From 16b1c77644217796f70a3a0bf1d95c245f9ee2d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 14:05:55 +1000 Subject: lib/util Bring procid_str() into lib/util as server_id_string() This is needed for OpenChange, which prints Samba struct server_id values in debug messages. Andrew Bartlett --- source3/Makefile.in | 2 +- source3/include/messages.h | 7 ------- source3/include/proto.h | 1 - source3/lib/g_lock.c | 10 +++++----- source3/lib/util.c | 18 +----------------- source3/locking/brlock.c | 2 +- source3/smbd/oplock.c | 10 +++++----- source3/smbd/sesssetup.c | 2 +- source3/utils/net_g_lock.c | 2 +- source3/utils/net_serverid.c | 12 ++++++------ source3/utils/smbcontrol.c | 6 +++--- 11 files changed, 24 insertions(+), 48 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 8165d2585c..a06c8c7c09 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -429,7 +429,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \ ../lib/util/tevent_werror.o \ ../lib/util/smb_threads.o ../lib/util/util_id.o \ ../lib/util/blocking.o ../lib/util/rfc1738.o \ - ../lib/util/select.o ../lib/util/util_pw.o + ../lib/util/select.o ../lib/util/util_pw.o ../lib/util/server_id.o CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \ ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \ diff --git a/source3/include/messages.h b/source3/include/messages.h index a78599055d..41d5bb19fd 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -48,13 +48,6 @@ #define FLAG_MSG_DBWRAP 0x0020 -/* - * Virtual Node Numbers are identifying a node within a cluster. Ctdbd sets - * this, we retrieve our vnn from it. - */ - -#define NONCLUSTER_VNN (0xFFFFFFFF) - /* * ctdb gives us 64-bit server ids for messaging_send. This is done to avoid * pid clashes and to be able to register for special messages like "all diff --git a/source3/include/proto.h b/source3/include/proto.h index c04dc94e20..42c62d2f6f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -594,7 +594,6 @@ bool cluster_id_equal(const struct server_id *id1, const struct server_id *id2); bool procid_is_me(const struct server_id *pid); struct server_id interpret_pid(const char *pid_string); -char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid); char *procid_str_static(const struct server_id *pid); bool procid_valid(const struct server_id *pid); bool procid_is_local(const struct server_id *pid); diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index f2452919af..006ee3698c 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -108,7 +108,7 @@ static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data, DEBUG(10, ("locks:\n")); for (i=0; ivnn == NONCLUSTER_VNN && pid->task_id == 0) { - return talloc_asprintf(mem_ctx, - "%llu", - (unsigned long long)pid->pid); - } - else { - return talloc_asprintf(mem_ctx, - "%u:%llu:%u", - (unsigned)pid->vnn, - (unsigned long long)pid->pid, - (unsigned)pid->task_id); - } -} - char *procid_str_static(const struct server_id *pid) { - return procid_str(talloc_tos(), pid); + return server_id_str(talloc_tos(), pid); } bool procid_valid(const struct server_id *pid) diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index 52e23ec003..ad0f9d5e52 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -51,7 +51,7 @@ static void print_lock_struct(unsigned int i, struct lock_struct *pls) i, (unsigned long long)pls->context.smblctx, (unsigned int)pls->context.tid, - procid_str(talloc_tos(), &pls->context.pid) )); + server_id_str(talloc_tos(), &pls->context.pid) )); DEBUG(10,("start = %.0f, size = %.0f, fnum = %d, %s %s\n", (double)pls->start, diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 8482a00f64..56481e9700 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -459,7 +459,7 @@ void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx message_to_share_mode_entry(&msg, (char *)data->data); DEBUG(10, ("Got oplock async level 2 break message from pid %s: " - "%s/%lu\n", procid_str(talloc_tos(), &src), + "%s/%lu\n", server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id), msg.share_file_id)); fsp = initial_break_processing(sconn, msg.id, msg.share_file_id); @@ -510,7 +510,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, message_to_share_mode_entry(&msg, (char *)data->data); DEBUG(10, ("Got oplock break message from pid %s: %s/%lu\n", - procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id), + server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id), msg.share_file_id)); fsp = initial_break_processing(sconn, msg.id, msg.share_file_id); @@ -617,7 +617,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx, file_id = (unsigned long)IVAL(data->data, 24); DEBUG(10, ("Got kernel oplock break message from pid %s: %s/%u\n", - procid_str(talloc_tos(), &src), file_id_string_tos(&id), + server_id_str(talloc_tos(), &src), file_id_string_tos(&id), (unsigned int)file_id)); fsp = initial_break_processing(sconn, id, file_id); @@ -704,7 +704,7 @@ static void process_oplock_break_response(struct messaging_context *msg_ctx, message_to_share_mode_entry(&msg, (char *)data->data); DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %llu\n", - procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id), + server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id), msg.share_file_id, (unsigned long long)msg.op_mid)); schedule_deferred_open_message_smb(msg.op_mid); @@ -732,7 +732,7 @@ static void process_open_retry_message(struct messaging_context *msg_ctx, message_to_share_mode_entry(&msg, (char *)data->data); DEBUG(10, ("Got open retry msg from pid %s: %s mid %llu\n", - procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id), + server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id), (unsigned long long)msg.op_mid)); schedule_deferred_open_message_smb(msg.op_mid); diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index ee305c478e..98bed880df 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -1223,7 +1223,7 @@ static int shutdown_other_smbds(const struct connections_key *key, struct shutdown_state *state = (struct shutdown_state *)private_data; DEBUG(10, ("shutdown_other_smbds: %s, %s\n", - procid_str(talloc_tos(), &crec->pid), crec->addr)); + server_id_str(talloc_tos(), &crec->pid), crec->addr)); if (!process_exists(crec->pid)) { DEBUG(10, ("process does not exist\n")); diff --git a/source3/utils/net_g_lock.c b/source3/utils/net_g_lock.c index 6ed5d1776a..bfb9a225ab 100644 --- a/source3/utils/net_g_lock.c +++ b/source3/utils/net_g_lock.c @@ -113,7 +113,7 @@ static int net_g_lock_dump_fn(struct server_id pid, enum g_lock_type lock_type, { char *pidstr; - pidstr = procid_str(talloc_tos(), &pid); + pidstr = server_id_str(talloc_tos(), &pid); d_printf("%s: %s (%s)\n", pidstr, (lock_type & 1) ? "WRITE" : "READ", (lock_type & G_LOCK_PENDING) ? "pending" : "holder"); diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c index 08a1a7f298..2c3320f40e 100644 --- a/source3/utils/net_serverid.c +++ b/source3/utils/net_serverid.c @@ -26,7 +26,7 @@ static int net_serverid_list_fn(const struct server_id *id, uint32_t msg_flags, void *priv) { - char *str = procid_str(talloc_tos(), id); + char *str = server_id_str(talloc_tos(), id); d_printf("%s %llu 0x%x\n", str, (unsigned long long)id->unique_id, (unsigned int)msg_flags); TALLOC_FREE(str); @@ -51,7 +51,7 @@ static int net_serverid_wipe_fn(struct db_record *rec, } status = rec->delete_rec(rec); if (!NT_STATUS_IS_OK(status)) { - char *str = procid_str(talloc_tos(), id); + char *str = server_id_str(talloc_tos(), id); DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n", str, nt_errstr(status))); TALLOC_FREE(str); @@ -75,13 +75,13 @@ static int net_serverid_wipedbs_conn( NTSTATUS status; DEBUG(10, ("Deleting connections.tdb record for pid %s\n", - procid_str(talloc_tos(), &key->pid))); + server_id_str(talloc_tos(), &key->pid))); status = rec->delete_rec(rec); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Could not delete connections.tdb record " "for pid %s: %s\n", - procid_str(talloc_tos(), &key->pid), + server_id_str(talloc_tos(), &key->pid), nt_errstr(status))); } } @@ -97,13 +97,13 @@ static int net_serverid_wipedbs_sessionid(struct db_record *rec, NTSTATUS status; DEBUG(10, ("Deleting sessionid.tdb record for pid %s\n", - procid_str(talloc_tos(), &session->pid))); + server_id_str(talloc_tos(), &session->pid))); status = rec->delete_rec(rec); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Could not delete session.tdb record " "for pid %s: %s\n", - procid_str(talloc_tos(), &session->pid), + server_id_str(talloc_tos(), &session->pid), nt_errstr(status))); } } diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 5bf5c5da7b..0a3a94a1df 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -119,7 +119,7 @@ static void print_pid_string_cb(struct messaging_context *msg, { char *pidstr; - pidstr = procid_str(talloc_tos(), &pid); + pidstr = server_id_str(talloc_tos(), &pid); printf("PID %s: %.*s", pidstr, (int)data->length, (const char *)data->data); TALLOC_FREE(pidstr); @@ -433,7 +433,7 @@ static void pong_cb(struct messaging_context *msg, struct server_id pid, DATA_BLOB *data) { - char *src_string = procid_str(NULL, &pid); + char *src_string = server_id_str(NULL, &pid); printf("PONG from pid %s\n", src_string); TALLOC_FREE(src_string); num_replies++; @@ -1143,7 +1143,7 @@ static void winbind_validate_cache_cb(struct messaging_context *msg, struct server_id pid, DATA_BLOB *data) { - char *src_string = procid_str(NULL, &pid); + char *src_string = server_id_str(NULL, &pid); printf("Winbindd cache is %svalid. (answer from pid %s)\n", (*(data->data) == 0 ? "" : "NOT "), src_string); TALLOC_FREE(src_string); -- cgit