summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authorerdgeist <>2007-02-01 13:30:58 +0000
committererdgeist <>2007-02-01 13:30:58 +0000
commit62c59983cb3122ec20183efb27b1a9e9e454971d (patch)
treefa8732c91e547d61d3b6b23f51528d03987f1b6c /opentracker.c
parent10a6586ad19db2238d127aed5050f4796c153744 (diff)
Use multiple output buffers to try to avoid copy on write when unnecessary
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c11
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;
32static time_t ot_start_time; 32static time_t ot_start_time;
33static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; 33static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
34static const size_t SUCCESS_HTTP_SIZE_OFF = 17; 34static 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
36static char static_inbuf[8192]; 43static char static_inbuf[8192];
37static char static_outbuf[8192*4]; 44static char static_outbufs[ static_outbuf_size * static_outbuf_count ];
45static int static_outbuf_off = 0;
38 46
39#ifdef _DEBUG_HTTPERROR 47#ifdef _DEBUG_HTTPERROR
40static char debug_request[8192]; 48static 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 );