diff options
author | erdgeist <> | 2007-11-21 01:53:17 +0000 |
---|---|---|
committer | erdgeist <> | 2007-11-21 01:53:17 +0000 |
commit | e65ac51a28b15844ca6f6cd15b203d6594c1c81a (patch) | |
tree | c85519edee2f0ede88e066f78a2675182ee26dfe | |
parent | e9d49af9fada3ca2b427cdb70cbd0a957798c406 (diff) |
Last user of sendmmapdata is gone. Purge it.
-rw-r--r-- | opentracker.c | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/opentracker.c b/opentracker.c index 6b5902e..a2ada33 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <sys/types.h> | 8 | #include <sys/types.h> |
9 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
10 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
11 | #include <sys/mman.h> | ||
12 | #include <arpa/inet.h> | 11 | #include <arpa/inet.h> |
13 | #include <unistd.h> | 12 | #include <unistd.h> |
14 | #include <stdlib.h> | 13 | #include <stdlib.h> |
@@ -62,8 +61,8 @@ time_t g_now; | |||
62 | #endif | 61 | #endif |
63 | 62 | ||
64 | /* To always have space for error messages ;) */ | 63 | /* To always have space for error messages ;) */ |
65 | char static_inbuf[8192]; | 64 | static char static_inbuf[8192]; |
66 | char static_outbuf[8192]; | 65 | static char static_outbuf[8192]; |
67 | 66 | ||
68 | #define OT_MAXMULTISCRAPE_COUNT 64 | 67 | #define OT_MAXMULTISCRAPE_COUNT 64 |
69 | static ot_hash multiscrape_buf[OT_MAXMULTISCRAPE_COUNT]; | 68 | static ot_hash multiscrape_buf[OT_MAXMULTISCRAPE_COUNT]; |
@@ -103,7 +102,6 @@ int main( int argc, char **argv ); | |||
103 | static void httperror( const int64 s, const char *title, const char *message ); | 102 | static void httperror( const int64 s, const char *title, const char *message ); |
104 | static void httpresponse( const int64 s, char *data _DEBUG_HTTPERROR_PARAM(size_t l ) ); | 103 | static void httpresponse( const int64 s, char *data _DEBUG_HTTPERROR_PARAM(size_t l ) ); |
105 | 104 | ||
106 | static void sendmmapdata( const int64 s, char *buffer, const size_t size ); | ||
107 | static void sendiovecdata( const int64 s, int iovec_entries, struct iovec *iovector ); | 105 | static void sendiovecdata( const int64 s, int iovec_entries, struct iovec *iovector ); |
108 | static void senddata( const int64 s, char *buffer, const size_t size ); | 106 | static void senddata( const int64 s, char *buffer, const size_t size ); |
109 | 107 | ||
@@ -152,42 +150,6 @@ static void httperror( const int64 s, const char *title, const char *message ) { | |||
152 | senddata(s,static_outbuf,reply_size); | 150 | senddata(s,static_outbuf,reply_size); |
153 | } | 151 | } |
154 | 152 | ||
155 | static void sendmmapdata( const int64 s, char *buffer, size_t size ) { | ||
156 | struct http_data *h = io_getcookie( s ); | ||
157 | char *header; | ||
158 | size_t header_size; | ||
159 | tai6464 t; | ||
160 | |||
161 | if( !h ) { | ||
162 | munmap( buffer, size ); | ||
163 | return; | ||
164 | } | ||
165 | if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) { | ||
166 | h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED; | ||
167 | array_reset( &h->request ); | ||
168 | } | ||
169 | |||
170 | header = malloc( SUCCESS_HTTP_HEADER_LENGTH ); | ||
171 | if( !header ) { | ||
172 | munmap( buffer, size ); | ||
173 | HTTPERROR_500; | ||
174 | } | ||
175 | |||
176 | header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r\n", size ); | ||
177 | |||
178 | iob_reset( &h->batch ); | ||
179 | iob_addbuf_free( &h->batch, header, header_size ); | ||
180 | iob_addbuf_munmap( &h->batch, buffer, size ); | ||
181 | h->flag |= STRUCT_HTTP_FLAG_IOB_USED; | ||
182 | |||
183 | /* writeable sockets timeout after twice the pool timeout | ||
184 | which defaults to 5 minutes (e.g. after 10 minutes) */ | ||
185 | taia_now( &t ); taia_addsec( &t, &t, OT_CLIENT_TIMEOUT_SEND ); | ||
186 | io_timeout( s, t ); | ||
187 | io_dontwantread( s ); | ||
188 | io_wantwrite( s ); | ||
189 | } | ||
190 | |||
191 | static void sendiovecdata( const int64 s, int iovec_entries, struct iovec *iovector ) { | 153 | static void sendiovecdata( const int64 s, int iovec_entries, struct iovec *iovector ) { |
192 | struct http_data *h = io_getcookie( s ); | 154 | struct http_data *h = io_getcookie( s ); |
193 | char *header; | 155 | char *header; |
@@ -343,9 +305,11 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | |||
343 | } | 305 | } |
344 | 306 | ||
345 | if( mode == SYNC_OUT ) { | 307 | if( mode == SYNC_OUT ) { |
346 | char *reply; | 308 | /* Pass this task to the worker thread */ |
347 | if( !( reply_size = return_changeset_for_tracker( &reply ) ) ) HTTPERROR_500; | 309 | h->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; |
348 | return sendmmapdata( s, reply, reply_size ); | 310 | sync_deliver( s ); |
311 | io_dontwantread( s ); | ||
312 | return; | ||
349 | } | 313 | } |
350 | 314 | ||
351 | /* Simple but proof for now */ | 315 | /* Simple but proof for now */ |
@@ -789,8 +753,8 @@ static void server_mainloop( ) { | |||
789 | } | 753 | } |
790 | 754 | ||
791 | /* See if we need to move our pools */ | 755 | /* See if we need to move our pools */ |
792 | if( g_now != ot_last_clean_time ) { | 756 | if( NOW != ot_last_clean_time ) { |
793 | ot_last_clean_time = g_now; | 757 | ot_last_clean_time = NOW; |
794 | clean_all_torrents(); | 758 | clean_all_torrents(); |
795 | } | 759 | } |
796 | } | 760 | } |
@@ -881,7 +845,8 @@ int main( int argc, char **argv ) { | |||
881 | if( trackerlogic_init( serverdir ) == -1 ) | 845 | if( trackerlogic_init( serverdir ) == -1 ) |
882 | panic( "Logic not started" ); | 846 | panic( "Logic not started" ); |
883 | 847 | ||
884 | g_now = ot_start_time = ot_last_clean_time = time( NULL ); | 848 | g_now = ot_start_time = time( NULL ); |
849 | ot_last_clean_time = NOW; | ||
885 | alarm(5); | 850 | alarm(5); |
886 | 851 | ||
887 | server_mainloop( ); | 852 | server_mainloop( ); |