]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
librpc/rpc: add dcesrv_async_reply() helper that disconnects as needed
authorStefan Metzmacher <metze@samba.org>
Mon, 14 Aug 2023 10:58:14 +0000 (12:58 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 17 Oct 2023 19:20:38 +0000 (19:20 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/dcesrv_core.h
librpc/rpc/dcesrv_reply.c

index 98f8dd9750672a42fab45d7ca6cf2a1e2f066684..b03376dad48890984931a8a45295b98e11fff6e5 100644 (file)
@@ -514,7 +514,16 @@ void dcesrv_context_set_callbacks(
        struct dcesrv_context *dce_ctx,
        struct dcesrv_context_callbacks *cb);
 
+/*
+ * Use dcesrv_async_reply() in async code
+ */
 NTSTATUS dcesrv_reply(struct dcesrv_call_state *call);
+void _dcesrv_async_reply(struct dcesrv_call_state *call,
+                        const char *func,
+                        const char *location);
+#define dcesrv_async_reply(__call) \
+       _dcesrv_async_reply(__call, __func__, __location__)
+
 struct dcesrv_handle *dcesrv_handle_create(struct dcesrv_call_state *call,
                                           uint8_t handle_type);
 
index bc103e51171d94647d19275e3ec38976ba280671..94a616c7f592285ef2e54deac2a5ef13d863a41d 100644 (file)
@@ -267,3 +267,18 @@ _PUBLIC_ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
 
        return NT_STATUS_OK;
 }
+
+_PUBLIC_ void _dcesrv_async_reply(struct dcesrv_call_state *call,
+                                 const char *func,
+                                 const char *location)
+{
+       struct dcesrv_connection *conn = call->conn;
+       NTSTATUS status;
+
+       status = dcesrv_reply(call);
+       if (!NT_STATUS_IS_OK(status)) {
+               D_ERR("%s: %s: dcesrv_async_reply() failed - %s\n",
+                     func, location, nt_errstr(status));
+               dcesrv_terminate_connection(conn, nt_errstr(status));
+       }
+}