diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 22:16:45 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 22:16:45 +0100 |
| commit | 03d044b88dd1377281caa44c0133d9f22579ba90 (patch) | |
| tree | 216c88a5344c2299c5120b035433e96d1fd2f91a /src/ot_tcp.c | |
| parent | fdbd31bbb3e61cc42c2d12371975b892934dd51c (diff) | |
Add a generation to a task on the workqueue to prevent its result being sent to the next client reusing the fd
Diffstat (limited to 'src/ot_tcp.c')
| -rw-r--r-- | src/ot_tcp.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ot_tcp.c b/src/ot_tcp.c index 5d7b78f..67a0ebc 100644 --- a/src/ot_tcp.c +++ b/src/ot_tcp.c | |||
| @@ -44,9 +44,19 @@ static ssize_t header_complete(char *request, ssize_t byte_count) { | |||
| 44 | 44 | ||
| 45 | void tcp_read(const int64_t sock, struct ot_workstruct *ws) { | 45 | void tcp_read(const int64_t sock, struct ot_workstruct *ws) { |
| 46 | struct http_data *cookie = fdstate_cookie(sock); | 46 | struct http_data *cookie = fdstate_cookie(sock); |
| 47 | ssize_t byte_count = read((int)sock, ws->inbuf, G_INBUF_SIZE); | 47 | ssize_t byte_count; |
| 48 | uint32_t generation; | 48 | uint32_t generation; |
| 49 | 49 | ||
| 50 | /* We're not supposed to read from a socket that waits for | ||
| 51 | our answer. Prevent its reply from being sent to the next | ||
| 52 | generation on that fd. */ | ||
| 53 | if (cookie->flag & (STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER)) { | ||
| 54 | http_close(sock); | ||
| 55 | return; | ||
| 56 | } | ||
| 57 | |||
| 58 | byte_count = read((int)sock, ws->inbuf, G_INBUF_SIZE); | ||
| 59 | |||
| 50 | if (byte_count == 0 || (byte_count == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)) { | 60 | if (byte_count == 0 || (byte_count == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)) { |
| 51 | http_close(sock); | 61 | http_close(sock); |
| 52 | return; | 62 | return; |
