diff options
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/opentracker.c b/opentracker.c index 441639a..cc0700c 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -156,7 +156,10 @@ static size_t header_complete( char * request, ssize_t byte_count ) { | |||
156 | static void handle_dead( const int64 sock ) { | 156 | static void handle_dead( const int64 sock ) { |
157 | struct http_data* cookie=io_getcookie( sock ); | 157 | struct http_data* cookie=io_getcookie( sock ); |
158 | if( cookie ) { | 158 | if( cookie ) { |
159 | iob_reset( &cookie->batch ); | 159 | size_t i; |
160 | for ( i = 0; i < cookie->batches; ++i) | ||
161 | iob_reset( cookie->batch + i ); | ||
162 | free( cookie->batch ); | ||
160 | array_reset( &cookie->request ); | 163 | array_reset( &cookie->request ); |
161 | if( cookie->flag & STRUCT_HTTP_FLAG_WAITINGFORTASK ) | 164 | if( cookie->flag & STRUCT_HTTP_FLAG_WAITINGFORTASK ) |
162 | mutex_workqueue_canceltask( sock ); | 165 | mutex_workqueue_canceltask( sock ); |
@@ -204,12 +207,22 @@ static void handle_read( const int64 sock, struct ot_workstruct *ws ) { | |||
204 | 207 | ||
205 | static void handle_write( const int64 sock ) { | 208 | static void handle_write( const int64 sock ) { |
206 | struct http_data* cookie=io_getcookie( sock ); | 209 | struct http_data* cookie=io_getcookie( sock ); |
207 | if( cookie ) { | 210 | size_t i; |
208 | int64 res = iob_send( sock, &cookie->batch ); | 211 | |
209 | if (res == 0 || res == -3) | 212 | /* Look for the first io_batch still containing bytes to write */ |
210 | handle_dead( sock ); | 213 | if( cookie ) |
211 | } else | 214 | for( i = 0; i < cookie->batches; ++i ) |
212 | handle_dead( sock ); | 215 | if( cookie->batch[i].bytesleft ) { |
216 | int64 res = iob_send( sock, cookie->batch + i ); | ||
217 | |||
218 | if( res == -3 ) | ||
219 | break; | ||
220 | |||
221 | if( res == -1 || res > 0 || i < cookie->batches - 1 ) | ||
222 | return; | ||
223 | } | ||
224 | |||
225 | handle_dead( sock ); | ||
213 | } | 226 | } |
214 | 227 | ||
215 | static void handle_accept( const int64 serversocket ) { | 228 | static void handle_accept( const int64 serversocket ) { |