Introduce tevent_req_simple_finish_ntstatus
authorVolker Lendecke <vl@samba.org>
Sat, 14 Nov 2009 08:38:20 +0000 (09:38 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 14 Nov 2009 10:03:28 +0000 (11:03 +0100)
lib/util/tevent_ntstatus.c
lib/util/tevent_ntstatus.h

index d6cb0affd93e08540dcbd77a31b54f20f8d14cbb..4be45754994fd1eef1a982510cb62131e83ab48d 100644 (file)
@@ -59,3 +59,18 @@ NTSTATUS tevent_req_simple_recv_ntstatus(struct tevent_req *req)
        }
        return NT_STATUS_OK;
 }
+
+void tevent_req_simple_finish_ntstatus(struct tevent_req *subreq,
+                                      NTSTATUS subreq_status)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+
+       TALLOC_FREE(subreq);
+
+       if (!NT_STATUS_IS_OK(subreq_status)) {
+               tevent_req_nterror(req, subreq_status);
+               return;
+       }
+       tevent_req_done(req);
+}
index 22fe9188d0441c58ac337f58a3fd87725ebdd3ca..4cf593a454ad9f66a23bd70667a7629ba098deb8 100644 (file)
@@ -29,4 +29,11 @@ bool tevent_req_nterror(struct tevent_req *req, NTSTATUS status);
 bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *pstatus);
 NTSTATUS tevent_req_simple_recv_ntstatus(struct tevent_req *req);
 
+/*
+ * Helper routine to pass the subreq_ntstatus to the req embedded in
+ * tevent_req_callback_data(subreq), which will be freed.
+ */
+void tevent_req_simple_finish_ntstatus(struct tevent_req *subreq,
+                                      NTSTATUS subreq_status);
+
 #endif