diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 12 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 82 |
2 files changed, 47 insertions, 47 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 559d62fec3..3fb57e44d4 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1423,12 +1423,12 @@ int open_socket_in(int type, bool rebind); NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port, int timeout, int *pfd); -struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, - const struct sockaddr_storage *pss, - uint16_t port, - int timeout); -NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd); +struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + const struct sockaddr_storage *pss, + uint16_t port, + int timeout); +NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd); struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct timeval wait_time, diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 83e8a9d355..b33088db61 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -967,20 +967,20 @@ static int open_socket_out_state_destructor(struct open_socket_out_state *s) Create an outgoing socket. timeout is in milliseconds. **************************************************************************/ -struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, - const struct sockaddr_storage *pss, - uint16_t port, - int timeout) +struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + const struct sockaddr_storage *pss, + uint16_t port, + int timeout) { char addr[INET6_ADDRSTRLEN]; - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct open_socket_out_state *state; NTSTATUS status; - if (!async_req_setup(mem_ctx, &result, &state, - struct open_socket_out_state)) { + result = tevent_req_create(mem_ctx, &state, + struct open_socket_out_state); + if (result == NULL) { return NULL; } state->ev = ev; @@ -996,7 +996,8 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, } talloc_set_destructor(state, open_socket_out_state_destructor); - if (!async_req_set_timeout(result, ev, timeval_set(0, timeout*1000))) { + if (!tevent_req_set_endtime( + result, ev, timeval_current_ofs(0, timeout*1000))) { goto fail; } @@ -1030,18 +1031,15 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, || !tevent_req_set_endtime( subreq, state->ev, timeval_current_ofs(0, state->wait_nsec))) { - status = NT_STATUS_NO_MEMORY; - goto post_status; + goto fail; } subreq->async.fn = open_socket_out_connected; subreq->async.private_data = result; return result; post_status: - if (!async_post_ntstatus(result, ev, status)) { - goto fail; - } - return result; + tevent_req_nterror(result, status); + return tevent_req_post(result, ev); fail: TALLOC_FREE(result); return NULL; @@ -1049,17 +1047,18 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, static void open_socket_out_connected(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct tevent_req *req = talloc_get_type_abort( + subreq->async.private_data, struct tevent_req); struct open_socket_out_state *state = talloc_get_type_abort( - req->private_data, struct open_socket_out_state); + req->private_state, struct open_socket_out_state); int ret; int sys_errno; ret = async_connect_recv(subreq, &sys_errno); TALLOC_FREE(subreq); if (ret == 0) { - async_req_done(req); + DEBUG(0, ("calling tevent_req_done from open_socket_out_connected\n")); + tevent_req_done(req); return; } @@ -1082,13 +1081,13 @@ static void open_socket_out_connected(struct tevent_req *subreq) subreq = async_connect_send(state, state->ev, state->fd, (struct sockaddr *)&state->ss, state->salen); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } if (!tevent_req_set_endtime( subreq, state->ev, timeval_current_ofs(0, state->wait_nsec))) { - async_req_error(req, ENOMEM); + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); return; } subreq->async.fn = open_socket_out_connected; @@ -1098,23 +1097,23 @@ static void open_socket_out_connected(struct tevent_req *subreq) #ifdef EISCONN if (sys_errno == EISCONN) { - async_req_done(req); + tevent_req_done(req); return; } #endif /* real error */ - async_req_error(req, sys_errno); + tevent_req_nterror(req, map_nt_error_from_unix(sys_errno)); } -NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd) +NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd) { struct open_socket_out_state *state = talloc_get_type_abort( - req->private_data, struct open_socket_out_state); - int err; + req->private_state, struct open_socket_out_state); + NTSTATUS status; - if (async_req_is_errno(req, &err)) { - return map_nt_error_from_unix(err); + if (tevent_req_is_nterror(req, &status)) { + return status; } *pfd = state->fd; state->fd = -1; @@ -1126,7 +1125,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port, { TALLOC_CTX *frame = talloc_stackframe(); struct event_context *ev; - struct async_req *req; + struct tevent_req *req; NTSTATUS status = NT_STATUS_NO_MEMORY; ev = event_context_init(frame); @@ -1138,10 +1137,10 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port, if (req == NULL) { goto fail; } - while (req->state < ASYNC_REQ_DONE) { - event_loop_once(ev); + if (!tevent_req_poll(req, ev)) { + status = NT_STATUS_INTERNAL_ERROR; + goto fail; } - status = open_socket_out_recv(req, pfd); fail: TALLOC_FREE(frame); @@ -1157,7 +1156,7 @@ struct open_socket_out_defer_state { }; static void open_socket_out_defer_waited(struct async_req *subreq); -static void open_socket_out_defer_connected(struct async_req *subreq); +static void open_socket_out_defer_connected(struct tevent_req *subreq); struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, struct event_context *ev, @@ -1204,6 +1203,7 @@ static void open_socket_out_defer_waited(struct async_req *subreq) subreq->async.priv, struct async_req); struct open_socket_out_defer_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_defer_state); + struct tevent_req *subreq2; bool ret; ret = async_wait_recv(subreq); @@ -1213,19 +1213,19 @@ static void open_socket_out_defer_waited(struct async_req *subreq) return; } - subreq = open_socket_out_send(state, state->ev, &state->ss, - state->port, state->timeout); - if (async_req_nomem(subreq, req)) { + subreq2 = open_socket_out_send(state, state->ev, &state->ss, + state->port, state->timeout); + if (async_req_nomem(subreq2, req)) { return; } - subreq->async.fn = open_socket_out_defer_connected; - subreq->async.priv = req; + subreq2->async.fn = open_socket_out_defer_connected; + subreq2->async.private_data = req; } -static void open_socket_out_defer_connected(struct async_req *subreq) +static void open_socket_out_defer_connected(struct tevent_req *subreq) { struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + subreq->async.private_data, struct async_req); struct open_socket_out_defer_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_defer_state); NTSTATUS status; |