summaryrefslogtreecommitdiffstats
path: root/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-01-08 10:31:15 +0100
committerStefan Metzmacher <metze@samba.org>2014-01-17 12:38:08 +0100
commitf08c0b2ef1bb92928ae86ba9d1c276a8e117367c (patch)
tree424180b71302ebf583134d63b884f760330234b2 /libcli
parentc4c88d1ee8960ae0d8a392821cf4f218725ab660 (diff)
downloadsamba-f08c0b2ef1bb92928ae86ba9d1c276a8e117367c.tar.gz
samba-f08c0b2ef1bb92928ae86ba9d1c276a8e117367c.tar.xz
samba-f08c0b2ef1bb92928ae86ba9d1c276a8e117367c.zip
libcli/smb: make use of tevent_req_set_cleanup_fn()
This is more better than a custom tevent_req destructor. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r--libcli/smb/smbXcli_base.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 082b62604b1..43dd9941053 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -785,7 +785,7 @@ void smbXcli_req_unset_pending(struct tevent_req *req)
return;
}
- talloc_set_destructor(req, NULL);
+ tevent_req_set_cleanup_fn(req, NULL);
if (num_pending == 1) {
/*
@@ -828,19 +828,25 @@ void smbXcli_req_unset_pending(struct tevent_req *req)
return;
}
-static int smbXcli_req_destructor(struct tevent_req *req)
+static void smbXcli_req_cleanup(struct tevent_req *req,
+ enum tevent_req_state req_state)
{
struct smbXcli_req_state *state =
tevent_req_data(req,
struct smbXcli_req_state);
- /*
- * Make sure we really remove it from
- * the pending array on destruction.
- */
- state->smb1.mid = 0;
- smbXcli_req_unset_pending(req);
- return 0;
+ switch (req_state) {
+ case TEVENT_REQ_RECEIVED:
+ /*
+ * Make sure we really remove it from
+ * the pending array on destruction.
+ */
+ state->smb1.mid = 0;
+ smbXcli_req_unset_pending(req);
+ return;
+ default:
+ return;
+ }
}
static bool smb1cli_req_cancel(struct tevent_req *req);
@@ -893,7 +899,7 @@ bool smbXcli_req_set_pending(struct tevent_req *req)
}
pending[num_pending] = req;
conn->pending = pending;
- talloc_set_destructor(req, smbXcli_req_destructor);
+ tevent_req_set_cleanup_fn(req, smbXcli_req_cleanup);
tevent_req_set_cancel_fn(req, smbXcli_req_cancel);
if (!smbXcli_conn_receive_next(conn)) {