TODO 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>
Tue, 4 Oct 2016 12:51:56 +0000 (14:51 +0200)
source4/libcli/smb2/transport.c

index 166f34b82569d01702f3f6d5b91405e6d74fd929..b501b52ce51843e894c96f39cd8d1d61f4e7fd3d 100644 (file)
@@ -456,6 +456,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,
@@ -474,6 +482,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;