s4:libcli/smb2: don't schedule idle handlers on a dead connection
authorStefan Metzmacher <metze@samba.org>
Sun, 17 Feb 2013 21:41:00 +0000 (22:41 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Feb 2019 10:31:19 +0000 (11:31 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/libcli/smb2/transport.c

index 18cc490be4804e9c1770aab51a53aca59a2de95f..5b5bb79150df4da684c4e5d3688708bfc781d4e3 100644 (file)
@@ -508,6 +508,14 @@ static void idle_handler(struct tevent_context *ev,
 
        transport->idle.func(transport, transport->idle.private_data);
 
+       if (transport->idle.func == NULL) {
+               return;
+       }
+
+       if (!smbXcli_conn_is_connected(transport->conn)) {
+               return;
+       }
+
        next = timeval_current_ofs_usec(transport->idle.period);
        transport->idle.te = tevent_add_timer(transport->ev,
                                              transport,
@@ -526,6 +534,15 @@ void smb2_transport_idle_handler(struct smb2_transport *transport,
                                 void *private_data)
 {
        TALLOC_FREE(transport->idle.te);
+       ZERO_STRUCT(transport->idle);
+
+       if (idle_func == NULL) {
+               return;
+       }
+
+       if (!smbXcli_conn_is_connected(transport->conn)) {
+               return;
+       }
 
        transport->idle.func = idle_func;
        transport->idle.private_data = private_data;