diff options
-rw-r--r-- | opentracker.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/opentracker.c b/opentracker.c index 030e423..6200087 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -32,9 +32,17 @@ static unsigned int ot_overall_successfulannounces = 0; | |||
32 | static time_t ot_start_time; | 32 | static time_t ot_start_time; |
33 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; | 33 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; |
34 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; | 34 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; |
35 | |||
35 | /* To always have space for error messages ;) */ | 36 | /* To always have space for error messages ;) */ |
37 | |||
38 | #define static_outbuf_size 8192 | ||
39 | #define static_outbuf_count 64 | ||
40 | #define static_outbuf ( static_outbufs + static_outbuf_size * static_outbuf_off ) | ||
41 | #define static_outbuf_next ( static_outbuf_off = ( static_outbuf_off + 1 ) & ( static_outbuf_count - 1 ) ) | ||
42 | |||
36 | static char static_inbuf[8192]; | 43 | static char static_inbuf[8192]; |
37 | static char static_outbuf[8192*4]; | 44 | static char static_outbufs[ static_outbuf_size * static_outbuf_count ]; |
45 | static int static_outbuf_off = 0; | ||
38 | 46 | ||
39 | #ifdef _DEBUG_HTTPERROR | 47 | #ifdef _DEBUG_HTTPERROR |
40 | static char debug_request[8192]; | 48 | static char debug_request[8192]; |
@@ -138,6 +146,7 @@ static void senddata( const int64 s, char *buffer, size_t size ) { | |||
138 | 146 | ||
139 | written_size = write( s, buffer, size ); | 147 | written_size = write( s, buffer, size ); |
140 | if( ( written_size < 0 ) || ( written_size == size ) ) { | 148 | if( ( written_size < 0 ) || ( written_size == size ) ) { |
149 | static_outbuf_next; | ||
141 | free( h ); io_close( s ); | 150 | free( h ); io_close( s ); |
142 | } else { | 151 | } else { |
143 | char * outbuf = malloc( size - written_size ); | 152 | char * outbuf = malloc( size - written_size ); |