diff options
author | Volker Lendecke <vl@samba.org> | 2021-03-09 12:54:49 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-03-16 17:09:31 +0000 |
commit | b6b0c0cb7e034effd2370e9043140e2ac090c514 (patch) | |
tree | af0310fecf0c0c826bbb8aaba8cb1a5058a702f6 /lib/async_req | |
parent | c58e9aa482cc650f99d040808ccfc780e1232210 (diff) | |
download | samba-b6b0c0cb7e034effd2370e9043140e2ac090c514.tar.gz |
lib: Use FIONREAD in wait_for_read_send/recv
ENOTSOCK looks ugly in straces...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/async_req')
-rw-r--r-- | lib/async_req/async_sock.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index 3035aaaf623..ae1d3257f65 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -652,8 +652,7 @@ static void wait_for_read_done(struct tevent_context *ev, private_data, struct tevent_req); struct wait_for_read_state *state = tevent_req_data(req, struct wait_for_read_state); - ssize_t nread; - char c; + int ret, available; if ((flags & TEVENT_FD_READ) == 0) { return; @@ -664,26 +663,20 @@ static void wait_for_read_done(struct tevent_context *ev, return; } - nread = recv(state->fd, &c, 1, MSG_PEEK); + ret = ioctl(state->fd, FIONREAD, &available); - if (nread == 0) { - tevent_req_error(req, EPIPE); - return; - } - - if ((nread == -1) && (errno == EINTR)) { + if ((ret == -1) && (errno == EINTR)) { /* come back later */ return; } - if ((nread == -1) && (errno == ENOTSOCK)) { - /* Ignore this specific error on pipes */ - tevent_req_done(req); + if (ret == -1) { + tevent_req_error(req, errno); return; } - if (nread == -1) { - tevent_req_error(req, errno); + if (available == 0) { + tevent_req_error(req, EPIPE); return; } |