mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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>
This commit is contained in:
parent
f055d3f7db
commit
e593f96960
@ -371,7 +371,7 @@ static void sock_socket_start_new_client(struct tevent_req *subreq)
|
||||
struct sock_client *client;
|
||||
int client_fd, ret;
|
||||
|
||||
client_fd = accept_recv(subreq, NULL, &ret);
|
||||
client_fd = accept_recv(subreq, NULL, NULL, &ret);
|
||||
TALLOC_FREE(subreq);
|
||||
if (client_fd == -1) {
|
||||
D_ERR("failed to accept new connection\n");
|
||||
|
@ -175,7 +175,7 @@ static void socket_process_client(struct tevent_req *subreq)
|
||||
int client_fd;
|
||||
int err = 0;
|
||||
|
||||
client_fd = accept_recv(subreq, NULL, &err);
|
||||
client_fd = accept_recv(subreq, NULL, NULL, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
|
||||
state->num_clients++;
|
||||
|
@ -4284,7 +4284,7 @@ static void server_new_client(struct tevent_req *subreq)
|
||||
int client_fd;
|
||||
int ret = 0;
|
||||
|
||||
client_fd = accept_recv(subreq, NULL, &ret);
|
||||
client_fd = accept_recv(subreq, NULL, NULL, &ret);
|
||||
TALLOC_FREE(subreq);
|
||||
if (client_fd == -1) {
|
||||
tevent_req_error(req, ret);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user