diff options
| author | Volker Lendecke <vl@samba.org> | 2013-12-03 13:20:38 +0000 |
|---|---|---|
| committer | Michael Adam <obnox@samba.org> | 2013-12-05 01:09:54 +0100 |
| commit | 051fb9155642a8c74f892df3547203a55826d2b9 (patch) | |
| tree | 49571756fcef2a686057bc731c1d0f64ef0db0be /source3/lib | |
| parent | 549b70eb434889ba54d83776f3773f2eac513ba3 (diff) | |
messaging3: Do not go through messages.tdb for self-sends
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
| -rw-r--r-- | source3/lib/messages_local.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c index c74c0aa0d0..36a267a1ba 100644 --- a/source3/lib/messages_local.c +++ b/source3/lib/messages_local.c @@ -354,6 +354,15 @@ static NTSTATUS message_notify(struct server_id procid) Send a message to a particular pid. ****************************************************************************/ +struct messaging_tdb_self_state { + struct messaging_context *msg; + struct messaging_rec rec; +}; + +static void messaging_tdb_trigger_self(struct tevent_context *ev, + struct tevent_immediate *im, + void *private_data); + static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx, struct server_id pid, int msg_type, const DATA_BLOB *data, @@ -380,6 +389,41 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx, SMB_ASSERT(procid_to_pid(&pid) > 0); + if (server_id_equal(&msg_ctx->id, &pid)) { + struct messaging_tdb_self_state *state; + struct tevent_immediate *im; + + TALLOC_FREE(frame); + + im = tevent_create_immediate(msg_ctx); + if (im == NULL) { + return NT_STATUS_NO_MEMORY; + } + + state = talloc(im, struct messaging_tdb_self_state); + if (state == NULL) { + TALLOC_FREE(im); + return NT_STATUS_NO_MEMORY; + } + state->msg = msg_ctx; + state->rec.msg_version = MESSAGE_VERSION; + state->rec.msg_type = msg_type & MSG_TYPE_MASK; + state->rec.dest = pid; + state->rec.src = msg_ctx->id; + + state->rec.buf = data_blob_talloc( + state, data->data, data->length); + if ((state->rec.buf.length != 0) && + (state->rec.buf.data == NULL)) { + TALLOC_FREE(im); + return NT_STATUS_NO_MEMORY; + } + + tevent_schedule_immediate(im, msg_ctx->event_ctx, + messaging_tdb_trigger_self, state); + return NT_STATUS_OK; + } + key = message_key_pid(frame, pid); if (tdb_chainlock(tdb->tdb, key) != 0) { @@ -437,6 +481,16 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx, return status; } +static void messaging_tdb_trigger_self(struct tevent_context *ev, + struct tevent_immediate *im, + void *private_data) +{ + struct messaging_tdb_self_state *state = talloc_get_type_abort( + private_data, struct messaging_tdb_self_state); + messaging_dispatch_rec(state->msg, &state->rec); +} + + /**************************************************************************** Retrieve all messages for a process. ****************************************************************************/ |
