s4:ldap_server: introduce a ldapsrv_call_destructor()
[bbaumbach/samba-autobuild/.git] / source4 / ldap_server / ldap_server.c
index 347a17dde5a62b2a8de26b1d6b27521e266b066d..062c3fc4b56782ab548f2a22046c1f83536d8e7c 100644 (file)
@@ -254,6 +254,18 @@ failed:
        return -1;
 }
 
+static int ldapsrv_call_destructor(struct ldapsrv_call *call)
+{
+       if (call->conn == NULL) {
+               return 0;
+       }
+
+       DLIST_REMOVE(call->conn->pending_calls, call);
+
+       call->conn = NULL;
+       return 0;
+}
+
 static struct tevent_req *ldapsrv_process_call_send(TALLOC_CTX *mem_ctx,
                                                    struct tevent_context *ev,
                                                    struct tevent_queue *call_queue,
@@ -504,6 +516,7 @@ static void ldapsrv_call_read_done(struct tevent_req *subreq)
                ldapsrv_terminate_connection(conn, "no memory");
                return;
        }
+       talloc_set_destructor(call, ldapsrv_call_destructor);
 
        call->conn = conn;