summaryrefslogtreecommitdiff
path: root/lib/async_req
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-10-02 07:56:30 -0700
committerJeremy Allison <jra@samba.org>2020-02-26 19:45:36 +0000
commit048a4230b2774f4dd1ec706af5b675226da1e872 (patch)
tree61c9463f6d9e4e92d3aebdbc1db4bf49cf716308 /lib/async_req
parent6d63fa024668d1f02fee0fa6b309497703be6a96 (diff)
downloadsamba-048a4230b2774f4dd1ec706af5b675226da1e872.tar.gz
lib/async_req: make sure we return errors early from async_connect_send/recv
While it is true that [e]poll() only needs POLLOUT and POLLERR/POLLHUP are added implicitly. For tevent we need TEVENT_FD_READ in order to see POLLERR/POLLHUP. The socket becomes only readable when we hit an error. Waiting for TEVENT_FD_WRITE is needed for getting success, while TEVENT_FD_READ is required to get failures. This matches what we have in tstream_bsd_connect_send(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/async_req')
-rw-r--r--lib/async_req/async_sock.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 0a8a333f4f3..d0cb06b0638 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -147,7 +147,14 @@ struct tevent_req *async_connect_send(
return tevent_req_post(req, ev);
}
- state->fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE,
+ /*
+ * Note for historic reasons TEVENT_FD_WRITE is not enough
+ * to get notified for POLLERR or EPOLLHUP even if they
+ * come together with POLLOUT. That means we need to
+ * use TEVENT_FD_READ in addition until we have
+ * TEVENT_FD_ERROR.
+ */
+ state->fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ|TEVENT_FD_WRITE,
async_connect_connected, req);
if (state->fde == NULL) {
tevent_req_error(req, ENOMEM);