diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-06-10 17:02:09 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:23:14 -0500 |
commit | de565785f5e1f097bd75f57331425c4185185f80 (patch) | |
tree | af24bb44388f9ffa2077435cc3fea134557c186b /source3/lib/util.c | |
parent | b05c7b97830f6029c264fc44831c2f5eae4f0c83 (diff) | |
download | samba-de565785f5e1f097bd75f57331425c4185185f80.tar.gz samba-de565785f5e1f097bd75f57331425c4185185f80.tar.bz2 samba-de565785f5e1f097bd75f57331425c4185185f80.zip |
r23410: Merge the core of the cluster code.
I'm 100% certain I've forgotten to merge something, but the main code
should be in. It's mainly in dbwrap_ctdb.c, ctdbd_conn.c and
messages_ctdbd.c.
There should be no changes to the non-cluster case, it does survive make
test on my laptop.
It survives some very basic tests with ctdbd enables, I did not do the
full test suite for clusters yet.
Phew...
Volker
(This used to be commit 15553d6327a3aecdd2b0b94a3656d04bf4106323)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r-- | source3/lib/util.c | 81 |
1 files changed, 70 insertions, 11 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 36396d9f83..3d72eb5d29 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1532,20 +1532,24 @@ BOOL process_exists(const struct server_id pid) return True; } - if (!procid_is_local(&pid)) { - /* This *SEVERELY* needs fixing. */ - return True; + if (procid_is_local(&pid)) { + return (kill(pid.pid,0) == 0 || errno != ESRCH); } - /* Doing kill with a non-positive pid causes messages to be - * sent to places we don't want. */ - SMB_ASSERT(pid.pid > 0); - return(kill(pid.pid,0) == 0 || errno != ESRCH); +#ifdef CLUSTER_SUPPORT + return ctdbd_process_exists(messaging_ctdbd_connection(), pid.vnn, + pid.pid); +#else + return False; +#endif } BOOL process_exists_by_pid(pid_t pid) { - return process_exists(pid_to_procid(pid)); + /* Doing kill with a non-positive pid causes messages to be + * sent to places we don't want. */ + SMB_ASSERT(pid > 0); + return(kill(pid,0) == 0 || errno != ESRCH); } /******************************************************************* @@ -3065,10 +3069,26 @@ pid_t procid_to_pid(const struct server_id *proc) return proc->pid; } +static uint32 my_vnn = NONCLUSTER_VNN; + +void set_my_vnn(uint32 vnn) +{ + DEBUG(10, ("vnn pid %d = %u\n", (int)sys_getpid(), (unsigned int)vnn)); + my_vnn = vnn; +} + +uint32 get_my_vnn(void) +{ + return my_vnn; +} + struct server_id pid_to_procid(pid_t pid) { struct server_id result; result.pid = pid; +#ifdef CLUSTER_SUPPORT + result.vnn = my_vnn; +#endif return result; } @@ -3084,7 +3104,13 @@ struct server_id server_id_self(void) BOOL procid_equal(const struct server_id *p1, const struct server_id *p2) { - return (p1->pid == p2->pid); + if (p1->pid != p2->pid) + return False; +#ifdef CLUSTER_SUPPORT + if (p1->vnn != p2->vnn) + return False; +#endif + return True; } BOOL cluster_id_equal(const struct server_id *id1, @@ -3095,18 +3121,47 @@ BOOL cluster_id_equal(const struct server_id *id1, BOOL procid_is_me(const struct server_id *pid) { - return (pid->pid == sys_getpid()); + if (pid->pid != sys_getpid()) + return False; +#ifdef CLUSTER_SUPPORT + if (pid->vnn != my_vnn) + return False; +#endif + return True; } struct server_id interpret_pid(const char *pid_string) { +#ifdef CLUSTER_SUPPORT + unsigned int vnn, pid; + struct server_id result; + if (sscanf(pid_string, "%u:%u", &vnn, &pid) == 2) { + result.vnn = vnn; + result.pid = pid; + } + else { + result.vnn = NONCLUSTER_VNN; + result.pid = -1; + } + return result; +#else return pid_to_procid(atoi(pid_string)); +#endif } char *procid_str_static(const struct server_id *pid) { static fstring str; - fstr_sprintf(str, "%d", pid->pid); +#ifdef CLUSTER_SUPPORT + if (pid->vnn == NONCLUSTER_VNN) { + fstr_sprintf(str, "%d", (int)pid->pid); + } + else { + fstr_sprintf(str, "%u:%d", (unsigned)pid->vnn, (int)pid->pid); + } +#else + fstr_sprintf(str, "%d", (int)pid->pid); +#endif return str; } @@ -3122,7 +3177,11 @@ BOOL procid_valid(const struct server_id *pid) BOOL procid_is_local(const struct server_id *pid) { +#ifdef CLUSTER_SUPPORT + return pid->vnn == my_vnn; +#else return True; +#endif } int this_is_smp(void) |