[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Jun 17 01:28:04 MDT 2014


The branch, master has been updated
       via  35dd4de messaging3: Use server_id_str_buf
       via  f0e1a8e lib: Use server_id_str_buf in server_id_str
       via  7a3bda5 lib: Add server_id_str_buf
      from  0e9d4f6 build: fix the test and define for msg_accrights

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 35dd4de8868ec9b00f105a889899b0c5f2c97b1b
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 3 13:11:05 2014 +0000

    messaging3: Use server_id_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Jun 17 09:27:07 CEST 2014 on sn-devel-104

commit f0e1a8e1e2f67cc18099c3c56b99777bc7ef7b7f
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 3 13:04:56 2014 +0000

    lib: Use server_id_str_buf in server_id_str
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7a3bda54b01991ca45ba2157636f4e01dc425bcb
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 30 15:24:34 2014 +0000

    lib: Add server_id_str_buf
    
    This is usable in a DEBUG statement without talloc_tos()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/samba_util.h      |    4 +++
 lib/util/server_id.c       |   56 ++++++++++++++++++++++++++-----------------
 source3/lib/messages_dgm.c |    6 +++-
 3 files changed, 42 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 73cab66..251ddc2 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -984,6 +984,10 @@ char *data_path(TALLOC_CTX *mem_ctx, const char *name);
 const char *shlib_ext(void);
 
 struct server_id;
+
+struct server_id_buf { char buf[48]; }; /* probably a bit too large ... */
+char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
+
 bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
 char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id);
 struct server_id server_id_from_string(uint32_t local_vnn,
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index a06891d..e0a05a7 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -41,31 +41,43 @@ bool server_id_equal(const struct server_id *p1, const struct server_id *p2)
 	return true;
 }
 
-char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id)
+char *server_id_str_buf(struct server_id id, struct server_id_buf *dst)
 {
-	if (server_id_is_disconnected(id)) {
-		return talloc_strdup(mem_ctx, "disconnected");
-	} else if (id->vnn == NONCLUSTER_VNN && id->task_id == 0) {
-		return talloc_asprintf(mem_ctx,
-				       "%llu",
-				       (unsigned long long)id->pid);
-	} else if (id->vnn == NONCLUSTER_VNN) {
-		return talloc_asprintf(mem_ctx,
-				       "%llu.%u",
-				       (unsigned long long)id->pid,
-				       (unsigned)id->task_id);
-	} else if (id->task_id == 0) {
-		return talloc_asprintf(mem_ctx,
-				       "%u:%llu",
-				       (unsigned)id->vnn,
-				       (unsigned long long)id->pid);
+	if (server_id_is_disconnected(&id)) {
+		strlcpy(dst->buf, "disconnected", sizeof(dst->buf));
+	} else if ((id.vnn == NONCLUSTER_VNN) && (id.task_id == 0)) {
+		snprintf(dst->buf, sizeof(dst->buf), "%llu",
+			 (unsigned long long)id.pid);
+	} else if (id.vnn == NONCLUSTER_VNN) {
+		snprintf(dst->buf, sizeof(dst->buf), "%llu.%u",
+			 (unsigned long long)id.pid, (unsigned)id.task_id);
+	} else if (id.task_id == 0) {
+		snprintf(dst->buf, sizeof(dst->buf), "%u:%llu",
+			 (unsigned)id.vnn, (unsigned long long)id.pid);
 	} else {
-		return talloc_asprintf(mem_ctx,
-				       "%u:%llu.%u",
-				       (unsigned)id->vnn,
-				       (unsigned long long)id->pid,
-				       (unsigned)id->task_id);
+		snprintf(dst->buf, sizeof(dst->buf), "%u:%llu.%u",
+			 (unsigned)id.vnn,
+			 (unsigned long long)id.pid,
+			 (unsigned)id.task_id);
 	}
+	return dst->buf;
+}
+
+char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id)
+{
+	struct server_id_buf tmp;
+	char *result;
+
+	result = talloc_strdup(mem_ctx, server_id_str_buf(*id, &tmp));
+	if (result == NULL) {
+		return NULL;
+	}
+
+	/*
+	 * beautify the talloc_report output
+	 */
+	talloc_set_name_const(result, result);
+	return result;
 }
 
 struct server_id server_id_from_string(uint32_t local_vnn,
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index ba13fc9..c3ab0d1 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -301,6 +301,7 @@ static NTSTATUS messaging_dgm_send(struct server_id src,
 	struct messaging_dgm_hdr hdr;
 	struct iovec iov2[iovlen + 1];
 	ssize_t pathlen;
+	struct server_id_buf idbuf;
 	int ret;
 
 	fstr_sprintf(pid_str, "msg/%u", (unsigned)pid.pid);
@@ -318,7 +319,7 @@ static NTSTATUS messaging_dgm_send(struct server_id src,
 
 	DEBUG(10, ("%s: Sending message 0x%x to %s\n", __func__,
 		   (unsigned)hdr.msg_type,
-		   server_id_str(talloc_tos(), &pid)));
+		   server_id_str_buf(pid, &idbuf)));
 
 	iov2[0].iov_base = &hdr;
 	iov2[0].iov_len = sizeof(hdr);
@@ -344,6 +345,7 @@ static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
 		private_data, struct messaging_dgm_context);
 	struct messaging_dgm_hdr *hdr;
 	struct messaging_rec rec;
+	struct server_id_buf idbuf;
 
 	if (msg_len < sizeof(*hdr)) {
 		DEBUG(1, ("message too short: %u\n", (unsigned)msg_len));
@@ -364,7 +366,7 @@ static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
 
 	DEBUG(10, ("%s: Received message 0x%x len %u from %s\n", __func__,
 		   (unsigned)hdr->msg_type, (unsigned)rec.buf.length,
-		   server_id_str(talloc_tos(), &rec.src)));
+		   server_id_str_buf(rec.src, &idbuf)));
 
 	messaging_dispatch_rec(dgm_ctx->msg_ctx, &rec);
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list