diff options
author | erdgeist <> | 2007-11-06 18:02:03 +0000 |
---|---|---|
committer | erdgeist <> | 2007-11-06 18:02:03 +0000 |
commit | 927ac023ce2c761063bbae81bb44b0aab624e36f (patch) | |
tree | cdae567406af42f8107daefdec8b762d30c63a13 /ot_stats.c | |
parent | ad5fa66737dd77260b881ca673d03b1c171fa7bd (diff) |
The expensive DMEM stats is gone. No need for it, too much potential to DOS.
Diffstat (limited to 'ot_stats.c')
-rw-r--r-- | ot_stats.c | 41 |
1 files changed, 0 insertions, 41 deletions
@@ -162,47 +162,6 @@ bailout_cleanup: | |||
162 | return 0; | 162 | return 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | size_t return_memstat_for_tracker( char **reply ) { | ||
166 | size_t torrent_count = 0, j; | ||
167 | size_t allocated, replysize; | ||
168 | ot_vector *torrents_list; | ||
169 | int bucket, k; | ||
170 | char *r; | ||
171 | |||
172 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | ||
173 | torrents_list = mutex_bucket_lock(bucket); | ||
174 | torrent_count += torrents_list->size; | ||
175 | mutex_bucket_unlock(bucket); | ||
176 | } | ||
177 | |||
178 | allocated = OT_BUCKET_COUNT*32 + (43+OT_POOLS_COUNT*32)*torrent_count; | ||
179 | if( !( r = *reply = mmap( NULL, allocated, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0 ) ) ) return 0; | ||
180 | |||
181 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | ||
182 | torrents_list = mutex_bucket_lock(bucket); | ||
183 | r += sprintf( r, "%02X: %08X %08X\n", bucket, (unsigned int)torrents_list->size, (unsigned int)torrents_list->space ); | ||
184 | mutex_bucket_unlock(bucket); | ||
185 | } | ||
186 | |||
187 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | ||
188 | ot_vector *torrents_list = mutex_bucket_lock(bucket); | ||
189 | char hex_out[42]; | ||
190 | for( j=0; j<torrents_list->size; ++j ) { | ||
191 | ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; | ||
192 | ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash; | ||
193 | r += sprintf( r, "\n%s:\n", to_hex( hex_out, (ot_byte*)hash) ); | ||
194 | for( k=0; k<OT_POOLS_COUNT; ++k ) | ||
195 | r += sprintf( r, "\t%05X %05X\n", ((unsigned int)peer_list->peers[k].size), (unsigned int)peer_list->peers[k].space ); | ||
196 | } | ||
197 | mutex_bucket_unlock(bucket); | ||
198 | } | ||
199 | |||
200 | replysize = ( r - *reply ); | ||
201 | fix_mmapallocation( *reply, allocated, replysize ); | ||
202 | |||
203 | return replysize; | ||
204 | } | ||
205 | |||
206 | static unsigned long events_per_time( unsigned long long events, time_t t ) { | 165 | static unsigned long events_per_time( unsigned long long events, time_t t ) { |
207 | return events / ( (unsigned int)t ? (unsigned int)t : 1 ); | 166 | return events / ( (unsigned int)t ? (unsigned int)t : 1 ); |
208 | } | 167 | } |