From 62c59983cb3122ec20183efb27b1a9e9e454971d Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 1 Feb 2007 13:30:58 +0000 Subject: Use multiple output buffers to try to avoid copy on write when unnecessary --- opentracker.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'opentracker.c') 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; static time_t ot_start_time; static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; static const size_t SUCCESS_HTTP_SIZE_OFF = 17; + /* To always have space for error messages ;) */ + +#define static_outbuf_size 8192 +#define static_outbuf_count 64 +#define static_outbuf ( static_outbufs + static_outbuf_size * static_outbuf_off ) +#define static_outbuf_next ( static_outbuf_off = ( static_outbuf_off + 1 ) & ( static_outbuf_count - 1 ) ) + static char static_inbuf[8192]; -static char static_outbuf[8192*4]; +static char static_outbufs[ static_outbuf_size * static_outbuf_count ]; +static int static_outbuf_off = 0; #ifdef _DEBUG_HTTPERROR static char debug_request[8192]; @@ -138,6 +146,7 @@ static void senddata( const int64 s, char *buffer, size_t size ) { written_size = write( s, buffer, size ); if( ( written_size < 0 ) || ( written_size == size ) ) { + static_outbuf_next; free( h ); io_close( s ); } else { char * outbuf = malloc( size - written_size ); -- cgit v1.2.3