summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/messaging/irpc.h1
-rw-r--r--source4/lib/messaging/messaging.c14
2 files changed, 14 insertions, 1 deletions
diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h
index 1d704ad943..6873f014a6 100644
--- a/source4/lib/messaging/irpc.h
+++ b/source4/lib/messaging/irpc.h
@@ -69,6 +69,7 @@ struct irpc_request {
void *r;
NTSTATUS status;
BOOL done;
+ BOOL reject_free;
TALLOC_CTX *mem_ctx;
struct {
void (*fn)(struct irpc_request *);
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 04b340eb5a..705fdcc465 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -773,7 +773,14 @@ failed:
*/
static int irpc_destructor(struct irpc_request *irpc)
{
- idr_remove(irpc->msg_ctx->idr, irpc->callid);
+ if (irpc->callid != -1) {
+ idr_remove(irpc->msg_ctx->idr, irpc->callid);
+ irpc->callid = -1;
+ }
+
+ if (irpc->reject_free) {
+ return -1;
+ }
return 0;
}
@@ -866,11 +873,16 @@ NTSTATUS irpc_call_recv(struct irpc_request *irpc)
NT_STATUS_HAVE_NO_MEMORY(irpc);
+ irpc->reject_free = true;
+
while (!irpc->done) {
if (event_loop_once(irpc->msg_ctx->event.ev) != 0) {
return NT_STATUS_CONNECTION_DISCONNECTED;
}
}
+
+ irpc->reject_free = false;
+
status = irpc->status;
talloc_free(irpc);
return status;