diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-08 12:47:59 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-09 12:40:09 +0200 |
commit | d01dbd6c3fd9ca2595d65991b56db4400a35ece0 (patch) | |
tree | 446285beb823a73651e1afcf57d806147cd5de54 | |
parent | a772797a384a1142c5af95bd06c14a141dea38d7 (diff) | |
download | samba-d01dbd6c3fd9ca2595d65991b56db4400a35ece0.tar.gz samba-d01dbd6c3fd9ca2595d65991b56db4400a35ece0.tar.bz2 samba-d01dbd6c3fd9ca2595d65991b56db4400a35ece0.zip |
s3-lib Read and write the full struct server_id (except the unique_id)
This is in preperation for making this code the common, only reader
and writer of this structure.
Andrew Bartlett
-rw-r--r-- | source3/lib/util.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index a0b6d9f55d..ca30858914 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1966,41 +1966,40 @@ bool procid_is_me(const struct server_id *pid) struct server_id interpret_pid(const char *pid_string) { struct server_id result; - int pid; - unsigned int vnn; - if (sscanf(pid_string, "%u:%d", &vnn, &pid) == 2) { + unsigned long long pid; + unsigned int vnn, task_id = 0; + + ZERO_STRUCT(result); + + /* We accept either the 2 or 3 componet form for backwards compatability in the smbstatus command line tool */ + if (sscanf(pid_string, "%u:%llu:%u", &vnn, &pid, &task_id) >= 2) { result.vnn = vnn; result.pid = pid; - } - else if (sscanf(pid_string, "%d", &pid) == 1) { + result.task_id = task_id; + } else if (sscanf(pid_string, "%d", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; } else { result.vnn = NONCLUSTER_VNN; - result.pid = -1; - } - /* Assigning to result.pid may have overflowed - Map negative pid to -1: i.e. error */ - if (result.pid < 0) { - result.pid = -1; + result.pid = (uint64_t)-1; } - result.unique_id = 0; return result; } char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid) { - if (pid->vnn == NONCLUSTER_VNN) { + if (pid->vnn == NONCLUSTER_VNN && pid->task_id == 0) { return talloc_asprintf(mem_ctx, - "%d", - (int)pid->pid); + "%llu", + (unsigned long long)pid->pid); } else { return talloc_asprintf(mem_ctx, - "%u:%d", - (unsigned)pid->vnn, - (int)pid->pid); + "%u:%llu:%u", + (unsigned)pid->vnn, + (unsigned long long)pid->pid, + (unsigned)pid->task_id); } } @@ -2011,7 +2010,7 @@ char *procid_str_static(const struct server_id *pid) bool procid_valid(const struct server_id *pid) { - return (pid->pid != -1); + return (pid->pid != (uint64_t)-1); } bool procid_is_local(const struct server_id *pid) |