From ef1c3176c80a5d8533d590aacd0b5035ba589b17 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Mar 2010 17:58:19 +0100 Subject: s4:libcli/wrepl: correctly remove the tstream_context when the connection is dead metze --- source4/libcli/wrepl/winsrepl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/libcli/wrepl/winsrepl.c') diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 380c79a5ca..ec7e3798dc 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -413,6 +413,11 @@ static void wrepl_request_trigger(struct tevent_req *req, struct wrepl_request_state); struct tevent_req *subreq; + if (state->caller.wrepl_socket->stream == NULL) { + tevent_req_nterror(req, NT_STATUS_INVALID_CONNECTION); + return; + } + if (DEBUGLVL(10)) { DEBUG(10,("Sending WINS packet of length %u\n", (unsigned)state->req.blob.length)); @@ -445,10 +450,16 @@ static void wrepl_request_writev_done(struct tevent_req *subreq) TALLOC_FREE(subreq); if (ret == -1) { NTSTATUS status = map_nt_error_from_unix(sys_errno); + TALLOC_FREE(state->caller.wrepl_socket->stream); tevent_req_nterror(req, status); return; } + if (state->caller.wrepl_socket->stream == NULL) { + tevent_req_nterror(req, NT_STATUS_INVALID_CONNECTION); + return; + } + if (state->ctrl.disconnect_after_send) { subreq = tstream_disconnect_send(state, state->caller.ev, @@ -490,12 +501,13 @@ static void wrepl_request_disconnect_done(struct tevent_req *subreq) TALLOC_FREE(subreq); if (ret == -1) { NTSTATUS status = map_nt_error_from_unix(sys_errno); + TALLOC_FREE(state->caller.wrepl_socket->stream); tevent_req_nterror(req, status); return; } DEBUG(10,("WINS connection disconnected\n")); - state->caller.wrepl_socket->stream = NULL; + TALLOC_FREE(state->caller.wrepl_socket->stream); tevent_req_done(req); } @@ -512,6 +524,7 @@ static void wrepl_request_read_pdu_done(struct tevent_req *subreq) status = tstream_read_pdu_blob_recv(subreq, state, &state->rep.blob); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(state->caller.wrepl_socket->stream); tevent_req_nterror(req, status); return; } @@ -554,6 +567,7 @@ NTSTATUS wrepl_request_recv(struct tevent_req *req, NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { + TALLOC_FREE(state->caller.wrepl_socket->stream); tevent_req_received(req); return status; } -- cgit