diff options
Diffstat (limited to 'opentracker.c')
| -rw-r--r-- | opentracker.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/opentracker.c b/opentracker.c index 6160696..ec92fe0 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -180,12 +180,11 @@ static void handle_write(const int64_t sock) { | |||
| 180 | 180 | ||
| 181 | /* In a chunked transfer, wait for the next piece once everything queued has gone out */ | 181 | /* In a chunked transfer, wait for the next piece once everything queued has gone out */ |
| 182 | if (chunked) | 182 | if (chunked) |
| 183 | http_interest_drop(sock, cookie, EVENT_OUT); | 183 | http_interest_set(sock, cookie, 0); |
| 184 | else if (keep_alive) { | 184 | else if (keep_alive) { |
| 185 | /* The reply is out and the client asked to keep the connection, so stop | 185 | /* The reply is out and the client asked to keep the connection, so go |
| 186 | waiting to write and go back to waiting for the next request */ | 186 | back to waiting for the next request */ |
| 187 | http_interest_drop(sock, cookie, EVENT_OUT); | 187 | http_interest_set(sock, cookie, EVENT_IN); |
| 188 | http_interest_add(sock, cookie, EVENT_IN); | ||
| 189 | fdstate_set_expiry(sock, time_future_seconds(OT_CLIENT_TIMEOUT)); | 188 | fdstate_set_expiry(sock, time_future_seconds(OT_CLIENT_TIMEOUT)); |
| 190 | } else | 189 | } else |
| 191 | http_close(sock); | 190 | http_close(sock); |
| @@ -199,8 +198,6 @@ static void handle_accept(const int64_t serversocket, struct ot_workstruct *ws) | |||
| 199 | 198 | ||
| 200 | while ((sock = socket_accept(serversocket, ip, &port)) != -1) { | 199 | while ((sock = socket_accept(serversocket, ip, &port)) != -1) { |
| 201 | 200 | ||
| 202 | socket_set_blocking((int)sock, 0); | ||
| 203 | |||
| 204 | if (!(cookie = (struct http_data *)calloc(1, sizeof(struct http_data)))) { | 201 | if (!(cookie = (struct http_data *)calloc(1, sizeof(struct http_data)))) { |
| 205 | close((int)sock); | 202 | close((int)sock); |
| 206 | continue; | 203 | continue; |
| @@ -342,6 +339,7 @@ static void listen_bind_one(ot_listen *entry) { | |||
| 342 | if (entry->proto == FLAG_TCP) { | 339 | if (entry->proto == FLAG_TCP) { |
| 343 | if ((entry->sock = socket_tcp_listen(entry->ip, entry->port, sharing)) == -1) | 340 | if ((entry->sock = socket_tcp_listen(entry->ip, entry->port, sharing)) == -1) |
| 344 | panic("socket_tcp_listen"); | 341 | panic("socket_tcp_listen"); |
| 342 | socket_defer_accept((int)entry->sock); | ||
| 345 | } else { | 343 | } else { |
| 346 | if ((entry->sock = socket_udp_bind(entry->ip, entry->port, sharing)) == -1) | 344 | if ((entry->sock = socket_udp_bind(entry->ip, entry->port, sharing)) == -1) |
| 347 | panic("socket_udp_bind"); | 345 | panic("socket_udp_bind"); |
