1 From c35e4be4f481312e3b0d639ae8bb980786749321 Mon Sep 17 00:00:00 2001
2 From: Julien Kerihuel <j.kerihuel@openchange.org>
3 Date: Mon, 6 Apr 2015 11:26:58 +0200
4 Subject: [PATCH] Add DCERPC flag to call unbind hooks without destroying the
5 connection itself upon termination of a connection with outstanding pending
8 Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
11 Autobuild-User(master): Jeremy Allison <jra@samba.org>
12 Autobuild-Date(master): Tue Apr 14 20:39:34 CEST 2015 on sn-devel-104
14 (cherry picked from commit fd90d270c7e97a639f42a96b674a674d1b51aa0d)
16 source4/rpc_server/dcerpc_server.c | 21 +++++++++++++++++++++
17 source4/rpc_server/dcerpc_server.h | 1 +
18 2 files changed, 22 insertions(+)
20 diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
21 index 4681e17..f25aa68 100644
22 --- a/source4/rpc_server/dcerpc_server.c
23 +++ b/source4/rpc_server/dcerpc_server.c
24 @@ -504,6 +504,7 @@ static int dcesrv_connection_context_destructor(struct dcesrv_connection_context
26 if (c->iface && c->iface->unbind) {
27 c->iface->unbind(c, c->iface);
32 @@ -620,6 +621,10 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
33 extra_flags |= DCERPC_PFC_FLAG_CONC_MPX;
36 + if (call->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
37 + call->context->conn->state_flags |= DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL;
40 /* handle any authentication that is being requested */
41 if (!dcesrv_auth_bind(call)) {
42 talloc_free(call->context);
43 @@ -839,6 +844,10 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
47 + if (call->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
48 + call->context->conn->state_flags |= DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL;
51 /* setup a alter_resp */
52 dcesrv_init_hdr(&pkt, lpcfg_rpc_big_endian(call->conn->dce_ctx->lp_ctx));
54 @@ -1377,6 +1386,18 @@ static void dcesrv_cleanup_broken_connections(struct dcesrv_context *dce_ctx)
58 + if (cur->state_flags & DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL) {
59 + struct dcesrv_connection_context *context_cur, *context_next;
61 + context_next = cur->contexts;
62 + while (context_next != NULL) {
63 + context_cur = context_next;
64 + context_next = context_cur->next;
66 + dcesrv_connection_context_destructor(context_cur);
70 dcesrv_terminate_connection(cur, cur->terminate);
73 diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h
74 index 2346876..8786cd8 100644
75 --- a/source4/rpc_server/dcerpc_server.h
76 +++ b/source4/rpc_server/dcerpc_server.h
77 @@ -102,6 +102,7 @@ struct dcesrv_call_state {
78 #define DCESRV_CALL_STATE_FLAG_ASYNC (1<<0)
79 #define DCESRV_CALL_STATE_FLAG_MAY_ASYNC (1<<1)
80 #define DCESRV_CALL_STATE_FLAG_MULTIPLEXED (1<<3)
81 +#define DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL (1<<4)
84 /* the time the request arrived in the server */