From: Ralph Boehme Date: Mon, 9 Aug 2021 13:12:31 +0000 (+0200) Subject: s3/rpc_server: track the number of policy handles with a talloc destructor X-Git-Tag: ldb-2.5.0~995 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45a33b25c4e6b1db5d2dfa6297ccb390220a7c80;p=thirdparty%2Fsamba.git s3/rpc_server: track the number of policy handles with a talloc destructor BUG: https://bugzilla.samba.org/show_bug.cgi?id=14783 RN: smbd "deadtime" parameter doesn't work anymore Signed-off-by: Ralph Boehme Reviewed-by: Samuel Cabrero Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Aug 10 18:41:43 UTC 2021 on sn-devel-184 --- diff --git a/selftest/knownfail.d/samba3.blackbox.deadtime b/selftest/knownfail.d/samba3.blackbox.deadtime deleted file mode 100644 index 99d00fdef58..00000000000 --- a/selftest/knownfail.d/samba3.blackbox.deadtime +++ /dev/null @@ -1 +0,0 @@ -^samba3.blackbox.deadtime.deadtime.* diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c index 9ef93231466..745ea4dd6ef 100644 --- a/source3/rpc_server/rpc_handles.c +++ b/source3/rpc_server/rpc_handles.c @@ -103,18 +103,36 @@ size_t num_pipe_handles(void) data_ptr is TALLOC_FREE()'ed ****************************************************************************/ +struct hnd_cnt { + bool _dummy; +}; + +static int hnd_cnt_destructor(struct hnd_cnt *cnt) +{ + num_handles--; + return 0; +} + bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, uint8_t handle_type, void *data_ptr) { struct dcesrv_handle *rpc_hnd = NULL; + struct hnd_cnt *cnt = NULL; rpc_hnd = dcesrv_handle_create(p->dce_call, handle_type); if (rpc_hnd == NULL) { return false; } + cnt = talloc_zero(rpc_hnd, struct hnd_cnt); + if (cnt == NULL) { + TALLOC_FREE(rpc_hnd); + return false; + } + talloc_set_destructor(cnt, hnd_cnt_destructor); + if (data_ptr != NULL) { rpc_hnd->data = talloc_move(rpc_hnd, &data_ptr); } @@ -205,8 +223,6 @@ bool close_policy_hnd(struct pipes_struct *p, TALLOC_FREE(rpc_hnd); - num_handles--; - return true; }