diff options
| author | erdgeist <> | 2007-10-15 18:01:38 +0000 |
|---|---|---|
| committer | erdgeist <> | 2007-10-15 18:01:38 +0000 |
| commit | 65cc45f129fae1b961fa27615b7532c9380e4522 (patch) | |
| tree | 1fec05c7534cb7839b0d36e63badbb81fcc9668c | |
| parent | ffffd807193f3504107c405458ab0fa15b0b1e3c (diff) | |
Log all expansive operations to stderr
| -rw-r--r-- | opentracker.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/opentracker.c b/opentracker.c index 872a891..052d9b9 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -48,6 +48,8 @@ static char *accesslist_filename = NULL; | |||
| 48 | #define WANT_ACCESS_CONTROL | 48 | #define WANT_ACCESS_CONTROL |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #define LOG_TO_STDERR( ... ) fprintf( stderr, __VA_ARGS__ ) | ||
| 52 | |||
| 51 | /* To always have space for error messages ;) */ | 53 | /* To always have space for error messages ;) */ |
| 52 | 54 | ||
| 53 | static char static_inbuf[8192]; | 55 | static char static_inbuf[8192]; |
| @@ -220,6 +222,8 @@ static void httpresponse( const int64 s, char *data ) { | |||
| 220 | if( byte_diff( data, 4, "sync") ) HTTPERROR_404; | 222 | if( byte_diff( data, 4, "sync") ) HTTPERROR_404; |
| 221 | if( !h->blessed ) HTTPERROR_403_IP; | 223 | if( !h->blessed ) HTTPERROR_403_IP; |
| 222 | 224 | ||
| 225 | LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | ||
| 226 | |||
| 223 | mode = SYNC_OUT; | 227 | mode = SYNC_OUT; |
| 224 | scanon = 1; | 228 | scanon = 1; |
| 225 | 229 | ||
| @@ -292,6 +296,8 @@ static void httpresponse( const int64 s, char *data ) { | |||
| 292 | switch( mode) | 296 | switch( mode) |
| 293 | { | 297 | { |
| 294 | case STATS_DMEM: | 298 | case STATS_DMEM: |
| 299 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: dmem", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | ||
| 300 | |||
| 295 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; | 301 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 296 | return sendmallocdata( s, reply, reply_size ); | 302 | return sendmallocdata( s, reply, reply_size ); |
| 297 | 303 | ||
| @@ -316,6 +322,8 @@ static void httpresponse( const int64 s, char *data ) { | |||
| 316 | break; | 322 | break; |
| 317 | case STATS_SLASH24S: | 323 | case STATS_SLASH24S: |
| 318 | { | 324 | { |
| 325 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | ||
| 326 | |||
| 319 | ot_dword diff; struct timeval tv1, tv2; gettimeofday( &tv1, NULL ); | 327 | ot_dword diff; struct timeval tv1, tv2; gettimeofday( &tv1, NULL ); |
| 320 | if( !( reply_size = return_stats_for_slash24s( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 25, 16 ) ) ) HTTPERROR_500; | 328 | if( !( reply_size = return_stats_for_slash24s( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 25, 16 ) ) ) HTTPERROR_500; |
| 321 | gettimeofday( &tv2, NULL ); diff = ( tv2.tv_sec - tv1.tv_sec ) * 1000000 + tv2.tv_usec - tv1.tv_usec; | 329 | gettimeofday( &tv2, NULL ); diff = ( tv2.tv_sec - tv1.tv_sec ) * 1000000 + tv2.tv_usec - tv1.tv_usec; |
| @@ -324,6 +332,8 @@ static void httpresponse( const int64 s, char *data ) { | |||
| 324 | } | 332 | } |
| 325 | case STATS_SLASH24S_OLD: | 333 | case STATS_SLASH24S_OLD: |
| 326 | { | 334 | { |
| 335 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | ||
| 336 | |||
| 327 | ot_dword diff; struct timeval tv1, tv2; gettimeofday( &tv1, NULL ); | 337 | ot_dword diff; struct timeval tv1, tv2; gettimeofday( &tv1, NULL ); |
| 328 | if( !( reply_size = return_stats_for_slash24s_old( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 25, 16 ) ) ) HTTPERROR_500; | 338 | if( !( reply_size = return_stats_for_slash24s_old( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 25, 16 ) ) ) HTTPERROR_500; |
| 329 | gettimeofday( &tv2, NULL ); diff = ( tv2.tv_sec - tv1.tv_sec ) * 1000000 + tv2.tv_usec - tv1.tv_usec; | 339 | gettimeofday( &tv2, NULL ); diff = ( tv2.tv_sec - tv1.tv_sec ) * 1000000 + tv2.tv_usec - tv1.tv_usec; |
| @@ -361,6 +371,8 @@ SCRAPE_WORKAROUND: | |||
| 361 | 371 | ||
| 362 | /* Scanned whole query string, no hash means full scrape... you might want to limit that */ | 372 | /* Scanned whole query string, no hash means full scrape... you might want to limit that */ |
| 363 | if( !hash ) { | 373 | if( !hash ) { |
| 374 | LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | ||
| 375 | |||
| 364 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; | 376 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 365 | ot_overall_tcp_successfulannounces++; | 377 | ot_overall_tcp_successfulannounces++; |
| 366 | return sendmallocdata( s, reply, reply_size ); | 378 | return sendmallocdata( s, reply, reply_size ); |
