summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2007-11-23 18:14:22 +0000
committererdgeist <>2007-11-23 18:14:22 +0000
commit54560fdcd37b0fb47311aa53074137e5e85341c4 (patch)
tree4fab983086f1f91182c0945e89b9fd07475edbb9
parentafcef0537cfadc572315bb70a180ad74de6856e3 (diff)
strnstr is not part of what posix conform libc has to offer... replace it by strstr after cutting off the last byte
-rw-r--r--opentracker.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/opentracker.c b/opentracker.c
index 57c7e9a..9b8ea5b 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -256,6 +256,7 @@ static void httpresponse( const int64 s, char *data, size_t l ) {
256 unsigned short port = htons(6881); 256 unsigned short port = htons(6881);
257 ssize_t len; 257 ssize_t len;
258 size_t reply_size = 0, reply_off; 258 size_t reply_size = 0, reply_off;
259 tai6464 t;
259 260
260 /* Touch l and d in case it is unused */ 261 /* Touch l and d in case it is unused */
261 l = l; d = d; 262 l = l; d = d;
@@ -394,6 +395,9 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
394#endif 395#endif
395 /* Pass this task to the worker thread */ 396 /* Pass this task to the worker thread */
396 h->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; 397 h->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK;
398
399 /* Clients waiting for us should not easily timeout */
400 taia_uint( &t, 0 ); io_timeout( s, t );
397 fullscrape_deliver( s, format ); 401 fullscrape_deliver( s, format );
398 io_dontwantread( s ); 402 io_dontwantread( s );
399 return; 403 return;
@@ -412,20 +416,25 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
412 416
413 /* Full scrape... you might want to limit that */ 417 /* Full scrape... you might want to limit that */
414 if( !byte_diff( data, 12, "scrape HTTP/" ) ) { 418 if( !byte_diff( data, 12, "scrape HTTP/" ) ) {
415LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE\n", (unsigned int)(g_now - ot_start_time), h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
416#ifdef _DEBUG_HTTPERROR
417write( 2, debug_request, l );
418#endif
419 format = 0; 419 format = 0;
420#ifdef WANT_COMPRESSION_GZIP 420#ifdef WANT_COMPRESSION_GZIP
421 if( strnstr( d, "gzip", l ) ) { 421 d[l-1] = 0;
422 if( strstr( d, "gzip" ) ) {
422 h->flag |= STRUCT_HTTP_FLAG_GZIP; 423 h->flag |= STRUCT_HTTP_FLAG_GZIP;
423 format = TASK_FLAG_GZIP; 424 format = TASK_FLAG_GZIP;
424 } 425LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE GZIP\n", (unsigned int)(g_now - ot_start_time), h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
426 } else
427#endif
428 LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE\n", (unsigned int)(g_now - ot_start_time), h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
429
430#ifdef _DEBUG_HTTPERROR
431write( 2, debug_request, l );
425#endif 432#endif
426 433
427 /* Pass this task to the worker thread */ 434 /* Pass this task to the worker thread */
428 h->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; 435 h->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK;
436 /* Clients waiting for us should not easily timeout */
437 taia_uint( &t, 0 ); io_timeout( s, t );
429 fullscrape_deliver( s, TASK_FULLSCRAPE | format ); 438 fullscrape_deliver( s, TASK_FULLSCRAPE | format );
430 io_dontwantread( s ); 439 io_dontwantread( s );
431 return; 440 return;