From 8e78ac70121b3d634cc224726b169e26938525d9 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 17 Oct 2007 14:43:14 +0000 Subject: HEADS UP: you need to check out the latest libowfat! Huge allocations are now taken from mmap()ed regions, not from heap anymore --- opentracker.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'opentracker.c') diff --git a/opentracker.c b/opentracker.c index ae755cc..2e46fa1 100644 --- a/opentracker.c +++ b/opentracker.c @@ -83,7 +83,7 @@ int main( int argc, char **argv ); static void httperror( const int64 s, const char *title, const char *message ); static void httpresponse( const int64 s, char *data ); -static void sendmallocdata( const int64 s, char *buffer, const size_t size ); +static void sendmmapdata( const int64 s, char *buffer, const size_t size ); static void senddata( const int64 s, char *buffer, const size_t size ); static void server_mainloop( ); @@ -132,7 +132,7 @@ static void httperror( const int64 s, const char *title, const char *message ) { senddata(s,static_outbuf,reply_size); } -static void sendmallocdata( const int64 s, char *buffer, size_t size ) { +static void sendmmapdata( const int64 s, char *buffer, size_t size ) { struct http_data *h = io_getcookie( s ); char *header; size_t header_size; @@ -152,7 +152,7 @@ static void sendmallocdata( const int64 s, char *buffer, size_t size ) { iob_reset( &h->batch ); iob_addbuf_free( &h->batch, header, header_size ); - iob_addbuf_free( &h->batch, buffer, size ); + iob_addbuf_munmap( &h->batch, buffer, size ); /* writeable sockets timeout after twice the pool timeout which defaults to 5 minutes (e.g. after 10 minutes) */ @@ -253,7 +253,7 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); if( mode == SYNC_OUT ) { if( !( reply_size = return_changeset_for_tracker( &reply ) ) ) HTTPERROR_500; - return sendmallocdata( s, reply, reply_size ); + return sendmmapdata( s, reply, reply_size ); } /* Simple but proof for now */ @@ -305,7 +305,7 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: dmem\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; - return sendmallocdata( s, reply, reply_size ); + return sendmmapdata( s, reply, reply_size ); case STATS_UDP: t = time( NULL ) - ot_start_time; @@ -380,9 +380,8 @@ SCRAPE_WORKAROUND: LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; - if( (c = realloc( reply, reply_size ) ) ) reply = c; ot_overall_tcp_successfulannounces++; - return sendmallocdata( s, reply, reply_size ); + return sendmmapdata( s, reply, reply_size ); } /* Enough for http header + whole scrape string */ -- cgit v1.2.3