s4:libcli/raw: don't schedule idle handlers on a dead connection
authorStefan Metzmacher <metze@samba.org>
Sun, 17 Feb 2013 21:39:40 +0000 (22:39 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 28 Mar 2019 23:09:32 +0000 (23:09 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/libcli/raw/clitransport.c

index 47b8dbf3ae7f3a43dd7a3fc78365878e6df993de..26e9dee401d6e4204932c84c090dfadc6b21238a 100644 (file)
@@ -181,6 +181,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,
@@ -200,6 +208,15 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_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;