diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-01-24 00:28:39 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-01-24 00:28:39 +0100 |
commit | 797f2def3d778f386cffdd1a98b9b685c4964693 (patch) | |
tree | 15124bfbc58be97bafe5984363e76c9709cd5be1 | |
parent | d7e9863f46bf45841206c8db91f61e7042433171 (diff) |
delegate/save errno in pevent forward_connection
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | src/pevent.c | 8 | ||||
-rw-r--r-- | src/redirector.c | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/pevent.c b/src/pevent.c index 9f0ef91..edcc16f 100644 --- a/src/pevent.c +++ b/src/pevent.c @@ -294,6 +294,12 @@ event_forward_connection(event_ctx *ctx, int dest_fd, on_data_cb on_data, errno = 0; siz = write(dest_fd, ev_buf->buf, ev_buf->buf_used); + saved_errno = errno; + // FIXME: Add EPOLLOUT to epoll fd and wait until the buffer is drained +/* + if (saved_errno == EAGAIN) + break; +*/ switch (siz) { case -1: @@ -318,5 +324,7 @@ event_forward_connection(event_ctx *ctx, int dest_fd, on_data_cb on_data, shutdown(ev_buf->fd, SHUT_RDWR); shutdown(dest_fd, SHUT_RDWR); } + + errno = saved_errno; return rc; } diff --git a/src/redirector.c b/src/redirector.c index e418224..e6ddda5 100644 --- a/src/redirector.c +++ b/src/redirector.c @@ -457,7 +457,7 @@ finish: static int client_io(event_ctx *ev_ctx, event_buf *buf, void *user_data) { - int dest_fd, src_fd = buf->fd; + int dest_fd, src_fd = buf->fd, saved_errno = 0; client_event *ev_cli = (client_event *) user_data; const psocket *client_sock = &ev_cli->client_args->client_sock; forward_state fwd_state; @@ -469,6 +469,7 @@ client_io(event_ctx *ev_ctx, event_buf *buf, void *user_data) } else return 0; fwd_state = event_forward_connection(ev_ctx, dest_fd, NULL, NULL); + saved_errno = errno; switch (fwd_state_string(fwd_state, ev_cli->client_args, ev_cli->fwd_sock)) @@ -480,6 +481,7 @@ client_io(event_ctx *ev_ctx, event_buf *buf, void *user_data) return 1; case CON_IN_ERROR: case CON_OUT_ERROR: + errno = saved_errno; ev_ctx->active = 0; return 0; } |