|
|
|
@ -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 */
|
|
|
|
|