summaryrefslogtreecommitdiff
path: root/lib/async_req
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2021-01-17 11:04:47 +0100
committerJeremy Allison <jra@samba.org>2021-01-22 19:54:38 +0000
commite593f969607791571248dd3341089001f49362fa (patch)
tree5218d79bd5442254218744569a3638ee9329ca41 /lib/async_req
parentf055d3f7db1c6eb47a5773f3cbe5bf8a047f3830 (diff)
downloadsamba-e593f969607791571248dd3341089001f49362fa.tar.gz
lib: Make accept_recv() return the listening socket
This is helpful if you are in a listening loop with the same receiver for many sockets doing the same thing. 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.c9
-rw-r--r--lib/async_req/async_sock.h1
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 1a39c98ab38..3035aaaf623 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -767,20 +767,27 @@ static void accept_handler(struct tevent_context *ev, struct tevent_fd *fde,
}
int accept_recv(struct tevent_req *req,
+ int *listen_sock,
struct samba_sockaddr *paddr,
int *perr)
{
struct accept_state *state = tevent_req_data(req, struct accept_state);
+ int sock = state->sock;
int err;
if (tevent_req_is_unix_error(req, &err)) {
if (perr != NULL) {
*perr = err;
}
+ tevent_req_received(req);
return -1;
}
+ if (listen_sock != NULL) {
+ *listen_sock = state->listen_sock;
+ }
if (paddr != NULL) {
*paddr = state->addr;
}
- return state->sock;
+ tevent_req_received(req);
+ return sock;
}
diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h
index 6952345df0c..780195e3725 100644
--- a/lib/async_req/async_sock.h
+++ b/lib/async_req/async_sock.h
@@ -61,6 +61,7 @@ struct samba_sockaddr;
struct tevent_req *accept_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int listen_sock);
int accept_recv(struct tevent_req *req,
+ int *listen_sock,
struct samba_sockaddr *paddr,
int *perr);