mirror of
				git://erdgeist.org/opentracker
				synced 2025-11-04 11:53:22 +08:00 
			
		
		
		
	Use multiple output buffers to try to avoid copy on write when unnecessary
This commit is contained in:
		
							parent
							
								
									10a6586ad1
								
							
						
					
					
						commit
						62c59983cb
					
				@ -32,9 +32,17 @@ static unsigned int ot_overall_successfulannounces = 0;
 | 
				
			|||||||
static time_t ot_start_time;
 | 
					static time_t ot_start_time;
 | 
				
			||||||
static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
 | 
					static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
 | 
				
			||||||
static const size_t SUCCESS_HTTP_SIZE_OFF = 17;
 | 
					static const size_t SUCCESS_HTTP_SIZE_OFF = 17;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* To always have space for error messages ;) */
 | 
					/* 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_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
 | 
					#ifdef _DEBUG_HTTPERROR
 | 
				
			||||||
static char debug_request[8192];
 | 
					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 );
 | 
					  written_size = write( s, buffer, size );
 | 
				
			||||||
  if( ( written_size < 0 ) || ( written_size == size ) ) {
 | 
					  if( ( written_size < 0 ) || ( written_size == size ) ) {
 | 
				
			||||||
 | 
					    static_outbuf_next;
 | 
				
			||||||
    free( h ); io_close( s );
 | 
					    free( h ); io_close( s );
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    char * outbuf = malloc( size - written_size );
 | 
					    char * outbuf = malloc( size - written_size );
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user