diff options
Diffstat (limited to 'opentracker.c')
| -rw-r--r-- | opentracker.c | 13 |
1 files changed, 6 insertions, 7 deletions
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 ); | |||
| 83 | static void httperror( const int64 s, const char *title, const char *message ); | 83 | static void httperror( const int64 s, const char *title, const char *message ); |
| 84 | static void httpresponse( const int64 s, char *data ); | 84 | static void httpresponse( const int64 s, char *data ); |
| 85 | 85 | ||
| 86 | static void sendmallocdata( const int64 s, char *buffer, const size_t size ); | 86 | static void sendmmapdata( const int64 s, char *buffer, const size_t size ); |
| 87 | static void senddata( const int64 s, char *buffer, const size_t size ); | 87 | static void senddata( const int64 s, char *buffer, const size_t size ); |
| 88 | 88 | ||
| 89 | static void server_mainloop( ); | 89 | static void server_mainloop( ); |
| @@ -132,7 +132,7 @@ static void httperror( const int64 s, const char *title, const char *message ) { | |||
| 132 | senddata(s,static_outbuf,reply_size); | 132 | senddata(s,static_outbuf,reply_size); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | static void sendmallocdata( const int64 s, char *buffer, size_t size ) { | 135 | static void sendmmapdata( const int64 s, char *buffer, size_t size ) { |
| 136 | struct http_data *h = io_getcookie( s ); | 136 | struct http_data *h = io_getcookie( s ); |
| 137 | char *header; | 137 | char *header; |
| 138 | size_t header_size; | 138 | size_t header_size; |
| @@ -152,7 +152,7 @@ static void sendmallocdata( const int64 s, char *buffer, size_t size ) { | |||
| 152 | 152 | ||
| 153 | iob_reset( &h->batch ); | 153 | iob_reset( &h->batch ); |
| 154 | iob_addbuf_free( &h->batch, header, header_size ); | 154 | iob_addbuf_free( &h->batch, header, header_size ); |
| 155 | iob_addbuf_free( &h->batch, buffer, size ); | 155 | iob_addbuf_munmap( &h->batch, buffer, size ); |
| 156 | 156 | ||
| 157 | /* writeable sockets timeout after twice the pool timeout | 157 | /* writeable sockets timeout after twice the pool timeout |
| 158 | which defaults to 5 minutes (e.g. after 10 minutes) */ | 158 | 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] ); | |||
| 253 | 253 | ||
| 254 | if( mode == SYNC_OUT ) { | 254 | if( mode == SYNC_OUT ) { |
| 255 | if( !( reply_size = return_changeset_for_tracker( &reply ) ) ) HTTPERROR_500; | 255 | if( !( reply_size = return_changeset_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 256 | return sendmallocdata( s, reply, reply_size ); | 256 | return sendmmapdata( s, reply, reply_size ); |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | /* Simple but proof for now */ | 259 | /* 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] ); | |||
| 305 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: dmem\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | 305 | LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: dmem\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); |
| 306 | 306 | ||
| 307 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; | 307 | if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 308 | return sendmallocdata( s, reply, reply_size ); | 308 | return sendmmapdata( s, reply, reply_size ); |
| 309 | 309 | ||
| 310 | case STATS_UDP: | 310 | case STATS_UDP: |
| 311 | t = time( NULL ) - ot_start_time; | 311 | t = time( NULL ) - ot_start_time; |
| @@ -380,9 +380,8 @@ SCRAPE_WORKAROUND: | |||
| 380 | LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | 380 | LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); |
| 381 | 381 | ||
| 382 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; | 382 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; |
| 383 | if( (c = realloc( reply, reply_size ) ) ) reply = c; | ||
| 384 | ot_overall_tcp_successfulannounces++; | 383 | ot_overall_tcp_successfulannounces++; |
| 385 | return sendmallocdata( s, reply, reply_size ); | 384 | return sendmmapdata( s, reply, reply_size ); |
| 386 | } | 385 | } |
| 387 | 386 | ||
| 388 | /* Enough for http header + whole scrape string */ | 387 | /* Enough for http header + whole scrape string */ |
