barrier.c | barrier.c | |||
---|---|---|---|---|
skipping to change at line 104 | skipping to change at line 104 | |||
if (barrier->got_nodes == ((barrier->expected_nodes != 0) | if (barrier->got_nodes == ((barrier->expected_nodes != 0) | |||
? barrier->expected_nodes : | ? barrier->expected_nodes : | |||
cluster_members)) { | cluster_members)) { | |||
struct cl_barriermsg bmsg; | struct cl_barriermsg bmsg; | |||
barrier->phase = 2; /* Wait for complete phase II */ | barrier->phase = 2; /* Wait for complete phase II */ | |||
bmsg.cmd = CLUSTER_MSG_BARRIER; | bmsg.cmd = CLUSTER_MSG_BARRIER; | |||
bmsg.subcmd = BARRIER_COMPLETE; | bmsg.subcmd = BARRIER_COMPLETE; | |||
strcpy(bmsg.name, barrier->name); | strncpy(bmsg.name, barrier->name, MAX_BARRIER_NAME_LEN - 1); | |||
log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending COMPLETE fo r %s\n", barrier->name); | log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending COMPLETE fo r %s\n", barrier->name); | |||
comms_send_message((char *) &bmsg, sizeof (bmsg), | comms_send_message((char *) &bmsg, sizeof (bmsg), | |||
0, 0, | 0, 0, | |||
0, | 0, | |||
MSG_TOTEM_SAFE); | MSG_TOTEM_SAFE); | |||
} | } | |||
} | } | |||
/* Do the stuff we need to do when the barrier has been reached */ | /* Do the stuff we need to do when the barrier has been reached */ | |||
skipping to change at line 163 | skipping to change at line 163 | |||
{ | { | |||
struct cl_barrier *barrier; | struct cl_barrier *barrier; | |||
/* Build a new struct and add it to the list */ | /* Build a new struct and add it to the list */ | |||
barrier = malloc(sizeof (struct cl_barrier)); | barrier = malloc(sizeof (struct cl_barrier)); | |||
if (barrier == NULL) { | if (barrier == NULL) { | |||
return NULL; | return NULL; | |||
} | } | |||
memset(barrier, 0, sizeof (*barrier)); | memset(barrier, 0, sizeof (*barrier)); | |||
strcpy(barrier->name, name); | strncpy(barrier->name, name, MAX_BARRIER_NAME_LEN - 1); | |||
barrier->flags = 0; | barrier->flags = 0; | |||
barrier->expected_nodes = nodes; | barrier->expected_nodes = nodes; | |||
barrier->got_nodes = 0; | barrier->got_nodes = 0; | |||
barrier->endreason = 0; | barrier->endreason = 0; | |||
barrier->state = BARRIER_STATE_INACTIVE; | barrier->state = BARRIER_STATE_INACTIVE; | |||
list_add(&barrier_list, &barrier->list); | list_add(&barrier_list, &barrier->list); | |||
return barrier; | return barrier; | |||
} | } | |||
/* Process BARRIER messages from other nodes */ | /* Process BARRIER messages from other nodes */ | |||
void process_barrier_msg(struct cl_barriermsg *msg, | void process_barrier_msg(struct cl_barriermsg *msg, | |||
struct cluster_node *node) | struct cluster_node *node) | |||
{ | { | |||
struct cl_barrier *barrier; | struct cl_barrier *barrier; | |||
barrier = find_barrier(msg->name); | ||||
/* Ignore other peoples' messages */ | /* Ignore other peoples' messages */ | |||
if (!we_are_a_cluster_member) | if (!we_are_a_cluster_member) | |||
return; | return; | |||
barrier = find_barrier(msg->name); | ||||
if (!barrier) | if (!barrier) | |||
return; | return; | |||
log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Got %d for %s, from node %s \n", msg->subcmd, msg->name, | log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Got %d for %s, from node %s \n", msg->subcmd, msg->name, | |||
node ? node->name : "unknown"); | node ? node->name : "unknown"); | |||
switch (msg->subcmd) { | switch (msg->subcmd) { | |||
case BARRIER_WAIT: | case BARRIER_WAIT: | |||
if (barrier->phase == 0) | if (barrier->phase == 0) | |||
barrier->phase = 1; | barrier->phase = 1; | |||
if (barrier->phase == 1) { | if (barrier->phase == 1) { | |||
barrier->got_nodes++; | barrier->got_nodes++; | |||
check_barrier_complete_phase1(barrier); | check_barrier_complete_phase1(barrier); | |||
} | } | |||
break; | break; | |||
case BARRIER_COMPLETE: | case BARRIER_COMPLETE: | |||
if (!barrier) | ||||
return; | ||||
/* Once we receive COMPLETE, we know that everyone has compl eted. | /* Once we receive COMPLETE, we know that everyone has compl eted. | |||
I love VS */ | I love VS */ | |||
barrier_complete_phase2(barrier, 0); | barrier_complete_phase2(barrier, 0); | |||
break; | break; | |||
} | } | |||
} | } | |||
/* Barrier API */ | /* Barrier API */ | |||
static int barrier_register(struct connection *con, char *name, unsigned in t flags, unsigned int nodes) | static int barrier_register(struct connection *con, char *name, unsigned in t flags, unsigned int nodes) | |||
{ | { | |||
skipping to change at line 260 | skipping to change at line 258 | |||
barrier->con = con; | barrier->con = con; | |||
return 0; | return 0; | |||
} | } | |||
static int barrier_setattr_enabled(struct cl_barrier *barrier, | static int barrier_setattr_enabled(struct cl_barrier *barrier, | |||
unsigned int attr, unsigned long arg) | unsigned int attr, unsigned long arg) | |||
{ | { | |||
int status; | int status; | |||
/* Can't disable a barrier */ | /* Can't disable a barrier */ | |||
if (!arg) { | if ((!barrier) || (!arg)) { | |||
return -EINVAL; | return -EINVAL; | |||
} | } | |||
/* We need to send WAIT now because the user may not | /* We need to send WAIT now because the user may not | |||
* actually call barrier_wait() */ | * actually call barrier_wait() */ | |||
if (!barrier->waitsent) { | if (!barrier->waitsent) { | |||
struct cl_barriermsg bmsg; | struct cl_barriermsg bmsg; | |||
/* Send it to the rest of the cluster */ | /* Send it to the rest of the cluster */ | |||
bmsg.cmd = CLUSTER_MSG_BARRIER; | bmsg.cmd = CLUSTER_MSG_BARRIER; | |||
bmsg.subcmd = BARRIER_WAIT; | bmsg.subcmd = BARRIER_WAIT; | |||
strcpy(bmsg.name, barrier->name); | strncpy(bmsg.name, barrier->name, MAX_BARRIER_NAME_LEN - 1); | |||
barrier->waitsent = 1; | barrier->waitsent = 1; | |||
barrier->phase = 1; | barrier->phase = 1; | |||
/* Start the timer if one was wanted */ | /* Start the timer if one was wanted */ | |||
if (barrier->timeout) { | if (barrier->timeout) { | |||
corosync->timer_add_duration((unsigned long long)bar rier->timeout*1000000000ULL, barrier, | corosync->timer_add_duration((unsigned long long)bar rier->timeout*1000000000ULL, barrier, | |||
barrier_timer_fn, &barrie r->timer); | barrier_timer_fn, &barrie r->timer); | |||
} | } | |||
log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending WAIT for %s \n", barrier->name); | log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending WAIT for %s \n", barrier->name); | |||
status = comms_send_message((char *)&bmsg, sizeof(bmsg), 0,0 , 0, MSG_TOTEM_SAFE); | status = comms_send_message((char *)&bmsg, sizeof(bmsg), 0,0 , 0, MSG_TOTEM_SAFE); | |||
if (status < 0) { | if (status < 0) { | |||
return status; | return status; | |||
} | } | |||
} | } | |||
if (barrier && barrier->state == BARRIER_STATE_COMPLETE) { | if (barrier->state == BARRIER_STATE_COMPLETE) { | |||
return barrier->endreason; | return barrier->endreason; | |||
} | } | |||
return 0; /* Nothing to propogate */ | return 0; /* Nothing to propogate */ | |||
} | } | |||
static int barrier_setattr(char *name, unsigned int attr, unsigned long arg ) | static int barrier_setattr(char *name, unsigned int attr, unsigned long arg ) | |||
{ | { | |||
struct cl_barrier *barrier; | struct cl_barrier *barrier; | |||
/* See if it already exists */ | /* See if it already exists */ | |||
End of changes. 8 change blocks. | ||||
9 lines changed or deleted | 7 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |