libcli/smb: close the socket fd at the end of smbXcli_conn_disconnect()
authorStefan Metzmacher <metze@samba.org>
Thu, 28 May 2015 11:09:11 +0000 (13:09 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 12 Jun 2015 15:08:18 +0000 (17:08 +0200)
We need to cancel all pending requests before closing the socket fds,
otherwise we cause problem with the interaction with the epoll event backend.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
libcli/smb/smbXcli_base.c

index c2ba83af404ad1b91cdf58dd1054ae1fdb322629..b38792e87be4b2bc388d0e6deea932f152561c5e 100644 (file)
@@ -997,15 +997,11 @@ static bool smbXcli_conn_receive_next(struct smbXcli_conn *conn)
 void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status)
 {
        struct smbXcli_session *session;
+       int read_fd = conn->read_fd;
+       int write_fd = conn->write_fd;
 
        tevent_queue_stop(conn->outgoing);
 
-       if (conn->read_fd != -1) {
-               close(conn->read_fd);
-       }
-       if (conn->write_fd != -1) {
-               close(conn->write_fd);
-       }
        conn->read_fd = -1;
        conn->write_fd = -1;
 
@@ -1088,6 +1084,13 @@ void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status)
                }
                TALLOC_FREE(chain);
        }
+
+       if (read_fd != -1) {
+               close(read_fd);
+       }
+       if (write_fd != -1) {
+               close(write_fd);
+       }
 }
 
 /*