Add DCERPC flag to call unbind hooks without destroying the connection itself upon...
authorJulien Kerihuel <j.kerihuel@openchange.org>
Mon, 6 Apr 2015 09:26:58 +0000 (11:26 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 28 Apr 2015 00:20:32 +0000 (02:20 +0200)
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 14 20:39:34 CEST 2015 on sn-devel-104

(cherry picked from commit fd90d270c7e97a639f42a96b674a674d1b51aa0d)

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11226
Fix terminate connection behavior for asynchronous endpoint with PUSH
notification flavors

Autobuild-User(v4-2-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-2-test): Tue Apr 28 02:20:32 CEST 2015 on sn-devel-104

source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcerpc_server.h

index 4681e1786486ea7a52863671de1926cf9b398e3f..f25aa68b2da8af2e7334fa70c543bd56f6f2a6d3 100644 (file)
@@ -504,6 +504,7 @@ static int dcesrv_connection_context_destructor(struct dcesrv_connection_context
 
        if (c->iface && c->iface->unbind) {
                c->iface->unbind(c, c->iface);
+               c->iface = NULL;
        }
 
        return 0;
@@ -620,6 +621,10 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
                extra_flags |= DCERPC_PFC_FLAG_CONC_MPX;
        }
 
+       if (call->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
+               call->context->conn->state_flags |= DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL;
+       }
+
        /* handle any authentication that is being requested */
        if (!dcesrv_auth_bind(call)) {
                talloc_free(call->context);
@@ -839,6 +844,10 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
                }
        }
 
+       if (call->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
+               call->context->conn->state_flags |= DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL;
+       }
+
        /* setup a alter_resp */
        dcesrv_init_hdr(&pkt, lpcfg_rpc_big_endian(call->conn->dce_ctx->lp_ctx));
        pkt.auth_length = 0;
@@ -1377,6 +1386,18 @@ static void dcesrv_cleanup_broken_connections(struct dcesrv_context *dce_ctx)
                cur = next;
                next = cur->next;
 
+               if (cur->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
+                       struct dcesrv_connection_context *context_cur, *context_next;
+
+                       context_next = cur->contexts;
+                       while (context_next != NULL) {
+                               context_cur = context_next;
+                               context_next = context_cur->next;
+
+                               dcesrv_connection_context_destructor(context_cur);
+                       }
+               }
+
                dcesrv_terminate_connection(cur, cur->terminate);
        }
 }
index 23468768f2eaec1de0d6874ad3df6c4b8f5bb618..8786cd83cc6fd14feb1e6e40e9a911a9f4375140 100644 (file)
@@ -102,6 +102,7 @@ struct dcesrv_call_state {
 #define DCESRV_CALL_STATE_FLAG_ASYNC (1<<0)
 #define DCESRV_CALL_STATE_FLAG_MAY_ASYNC (1<<1)
 #define DCESRV_CALL_STATE_FLAG_MULTIPLEXED (1<<3)
+#define DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL (1<<4)
        uint32_t state_flags;
 
        /* the time the request arrived in the server */