From b4a95b949ee15054cf503029327bde9e75b7d17b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 5 Jun 2005 07:37:27 +0000 Subject: r7296: avoid two stat() calls per message. This increases the raw message rate from 20k/sec to 55k/sec. The irpc rate goes from 16k/sec to 34k/sec. I should have run strace -T on this a long time ago. (This used to be commit b9281668bb0c971af14df37ec3e979b9d5ef276e) --- source4/lib/messaging/messaging.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source4') diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index be89c97e5b..4c4b6ea8da 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -36,6 +36,7 @@ struct messaging_context { uint32_t server_id; struct socket_context *sock; + const char *base_path; const char *path; struct dispatch_fn *dispatch; struct messaging_rec *pending; @@ -94,13 +95,9 @@ static void ping_message(struct messaging_context *msg, void *private, /* return the path to a messaging socket */ -static char *messaging_path(TALLOC_CTX *mem_ctx, uint32_t server_id) +static char *messaging_path(struct messaging_context *msg, uint32_t server_id) { - char *name = talloc_asprintf(mem_ctx, "messaging/msg.%u", (unsigned)server_id); - char *ret; - ret = smbd_tmp_path(mem_ctx, name); - talloc_free(name); - return ret; + return talloc_asprintf(msg, "%s/msg.%u", msg->base_path, (unsigned)server_id); } /* @@ -308,7 +305,8 @@ NTSTATUS messaging_send(struct messaging_context *msg, uint32_t server, data->data, dlength); } - rec->path = messaging_path(rec, server); + rec->path = messaging_path(msg, server); + talloc_steal(rec, rec->path); status = try_send(rec); if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { @@ -369,7 +367,8 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id mkdir(path, 0700); talloc_free(path); - msg->path = messaging_path(msg, server_id); + msg->base_path = smbd_tmp_path(msg, "messaging"); + msg->path = messaging_path(msg, server_id); msg->server_id = server_id; msg->dispatch = NULL; msg->pending = NULL; -- cgit