s3:lib: fix some corner cases of open_socket_out_cleanup()
authorStefan Metzmacher <metze@samba.org>
Fri, 14 Aug 2015 10:54:00 +0000 (12:54 +0200)
committerRalph Böhme <slow@samba.org>
Mon, 17 Aug 2015 15:43:36 +0000 (17:43 +0200)
In case of timeouts we retry the async_connect_send() and forgot
to remember it, this results in an abort() in async_connect_cleanup()
as the fd is already closed when calling fcntl(F_SETFL).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/lib/util_sock.c

index a8a9ccac11f2e3096206d0e2e42d53a1eb47755c..cb57f84a1f3b1336bafe900af7b08ccdebb58290 100644 (file)
@@ -580,6 +580,7 @@ static void open_socket_out_connected(struct tevent_req *subreq)
                        tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
                        return;
                }
+               state->connect_subreq = subreq;
                tevent_req_set_callback(subreq, open_socket_out_connected, req);
                return;
        }
@@ -602,10 +603,12 @@ NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd)
        NTSTATUS status;
 
        if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
                return status;
        }
        *pfd = state->fd;
        state->fd = -1;
+       tevent_req_received(req);
        return NT_STATUS_OK;
 }