Remove this_ip from the source tree and replace with accessor functions.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1379 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2007-06-05 08:55:44 +00:00
parent 64fb1d1c18
commit 0a19a21f1b
18 changed files with 143 additions and 85 deletions

View File

@ -733,7 +733,7 @@ static int create_cluster_model (void)
return -1;
}
this_amf_node->nodeid = this_ip->nodeid;
this_amf_node->nodeid = totempg_my_nodeid_get();
return 0;
}
@ -754,7 +754,7 @@ static unsigned int calc_sync_master (
unsigned int *member_list, int member_list_entries)
{
int i;
unsigned int master = this_ip->nodeid; /* assume this node is master */
unsigned int master = totempg_my_nodeid_get(); /* assume this node is master */
for (i = 0; i < member_list_entries; i++) {
if (member_list[i] < master &&
@ -1156,7 +1156,7 @@ static void amf_sync_init (void)
break;
}
if (scsm.state == SYNCHRONIZING && scsm.sync_master == this_ip->nodeid) {
if (scsm.state == SYNCHRONIZING && scsm.sync_master == totempg_my_nodeid_get()) {
amf_msg_mcast (MESSAGE_REQ_EXEC_AMF_SYNC_START, NULL, 0);
assert (amf_cluster != NULL);
scsm.cluster = amf_cluster;
@ -1192,7 +1192,7 @@ static int amf_sync_process (void)
{
SYNCTRACE ("state %s", scsm_state_names[scsm.state]);
if (scsm.state != SYNCHRONIZING || scsm.sync_master != this_ip->nodeid) {
if (scsm.state != SYNCHRONIZING || scsm.sync_master != totempg_my_nodeid_get()) {
return 0;
}
@ -1273,7 +1273,7 @@ static void amf_sync_activate (void)
this_amf_node = get_this_node_obj ();
sync_state_set (NORMAL_OPERATION);
if (this_amf_node != NULL) {
this_amf_node->nodeid = this_ip->nodeid;
this_amf_node->nodeid = totempg_my_nodeid_get();
cluster_joined_nodes_start ();
} else {
log_printf (LOG_LEVEL_INFO,
@ -1388,7 +1388,7 @@ static void amf_confchg_fn (
}
break;
case SYNCHRONIZING: {
if (joined_list_entries > 0 && scsm.sync_master == this_ip->nodeid) {
if (joined_list_entries > 0 && scsm.sync_master == totempg_my_nodeid_get()) {
/* restart sync */
amf_msg_mcast (MESSAGE_REQ_EXEC_AMF_SYNC_START, NULL, 0);
}
@ -1400,7 +1400,7 @@ static void amf_confchg_fn (
scsm.sync_master =
calc_sync_master (member_list, member_list_entries);
if (scsm.sync_master == this_ip->nodeid) {
if (scsm.sync_master == totempg_my_nodeid_get()) {
/* restart sync */
SYNCTRACE ("I am (new) sync master");
amf_msg_mcast (MESSAGE_REQ_EXEC_AMF_SYNC_START, NULL, 0);
@ -1416,7 +1416,7 @@ static void amf_confchg_fn (
scsm.sync_master =
calc_sync_master (member_list, member_list_entries);
if (scsm.sync_master == this_ip->nodeid) {
if (scsm.sync_master == totempg_my_nodeid_get()) {
SYNCTRACE ("I am (new) sync master");
}
}
@ -1662,7 +1662,7 @@ static void message_handler_req_exec_amf_sync_start (
scsm.sync_master = nodeid;
break;
case PROBING_2:
if (this_ip->nodeid == nodeid) {
if (totempg_my_nodeid_get() == nodeid) {
scsm.sync_master = nodeid;
sync_state_set (CREATING_CLUSTER_MODEL);
if (create_cluster_model() == 0) {

View File

@ -299,7 +299,7 @@ static void message_handler_req_lib_cfg_ringstatusget (
res_lib_cfg_ringstatusget.header.error = SA_AIS_OK;
totempg_ifaces_get (
this_ip->nodeid,
totempg_my_nodeid_get(),
interfaces,
&status,
&iface_count);

View File

@ -3568,7 +3568,7 @@ static int ckpt_sync_process (void)
switch (my_sync_state) {
case SYNC_STATE_CHECKPOINT:
if (my_lowest_nodeid == this_ip->nodeid) {
if (my_lowest_nodeid == totempg_my_nodeid_get()) {
TRACE1 ("should transmit checkpoints because lowest member in old configuration.\n");
res = sync_checkpoints_iterate ();
@ -3588,7 +3588,7 @@ static int ckpt_sync_process (void)
case SYNC_STATE_REFCOUNT:
done_queueing = 1;
if (my_lowest_nodeid == this_ip->nodeid) {
if (my_lowest_nodeid == totempg_my_nodeid_get()) {
TRACE1 ("transmit refcounts because this processor is the lowest member in old configuration.\n");
res = sync_refcounts_iterate ();
}

View File

@ -264,24 +264,29 @@ struct req_exec_clm_nodejoin {
mar_clm_cluster_node_t cluster_node __attribute__((aligned(8)));
};
static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
static void my_cluster_node_load (void)
{
log_init ("CLM");
struct totem_ip_address interfaces[INTERFACE_MAX];
unsigned int iface_count;
char **status;
const char *iface_string;
memset (cluster_node_entries, 0,
sizeof (mar_clm_cluster_node_t) * PROCESSOR_COUNT_MAX);
totempg_ifaces_get (
totempg_my_nodeid_get (),
interfaces,
&status,
&iface_count);
iface_string = totemip_print (&interfaces[0]);
/*
* Build local cluster node data structure
*/
sprintf ((char *)my_cluster_node.node_address.value, "%s",
totemip_print (this_ip));
iface_string);
my_cluster_node.node_address.length =
strlen ((char *)my_cluster_node.node_address.value);
if (this_ip->family == AF_INET) {
if (totempg_my_family_get () == AF_INET) {
my_cluster_node.node_address.family = SA_CLM_AF_INET;
} else
if (this_ip->family == AF_INET6) {
if (totempg_my_family_get () == AF_INET6) {
my_cluster_node.node_address.family = SA_CLM_AF_INET6;
} else {
assert (0);
@ -291,8 +296,20 @@ static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
(char *)my_cluster_node.node_address.value);
my_cluster_node.node_name.length =
my_cluster_node.node_address.length;
my_cluster_node.node_id = this_ip->nodeid;
my_cluster_node.node_id = totempg_my_nodeid_get ();
my_cluster_node.member = 1;
memcpy (&cluster_node_entries[0], &my_cluster_node,
sizeof (mar_clm_cluster_node_t));
}
static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
{
log_init ("CLM");
memset (cluster_node_entries, 0,
sizeof (mar_clm_cluster_node_t) * PROCESSOR_COUNT_MAX);
{
#ifndef NANOSEC
#define NANOSEC 1000000000
@ -328,7 +345,6 @@ static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
#endif
}
memcpy (&cluster_node_entries[0], &my_cluster_node, sizeof (mar_clm_cluster_node_t));
cluster_node_count = 1;
main_clm_get_by_nodeid = clm_get_by_nodeid;
@ -534,20 +550,7 @@ static void clm_confchg_fn (
* Load the my_cluster_node data structure in case we are
* transitioning to network interface up or down
*/
sprintf ((char *)my_cluster_node.node_address.value, "%s", totemip_print (this_ip));
my_cluster_node.node_address.length = strlen ((char *)my_cluster_node.node_address.value);
if (this_ip->family == AF_INET) {
my_cluster_node.node_address.family = SA_CLM_AF_INET;
} else
if (this_ip->family == AF_INET6) {
my_cluster_node.node_address.family = SA_CLM_AF_INET6;
} else {
assert (0);
}
strcpy ((char *)my_cluster_node.node_name.value,
(char *)my_cluster_node.node_address.value);
my_cluster_node.node_name.length = my_cluster_node.node_address.length;
my_cluster_node.node_id = this_ip->nodeid;
my_cluster_node_load ();
}
/*

View File

@ -476,7 +476,7 @@ static int cpg_lib_exit_fn (void *conn)
if (gi) {
notify_info.pid = pi->pid;
notify_info.nodeid = this_ip->nodeid;
notify_info.nodeid = totempg_my_nodeid_get();
notify_info.reason = CONFCHG_CPG_REASON_PROCDOWN;
cpg_node_joinleave_send(gi, pi, MESSAGE_REQ_EXEC_CPG_PROCLEAVE, CONFCHG_CPG_REASON_PROCDOWN);
list_del(&pi->list);
@ -622,8 +622,8 @@ static void cpg_confchg_fn (
lowest_nodeid = member_list[i];
}
log_printf(LOG_LEVEL_DEBUG, "confchg, low nodeid=%d, us = %d\n", lowest_nodeid, this_ip->nodeid);
if (lowest_nodeid == this_ip->nodeid) {
log_printf(LOG_LEVEL_DEBUG, "confchg, low nodeid=%d, us = %d\n", lowest_nodeid, totempg_my_nodeid_get());
if (lowest_nodeid == totempg_my_nodeid_get()) {
req_exec_cpg_downlist.header.id = SERVICE_ID_MAKE(CPG_SERVICE, MESSAGE_REQ_EXEC_CPG_DOWNLIST);
req_exec_cpg_downlist.header.size = sizeof(struct req_exec_cpg_downlist);
@ -718,7 +718,7 @@ static void do_proc_join(
if (pi->pid == pid && pi->nodeid == nodeid) {
/* It could be a local join message */
if ((nodeid == this_ip->nodeid) &&
if ((nodeid == totempg_my_nodeid_get()) &&
(!pi->flags & PI_FLAG_MEMBER)) {
goto local_join;
} else {
@ -853,7 +853,7 @@ static void message_handler_req_exec_cpg_joinlist (
nodeid);
/* Ignore our own messages */
if (nodeid == this_ip->nodeid) {
if (nodeid == totempg_my_nodeid_get()) {
return;
}
@ -932,7 +932,7 @@ static int cpg_exec_send_joinlist(void)
gi = list_entry(iter, struct group_info, list);
for (iter2 = gi->members.next; iter2 != &gi->members; iter2 = iter2->next) {
struct process_info *pi = list_entry(iter2, struct process_info, list);
if (pi->pid && pi->nodeid == this_ip->nodeid) {
if (pi->pid && pi->nodeid == totempg_my_nodeid_get()) {
count++;
}
}
@ -959,7 +959,7 @@ static int cpg_exec_send_joinlist(void)
for (iter2 = gi->members.next; iter2 != &gi->members; iter2 = iter2->next) {
struct process_info *pi = list_entry(iter2, struct process_info, list);
if (pi->pid && pi->nodeid == this_ip->nodeid) {
if (pi->pid && pi->nodeid == totempg_my_nodeid_get()) {
memcpy(&jle->group_name, &gi->group_name, sizeof(mar_cpg_name_t));
jle->pid = pi->pid;
jle++;
@ -1018,7 +1018,7 @@ static void message_handler_req_lib_cpg_join (void *conn, void *message)
pi);
/* Add a node entry for us */
pi->nodeid = this_ip->nodeid;
pi->nodeid = totempg_my_nodeid_get();
pi->pid = req_lib_cpg_join->pid;
pi->group = gi;
list_add(&pi->list, &gi->members);

View File

@ -454,7 +454,7 @@ static void message_handler_req_evs_membership_get (void *conn, void *msg)
res_lib_evs_membership_get.header.size = sizeof (struct res_lib_evs_membership_get);
res_lib_evs_membership_get.header.id = MESSAGE_RES_EVS_MEMBERSHIP_GET;
res_lib_evs_membership_get.header.error = EVS_OK;
res_lib_evs_membership_get.local_nodeid = this_ip->nodeid;
res_lib_evs_membership_get.local_nodeid = totempg_my_nodeid_get ();
memcpy (&res_lib_evs_membership_get.member_list,
&res_evs_confchg_callback.member_list,
sizeof (res_lib_evs_membership_get.member_list));

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2002-2006 MontaVista Software, Inc.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
@ -102,8 +102,6 @@
static unsigned int g_gid_valid = 0;
static struct totem_ip_address *my_ip;
static totempg_groups_handle ipc_handle;
DECLARE_LIST_INIT (conn_info_list_head);
@ -993,7 +991,7 @@ int message_source_is_local(mar_message_source_t *source)
int ret = 0;
assert (source != NULL);
if (source->nodeid == my_ip->nodeid) {
if (source->nodeid == totempg_my_nodeid_get ()) {
ret = 1;
}
return ret;
@ -1005,7 +1003,7 @@ void message_source_set (
{
assert ((source != NULL) && (conn != NULL));
memset (source, 0, sizeof (mar_message_source_t));
source->nodeid = my_ip->nodeid;
source->nodeid = totempg_my_nodeid_get ();
source->conn = conn;
}
@ -1021,8 +1019,7 @@ static void ipc_confchg_fn (
void openais_ipc_init (
void (*serialize_lock_fn) (void),
void (*serialize_unlock_fn) (void),
unsigned int gid_valid,
struct totem_ip_address *my_ip_in)
unsigned int gid_valid)
{
int libais_server_fd;
struct sockaddr_un un_addr;
@ -1079,8 +1076,6 @@ void openais_ipc_init (
g_gid_valid = gid_valid;
my_ip = my_ip_in;
/*
* Reset internal state of flow control when
* configuration change occurs

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
@ -51,8 +51,7 @@ extern int openais_conn_send_response (void *conn, void *msg, int mlen);
extern void openais_ipc_init (
void (*serialize_lock_fn) (void),
void (*serialize_unlock_fn) (void),
unsigned int gid_valid,
struct totem_ip_address *non_loopback_ip);
unsigned int gid_valid);
extern int openais_ipc_timer_add (
void *conn,

View File

@ -1284,7 +1284,7 @@ error_exit:
req_exec_lck_resourceunlock->invocation;
openais_conn_send_response (
req_exec_lck_resourceunlock->source.conn,
openais_conn_partner_get(req_exec_lck_resourceunlock->source.conn),
&res_lib_lck_resourceunlockasync,
sizeof (struct res_lib_lck_resourceunlockasync));
openais_conn_send_response (

View File

@ -121,8 +121,6 @@ static void sigabrt_handler (int num)
raise (SIGABRT);
}
struct totem_ip_address *this_ip;
struct totem_ip_address this_non_loopback_ip;
#define LOCALHOST_IP inet_addr("127.0.0.1")
totempg_groups_handle openais_group_handle;
@ -201,10 +199,6 @@ static void confchg_fn (
memcpy (&aisexec_ring_id, ring_id, sizeof (struct memb_ring_id));
if (!totemip_localhost_check(this_ip)) {
totemip_copy(&this_non_loopback_ip, this_ip);
}
/*
* Call configuration change for all services
*/
@ -428,10 +422,6 @@ int main (int argc, char **argv)
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2006 Red Hat, Inc.\n");
memset(&this_non_loopback_ip, 0, sizeof(struct totem_ip_address));
totemip_localhost(AF_INET, &this_non_loopback_ip);
signal (SIGINT, sigintr_handler);
signal (SIGUSR2, sigusr2_handler);
signal (SIGSEGV, sigsegv_handler);
@ -586,8 +576,6 @@ int main (int argc, char **argv)
/*
* This must occur after totempg is initialized because "this_ip" must be set
*/
this_ip = &totem_config.interfaces[0].boundto;
res = openais_service_init_all (service_count, objdb);
if (res == -1) {
log_printf (LOG_LEVEL_ERROR, "Could not init services\n");
@ -615,8 +603,7 @@ int main (int argc, char **argv)
openais_ipc_init (
serialize_mutex_lock,
serialize_mutex_unlock,
gid_valid,
&this_non_loopback_ip);
gid_valid);
/*
* Start main processing loop

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2002-2006 MontaVista Software, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
@ -52,8 +53,6 @@
#define SIZEINB MESSAGE_SIZE_MAX
extern struct totem_ip_address *this_ip;
extern struct totempg_group openais_group;
extern totempg_groups_handle openais_group_handle;

View File

@ -1,9 +1,10 @@
/*
* Copyright (c) 2005 MontaVista Software, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
@ -191,6 +192,16 @@ int totemmrp_ifaces_get (
return (res);
}
int totemmrp_my_nodeid_get (void)
{
return (totemsrp_my_nodeid_get (totemsrp_handle_in));
}
int totemmrp_my_family_get (void)
{
return (totemsrp_my_family_get (totemsrp_handle_in));
}
extern int totemmrp_ring_reenable (void)
{
int res;

View File

@ -1,9 +1,10 @@
/*
* Copyright (c) 2005 MontaVista Software, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
@ -104,6 +105,10 @@ extern int totemmrp_ifaces_get (
char ***status,
unsigned int *iface_count);
extern int totemmrp_my_nodeid_get (void);
extern int totemmrp_my_family_get (void);
extern int totemmrp_ring_reenable (void);
#endif /* TOTEMMRP_H_DEFINED */

View File

@ -1,11 +1,12 @@
/*
* Copyright (c) 2003-2005 MontaVista Software, Inc.
* Copyright (c) 2005 OSDL.
* Copyright (c) 2006-2007 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
* Author: Steven Dake (sdake@redhat.com)
* Mark Haverkamp (markh@osdl.org)
*
* This software licensed under BSD license, the text of which follows:
@ -1252,3 +1253,12 @@ char *totempg_ifaces_print (unsigned int nodeid)
return (iface_string);
}
int totempg_my_nodeid_get (void)
{
return (totemmrp_my_nodeid_get());
}
int totempg_my_family_get (void)
{
return (totemmrp_my_family_get());
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2003-2005 MontaVista Software, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
@ -136,8 +137,12 @@ extern int totempg_ifaces_get (
char ***status,
unsigned int *iface_count);
extern int totempg_ring_reenable (void);
extern char *totempg_ifaces_print (unsigned int nodeid);
extern int totempg_my_nodeid_get (void);
extern int totempg_my_family_get (void);
extern int totempg_ring_reenable (void);
#endif /* TOTEMPG_H_DEFINED */

View File

@ -1,11 +1,11 @@
/*
* Copyright (c) 2003-2006 MontaVista Software, Inc.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
@ -889,6 +889,43 @@ error_exit:
return (res);
}
int totemsrp_my_nodeid_get (
totemsrp_handle handle)
{
struct totemsrp_instance *instance;
int res;
res = hdb_handle_get (&totemsrp_instance_database, handle,
(void *)&instance);
if (res != 0) {
return (0);
}
res = instance->totem_config->interfaces[0].boundto.nodeid;
hdb_handle_put (&totemsrp_instance_database, handle);
return (res);
}
int totemsrp_my_family_get (
totemsrp_handle handle)
{
struct totemsrp_instance *instance;
int res;
res = hdb_handle_get (&totemsrp_instance_database, handle,
(void *)&instance);
if (res != 0) {
return (0);
}
res = instance->totem_config->interfaces[0].boundto.family;
hdb_handle_put (&totemsrp_instance_database, handle);
return (res);
}
int totemsrp_ring_reenable (
totemsrp_handle handle)
{

View File

@ -1,9 +1,10 @@
/*
* Copyright (c) 2003-2005 MontaVista Software, Inc.
* Copyright (c) 2006-2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
@ -103,6 +104,12 @@ extern int totemsrp_ifaces_get (
char ***status,
unsigned int *iface_count);
extern int totemsrp_my_nodeid_get (
totemsrp_handle handle);
extern int totemsrp_my_family_get (
totemsrp_handle handle);
extern int totemsrp_ring_reenable (
totemsrp_handle handle);

View File

@ -458,7 +458,7 @@ static void ykd_confchg_fn (
memcpy (&ykd_ring_id, ring_id, sizeof (struct memb_ring_id));
if (first_run) {
ykd_state.last_primary.member_list[0] = this_ip->nodeid;
ykd_state.last_primary.member_list[0] = totempg_my_nodeid_get();
ykd_state.last_primary.member_list_entries = 1;
ykd_state.last_primary.session_id = 0;
first_run = 0;