[Spread-cvs] commit: r858 - branches/spread_5/daemon
jschultz at spread.org
jschultz at spread.org
Tue Oct 18 11:49:52 EDT 2016
Author: jschultz
Date: 2016-10-18 11:49:50 -0400 (Tue, 18 Oct 2016)
New Revision: 858
Modified:
branches/spread_5/daemon/configuration.c
branches/spread_5/daemon/configuration.h
branches/spread_5/daemon/membership.c
branches/spread_5/daemon/protocol.c
Log:
Work on membership.c primarily
Modified: branches/spread_5/daemon/configuration.c
===================================================================
--- branches/spread_5/daemon/configuration.c 2016-08-22 15:26:37 UTC (rev 857)
+++ branches/spread_5/daemon/configuration.c 2016-10-18 15:49:50 UTC (rev 858)
@@ -557,6 +557,22 @@
return( -1 );
}
+const char *Conf_name_by_id( int32u id )
+{
+ return Conf_name_by_in_conf( Config, id );
+}
+
+const char *Conf_name_by_id_in_conf( configuration *config, int32u id )
+{
+ const char *ret = "unknown_proc";
+ proc *p = NULL;
+
+ if ( Conf_proc_ref_by_id_in_conf( config, id, &p ) >= 0 )
+ ret = p->name;
+
+ return ret;
+}
+
int Conf_id_in_seg( segment *seg, int32u id )
{
int j;
Modified: branches/spread_5/daemon/configuration.h
===================================================================
--- branches/spread_5/daemon/configuration.h 2016-08-22 15:26:37 UTC (rev 857)
+++ branches/spread_5/daemon/configuration.h 2016-10-18 15:49:50 UTC (rev 858)
@@ -117,6 +117,8 @@
int Conf_proc_ref_by_id_in_conf( configuration *config, int32u id, proc **p );
int Conf_proc_by_name_in_conf( configuration *config, char *name, proc *p );
int Conf_proc_ref_by_name_in_conf( configuration *config, char *name, proc **p );
+const char *Conf_name_by_id( int32u id );
+const char *Conf_name_by_id_in_conf( configuration *config, int32u id );
int Conf_id_in_seg( segment *seg, int32u id );
int Conf_id_in_conf( configuration *config, int32u id );
int Conf_num_procs( configuration *config );
Modified: branches/spread_5/daemon/membership.c
===================================================================
--- branches/spread_5/daemon/membership.c 2016-08-22 15:26:37 UTC (rev 857)
+++ branches/spread_5/daemon/membership.c 2016-10-18 15:49:50 UTC (rev 858)
@@ -142,6 +142,38 @@
static void Flip_reps( reps_info *reps_ptr );
static void Flip_rings( char *buf );
+static const char *State_str(void)
+{
+ const char *ret = "UNKNOWN";
+
+ if (Token_alive)
+ {
+ switch (State)
+ {
+ case OP: ret = "OP/Alive"; break;
+ case SEG: ret = "SEG/Alive"; break;
+ case REPRESENTED: ret = "REPRESENTED/Alive"; break;
+ case GATHER: ret = "GATHER/Alive"; break;
+ case FORM: ret = "FORM/Alive"; break; /* NOTE: shouldn't happen */
+ case EVS: ret = "EVS/Alive"; break;
+ }
+ }
+ else
+ {
+ switch (State)
+ {
+ case OP: ret = "OP/Dead"; break; /* NOTE: shouldn't happen */
+ case SEG: ret = "SEG/Dead"; break;
+ case REPRESENTED: ret = "REPRESENTED/Dead"; break;
+ case GATHER: ret = "GATHER/Dead"; break;
+ case FORM: ret = "FORM/Dead"; break;
+ case EVS: ret = "EVS/Dead"; break; /* NOTE: shouldn't happen */
+ }
+ }
+
+ return ret;
+}
+
void Memb_init( void )
{
packet_header *pack_ptr;
@@ -288,98 +320,89 @@
void Memb_handle_message( sys_scatter *scat )
{
- packet_header *pack_ptr;
+ packet_header *pack_ptr = (packet_header *)scat->elements[0].buf;
- pack_ptr = (packet_header *)scat->elements[0].buf;
-
if ( Is_alive( pack_ptr->type ) )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_handle_message: handling alive message\n");
Memb_handle_alive( scat );
- }
+
else if ( Is_join( pack_ptr->type ) )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_handle_message: handling join message from %d.%d.%d.%d, State is %d\n", IP(pack_ptr->proc_id), State );
Memb_handle_join( scat );
- }
+
else if ( Is_refer( pack_ptr->type ) )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_handle_message: handling refer message from %d.%d.%d.%d, State is %d\n", IP(pack_ptr->proc_id), State );
Memb_handle_refer( scat );
- }
+
else if ( Is_regular( pack_ptr->type ) )
- {
- /*Alarmp( SPLOG_INFO, NONE, "Memb_handle_message: handling foreign message from %d.%d.%d.%d, State is %d\n", IP(pack_ptr->proc_id), State );*/
Memb_handle_foreign( scat );
- }
+
else
- Alarmp( SPLOG_PRINT, PROTOCOL, "Memb_handle_message: unknown message type 0x%x (ignoring)\n", pack_ptr->type );
+ Alarmp( SPLOG_WARNING, PROTOCOL | MEMB, "Memb_handle_message: unexpected message type 0x%x (ignoring); transmiter = '%s'; proc = '%s'\n",
+ pack_ptr->type, Conf_name_by_id( pack_ptr->transmiter_id ), Conf_name_by_id( pack_ptr->proc_id ) );
}
void Memb_handle_token( sys_scatter *scat )
{
- token_header *token_ptr;
+ token_header *token_ptr = (token_header *)scat->elements[0].buf;
- token_ptr = (token_header *)scat->elements[0].buf;
-
if( Is_form1( token_ptr->type ) )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_handle_token: handling form1 token\n");
Memb_handle_form1( scat );
- }
+
else if( Is_form2( token_ptr->type ) )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_handle_token: handling form2 token\n");
Memb_handle_form2( scat );
- }
+
else
- Alarmp( SPLOG_PRINT, PROTOCOL, "Memb_handle_token: unknown token type 0x%x (ignoring)\n", token_ptr->type );
+ Alarmp( SPLOG_WARNING, PROTOCOL | MEMB, "Memb_handle_token: unexpected token type 0x%x (ignoring); transmiter = '%s'; proc = '%s'\n",
+ pack_ptr->type, Conf_name_by_id( pack_ptr->transmiter_id ), Conf_name_by_id( pack_ptr->proc_id ) );
}
+/* NOTE 10/16: Much of the below seems overly aggressive and assumes
+ * no delayed / reordered packets. For example, assuming my ring is
+ * dead if I get an alive or join message from someone in my ring. If
+ * my ring is actually dead, then I will timeout soon too.
+ *
+ * Is there any reason why, in theory, we couldn't work on building a
+ * new ring (even with existing members of our ring) while we assume
+ * the old one is still alive? We already do this with daemons who
+ * aren't in our current ring.
+*/
+
static void Memb_handle_alive( sys_scatter *scat )
{
- packet_header *pack_ptr;
+ packet_header *pack_ptr = (packet_header *)scat->elements[0].buf;
- pack_ptr = (packet_header *)scat->elements[0].buf;
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_alive from '%s', State is %s\n", Conf_name_by_id( pack_ptr->proc_id ), State_str() );
switch( State )
{
case OP:
- Alarmp( SPLOG_INFO, MEMB, "Handle_alive in OP\n");
if( Conf_id_in_conf( &Membership, pack_ptr->proc_id ) != -1 )
{
/* sender belongs to my ring - my token is lost */
- Memb_token_loss();
- /* update my F_members list */
+ Memb_token_loss();
Insert_member( &F_members, pack_ptr->proc_id );
}
break;
case SEG:
- Alarmp( SPLOG_INFO, MEMB, "Handle_alive in SEG\n");
- /* update my F_members list */
Insert_member( &F_members, pack_ptr->proc_id );
-
break;
case REPRESENTED:
- Alarmp( SPLOG_INFO, MEMB, "Handle_alive in REPRESENTED\n");
E_queue( Shift_to_seg_event, 0, NULL, Rep_timeout );
-
break;
case GATHER:
- Alarmp( SPLOG_INFO, MEMB, "Handle_alive in GATHER\n");
/*
* If I am a seg representative - take this guy
* If I am a ring leader: if this guy in my ring - lost token
* otherwise ignore.
*/
- if( ! Token_alive ) Insert_member( &F_members, pack_ptr->proc_id );
- else if( Conf_id_in_conf( &Membership, pack_ptr->proc_id ) != -1 ){
+ if( ! Token_alive )
+ Insert_member( &F_members, pack_ptr->proc_id );
+
+ else if( Conf_id_in_conf( &Membership, pack_ptr->proc_id ) != -1 )
+ {
/* sender belongs to my ring - my token is lost */
Memb_token_loss();
- /* update my F_members list */
Insert_member( &F_members, pack_ptr->proc_id );
}
break;
@@ -402,7 +425,6 @@
if( Conf_id_in_conf( &Future_membership, pack_ptr->proc_id ) != -1 )
{
Memb_token_loss();
- /* update my F_members list */
Insert_member( &F_members, pack_ptr->proc_id );
}
break;
@@ -411,8 +433,8 @@
static void Memb_handle_join( sys_scatter *scat )
{
- packet_header *pack_ptr;
- members_info *members_ptr;
+ packet_header *pack_ptr = (packet_header *) scat->elements[0].buf;
+ members_info *members_ptr = (members_info *) scat->elements[1].buf;
reps_info *reps_ptr;
packet_header refer_pack;
sys_scatter send_scat;
@@ -421,22 +443,23 @@
int ret;
int dummy;
- pack_ptr = (packet_header *) scat->elements[0].buf;
- members_ptr = (members_info *) scat->elements[1].buf;
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_join from '%s', State is %s\n", Conf_name_by_id( pack_ptr->proc_id ), State_str() );
- if( !Same_endian( pack_ptr->type ) ) Flip_members( members_ptr );
+ if( !Same_endian( pack_ptr->type ) )
+ Flip_members( members_ptr );
- i = 2*sizeof(int16) + (members_ptr->num_members)*sizeof(int32);
- reps_ptr = (reps_info *)&scat->elements[1].buf[i];
+ i = 2 * sizeof(int16) + members_ptr->num_members * sizeof(int32);
+ reps_ptr = (reps_info *) &scat->elements[1].buf[i];
- if( !Same_endian( pack_ptr->type ) ) Flip_reps( reps_ptr );
+ if( !Same_endian( pack_ptr->type ) )
+ Flip_reps( reps_ptr );
switch( State )
{
case OP:
/* if sender belongs to my ring then my token is lost (except for single segment confs)
otherwise if I am a ring leader shift_to_gather */
- Alarmp( SPLOG_INFO, MEMB, "Handle_join in OP\n");
+
if( Conf_id_in_conf( &Membership, pack_ptr->proc_id ) == -1 )
{
if( Conf_leader( &Membership ) == My.id )
@@ -446,7 +469,9 @@
F_members.num_members = 0;
F_members.num_pending = 0;
Shift_to_gather();
- }else{
+ }
+ else
+ {
/* if !from my_seg OR seg_leader - answer ref */
if( reps_ptr->reps[0].seg_index != My.seg_index ||
Conf_seg_leader( &Membership, My.seg_index) == My.id )
@@ -462,7 +487,9 @@
Net_ucast( pack_ptr->proc_id, &send_scat );
}
}
- }else{
+ }
+ else
+ {
/* sender belongs to my ring - my token is lost */
/* If only one segment exists, then token is not lost, but rather
* a JOIN probe for merged segments was received. This can be
@@ -506,7 +533,9 @@
for( i=0; i < members_ptr->num_members; i++ )
if( members_ptr->members[i] == My.id ) break;
Scast_alive( 1 );
- }else{
+ }
+ else
+ {
/* if My_seg_rep is determined - send it to this guy */
/* My_seg_rep can be undetermined if it did not issue a join yet */
if( My_seg_rep != -1 )
@@ -539,8 +568,6 @@
break;
case FORM:
- /* Ignore */
-
break;
case EVS:
@@ -551,7 +578,6 @@
if( Conf_id_in_conf( &Future_membership, pack_ptr->proc_id ) != -1 )
{
Memb_token_loss();
- /* update my F_members list */
Insert_member( &F_members, pack_ptr->proc_id );
}
break;
@@ -560,29 +586,25 @@
static void Memb_handle_refer( sys_scatter *scat )
{
- packet_header *pack_ptr;
+ packet_header *pack_ptr = (packet_header *) scat->elements[0].buf;
proc p;
rep_info temp_rep;
int ret;
- pack_ptr = (packet_header *) scat->elements[0].buf;
-
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_refer from '%s', State is %s\n", Conf_name_by_id( pack_ptr->proc_id ), State_str() );
+
switch( State )
{
case OP:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in OP\n");
break;
case SEG:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in SEG\n");
break;
case REPRESENTED:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in REPRESENTED\n");
break;
case GATHER:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in GATHER\n");
ret = Conf_proc_by_id( pack_ptr->memb_id.proc_id, &p );
if( ret < 0 )
{
@@ -597,11 +619,9 @@
break;
case FORM:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in FORM\n");
break;
case EVS:
- Alarmp( SPLOG_INFO, MEMB, "Handle_refer in EVS\n");
break;
}
@@ -609,16 +629,15 @@
static void Memb_handle_foreign( sys_scatter *scat )
{
- packet_header *pack_ptr;
+ packet_header *pack_ptr = (packet_header *) scat->elements[0].buf;
proc p;
int ret;
- pack_ptr = (packet_header *) scat->elements[0].buf;
-
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_foreign from '%s', State is %s\n", Conf_name_by_id( pack_ptr->proc_id ), State_str() );
+
switch( State )
{
case OP:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in OP\n");
ret = Conf_proc_by_id( pack_ptr->proc_id, &p );
if( ret < 0 )
{
@@ -629,8 +648,9 @@
if( Conf_leader( &Membership ) == My.id )
{
Memb_lookup_new_members();
- }else if( Conf_seg_leader( &Membership, My.seg_index ) == My.id &&
- (!Foreign_found) ){
+ }
+ else if( Conf_seg_leader( &Membership, My.seg_index ) == My.id && !Foreign_found )
+ {
/*
* Seg leader : sending one foreign message
* to Conf leader
@@ -650,23 +670,18 @@
break;
case SEG:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in SEG\n");
break;
case REPRESENTED:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in REPRESENTED\n");
break;
case GATHER:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in GATHER\n");
break;
case FORM:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in FORM\n");
break;
case EVS:
- Alarmp( SPLOG_INFO, MEMB, "Handle_foreign in EVS\n");
/*
* This may happen when multiple old memberships merge
* and a message is retransmitted using bcast or scast.
@@ -679,72 +694,61 @@
static void Memb_handle_form1( sys_scatter *scat )
{
+ token_header *form_token = (token_header *) scat->elements[0].buf;
+
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_form1 from '%s', State is %s\n", Conf_name_by_id( form_token->proc_id ), State_str() );
+
switch( State )
{
case OP:
- if( Conf_leader( &Membership ) == My.id ) { Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in OP (leader swallow)\n");
- } else { Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in OP\n"); Fill_form1( scat ); }
+ if( Conf_leader( &Membership ) != My.id )
+ Fill_form1( scat );
break;
case SEG:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in SEG (swallow)\n");
- /* swallow this token */
break;
case REPRESENTED:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in REPRESENTED\n");
Fill_form1( scat );
break;
case GATHER:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in GATHER\n");
Fill_form1( scat );
break;
case FORM:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in FORM (swallow)\n");
- /* swallow this token */
break;
case EVS:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in EVS (swallow)\n");
- /* swallow this token */
break;
}
}
static void Memb_handle_form2( sys_scatter *scat )
{
+ token_header *form_token = (token_header *) scat->elements[0].buf;
+
+ Alarmp( SPLOG_INFO, MEMB, "Memb_handle_form2 from '%s', State is %s\n", Conf_name_by_id( form_token->proc_id ), State_str() );
+
switch( State )
{
case OP:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in OP (swallow)\n");
- /* swallow this token */
break;
case SEG:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in SEG (swallow)\n");
- /* swallow this token */
break;
case REPRESENTED:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in REPRESENTED (swallow)\n");
- /* swallow this token */
break;
case GATHER:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in GATHER (swallow)\n");
- /* swallow this token */
break;
case FORM:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in FORM\n");
Read_form2( scat );
break;
case EVS:
- Alarmp( SPLOG_INFO, MEMB, "Handle_form2 in EVS (swallow)\n");
- /* swallow this token */
break;
}
}
@@ -754,11 +758,11 @@
rep_info temp_rep;
int i;
+ Alarmp( SPLOG_WARNING, MEMB, "Memb_token_loss: ############### I lost my token, State is %s\n", State_str() );
+
switch( State )
{
case OP:
- /* my token is lost - shift to seg */
-
Potential_reps.num_reps = 0;
temp_rep.type = POTENTIAL_REP;
for( i=0; i < Conf_num_segments( Cn ); i++ )
@@ -777,14 +781,14 @@
case SEG:
case REPRESENTED:
- Alarmp( SPLOG_FATAL, EXIT, "Memb_token_loss: bug !!! state is %d\n",State);
+ Alarmp( SPLOG_FATAL, EXIT, "Memb_token_loss: Illegal state!\n" );
break;
case GATHER:
- /* I think I totally solved it */
/* If I am not a ring leader it is a bug */
+
if( ! Token_alive )
- Alarmp( SPLOG_FATAL, EXIT, "Memb_token_loss: bug !!! state is %d but !Token_alive\n",State);
+ Alarmp( SPLOG_FATAL, EXIT, "Memb_token_loss: Illegal state!\n" );
/* I am a ring leader and I lost my ring */
@@ -815,12 +819,10 @@
break;
case FORM:
- /* my token is lost - shift to seg */
/* potential already updated according to form token */
break;
case EVS:
- /* my token is lost - shift to seg */
/* clear empty messages */
Backoff_membership();
@@ -861,7 +863,6 @@
Conf_append_id_to_seg(&Membership.segments[My.seg_index], My.id);
- Alarmp( SPLOG_WARNING, MEMB, "Memb_token_loss: ############### I lost my token, state was %d\n\n", State);
Shift_to_seg();
}
@@ -872,16 +873,19 @@
static void Shift_to_op( void )
{
+ Alarmp( SPLOG_Info, MEMB, "Shift_to_op: State was %s\n", State_str() );
+
State = OP;
GlobalStatus.state = OP;
- if ( Prot_need_conf_reload() ) {
+ if ( Prot_need_conf_reload() )
E_queue( Prot_initiate_conf_reload, 0, NULL, Zero_timeout );
- }
}
static void Shift_to_seg( void )
{
+ Alarmp( SPLOG_Info, MEMB, "Shift_to_seg: State was %s\n", State_str() );
+
State = SEG;
GlobalStatus.state = SEG;
@@ -899,11 +903,15 @@
static void Gather_or_represented( void )
{
+ int32 smallest = Smallest_member( &F_members, &dummy );
int dummy;
+ Alarmp( SPLOG_Info, MEMB, "Gather_or_represented: State was %s; I am%s smallest.\n",
+ State_str(), ( smallest != My.id ? " NOT" : "" ) );
+
My_seg_rep = -1;
- if( Smallest_member( &F_members, &dummy ) == My.id )
+ if( smallest == My.id )
{
Shift_to_gather();
}else{
@@ -918,6 +926,8 @@
static void Shift_to_gather( void )
{
+ Alarmp( SPLOG_Info, MEMB, "Shift_to_gather: State was %s\n", State_str() );
+
State = GATHER;
GlobalStatus.state = GATHER;
@@ -936,6 +946,8 @@
static void Shift_to_represented( void )
{
+ Alarmp( SPLOG_Info, MEMB, "Shift_to_represented: State was %s\n", State_str() );
+
State = REPRESENTED;
GlobalStatus.state = REPRESENTED;
@@ -951,29 +963,38 @@
int i;
int dummy;
+ Alarmp( SPLOG_Info, MEMB, "Form_or_fail: State is %s\n", State_str() );
+
if( Smallest_rep( &F_reps, &dummy ) == My.id )
{
if( Token_alive && F_reps.num_reps == 1 )
{
/* clear everything and go back to op */
+ Alarmp( SPLOG_INFO, MEMB, "Form_or_fail: singleton, return to OP\n");
E_dequeue( Send_join_event, 0, NULL);
E_queue( Memb_lookup_new_members_event, 0, NULL, Lookup_timeout );
Shift_to_op();
- }else{
+ }
+ else
+ {
/* create and send form token */
Create_form1();
}
- }else{
+ }
+ else
+ {
if( Token_alive )
{
/* clear everything and go back to op */
- Alarmp( SPLOG_INFO, MEMB, "Form_or_fail:failed, return to OP\n");
+ Alarmp( SPLOG_INFO, MEMB, "Form_or_fail: failed, return to OP\n");
E_dequeue( Send_join_event, 0, NULL );
E_queue( Memb_lookup_new_members_event, 0, NULL, Lookup_timeout );
Shift_to_op();
- }else{
+ }
+ else
+ {
+ /* failed to gather again */
Alarmp( SPLOG_INFO, MEMB, "Form_or_fail: failed to gather\n");
- /* failed to gather again */
F_members.num_members = 1;
F_members.members[0] = My.id;
F_members.num_pending = 0;
@@ -1001,7 +1022,7 @@
{
packet_header *pack_ptr;
- Alarmp( SPLOG_INFO, MEMB, "Scast_alive: State is %d\n", State);
+ Alarmp( SPLOG_INFO, MEMB, "Scast_alive: State is %s\n", State_str() );
pack_ptr = (packet_header *)Send_pack.elements[0].buf;
pack_ptr->type = ALIVE_TYPE;
@@ -1026,7 +1047,7 @@
packet_header *pack_ptr;
int i;
- Alarmp( SPLOG_INFO, MEMB, "Send_join: State is %d\n", State);
+ Alarmp( SPLOG_INFO, MEMB, "Send_join: State is %s\n", State_str() );
pack_ptr = (packet_header *)Send_pack.elements[0].buf;
pack_ptr->type = JOIN_TYPE;
@@ -1063,11 +1084,13 @@
int num_missing;
int i,j;
+ Alarmp( SPLOG_INFO, MEMB, "Memb_lookup_new_member: State is %s\n", State_str() );
+
if( State != OP )
- {
- Alarmp( SPLOG_INFO, MEMB, "Memb_lookup_new_member: not in OP state, returning\n");
+ {
+ Alarmp( SPLOG_INFO, MEMB, "Memb_lookup_new_member: State is not OP, returning\n", State_str() );
return;
- }
+ }
Potential_reps.num_reps = 0;
@@ -1346,6 +1369,8 @@
int cur_num_members;
members_info valid_members;
+ Alarmp( SPLOG_INFO, MEMB, "Create_form1: State is %s\n", State_str() );
+
form_token.type = FORM1_TYPE;
form_token.proc_id = My.id;
form_token.memb_id.proc_id = My.id; /* NOTE: this memb_id is only used to ensure a FORM2 token matches up with the most recent FORM1 token we processed */
@@ -1544,7 +1569,7 @@
static void Fill_form1( sys_scatter *scat )
{
sys_scatter send_scat;
- token_header *form_token;
+ token_header *form_token = (token_header *)scat->elements[0].buf;
members_info *m_info;
reps_info *r_info;
ring_info *old_rg_info, *new_rg_info;
@@ -1556,7 +1581,7 @@
char rg_info_buf[sizeof(token_body)];
char *c_ptr;
char *rings_buf;
- int num_bytes;
+ int num_bytes = 0;
int bytes_to_copy;
rep_info temp_rep;
int i,j,k;
@@ -1564,15 +1589,20 @@
int num_to_copy;
members_info valid_members;
- if ( Alarm_get_priority() >= SPLOG_INFO && ( Alarm_get_types() & MEMB ) != 0 ) {
- Alarmp( SPLOG_INFO, MEMB, "Fill_form1: RECEIVED following token:\n" );
- Memb_print_form_token( scat );
+ if ( scat->elements[0].len != (int) sizeof(token_header) )
+ {
+ Alarmp( SPLOG_WARNING, MEMB, "Fill_form1: WARNING!!! Wrong size header %d (should be %d)\n", (int) scat->elements[0].len, (int) sizeof(token_header) );
+ return;
}
- num_bytes = 0;
-
- form_token = (token_header *)scat->elements[0].buf;
-
+ Alarmp( SPLOG_INFO, MEMB, "Fill_form1 from %s, State is %s\n", Conf_name_by_id( form_token->proc_id ), State_str() );
+
+ if ( Alarm_get_priority() >= SPLOG_DEBUG && ( Alarm_get_types() & MEMB ) != 0 )
+ {
+ Alarmp( SPLOG_DEBUG, MEMB, "Fill_form1 received following token:\n" );
+ Memb_print_form_token( scat );
+ }
+
m_info = (members_info *)scat->elements[1].buf;
num_bytes += sizeof(members_info);
@@ -1606,8 +1636,9 @@
m_info->num_members++;
m_info->num_pending--;
- }else if( State == GATHER ){
-
+ }
+ else if( State == GATHER )
+ {
/* validity check */
if( r_info->reps[r_info->rep_index].proc_id != My.id ||
( Token_alive && r_info->reps[r_info->rep_index].type == SEG_REP ) ||
@@ -1689,7 +1720,9 @@
r_info->rep_index++;
- }else Alarmp( SPLOG_FATAL, EXIT, "Fill_form1: invalid State: %d\n",State );
+ }
+ else
+ Alarmp( SPLOG_FATAL, EXIT, "Fill_form1: illegal State!\n" );
Form1_memb_id = form_token->memb_id;
@@ -2003,7 +2036,7 @@
static void Read_form2( sys_scatter *scat )
{
sys_scatter send_scat;
- token_header *form_token;
+ token_header *form_token = (token_header *)scat->elements[0].buf;
members_info *m_info;
membership_id *m_id_info;
ring_info *rg_info;
@@ -2013,7 +2046,7 @@
int pack_entry;
char *c_ptr;
char *rings_buf;
- int num_bytes;
+ int num_bytes = 0;
int bytes_to_skip;
int tot_len;
proc p;
@@ -2021,15 +2054,20 @@
int i;
int32 memb_time = 0;
- num_bytes = 0;
-
- form_token = (token_header *)scat->elements[0].buf;
-
- if ( scat->elements[0].len != (int) sizeof(token_header) ) {
+ if ( scat->elements[0].len != (int) sizeof(token_header) )
+ {
Alarmp( SPLOG_WARNING, MEMB, "Read_form2: WARNING!!! Wrong size header %d (should be %d)\n", (int) scat->elements[0].len, (int) sizeof(token_header) );
return;
}
+ Alarmp( SPLOG_INFO, MEMB, "Fill_form1 from %s, State is %s\n", Conf_name_by_id( form_token->proc_id ), State_str() );
+
+ if ( Alarm_get_priority() >= SPLOG_DEBUG && ( Alarm_get_types() & MEMB ) != 0 )
+ {
+ Alarmp( SPLOG_DEBUG, MEMB, "Read_form2 received following token:\n" );
+ Memb_print_form_token( scat );
+ }
+
tot_len = (int) scat->elements[1].len;
m_info = (members_info *)scat->elements[1].buf;
@@ -2308,8 +2346,8 @@
{
token_header *form_token;
members_info *m_info;
- reps_info *r_info = NULL; /* avoids compile warning -- gcc not detect initialization */
- membership_id *m_id_info = NULL; /* avoids compile warning -- gcc not detect initialization */
+ reps_info *r_info = NULL;
+ membership_id *m_id_info = NULL;
ring_info *rg_info;
int32 *num_rings;
int32 *commit_id;
@@ -2326,7 +2364,7 @@
m_info = (members_info *)&scat->elements[scat_index].buf[num_bytes];
num_bytes += sizeof(members_info);
- if (num_bytes == scat->elements[scat_index].len )
+ if ( num_bytes == scat->elements[scat_index].len )
{
num_bytes = 0;
scat_index++;
@@ -2337,17 +2375,20 @@
r_info = (reps_info *)&scat->elements[scat_index].buf[num_bytes];
num_bytes += sizeof(reps_info);
is_form1 = 1;
- } else if( Is_form2( form_token->type ) )
+ }
+ else if ( Is_form2( form_token->type ) )
{
m_id_info = (membership_id *)&scat->elements[scat_index].buf[num_bytes];
num_bytes += sizeof(membership_id);
is_form1 = 0;
- } else {
+ }
+ else
+ {
Alarmp( SPLOG_FATAL, EXIT, "Invalid token type received: 0x%x\n", form_token->type);
return;
}
- if (num_bytes == scat->elements[scat_index].len )
+ if ( num_bytes == scat->elements[scat_index].len )
{
num_bytes = 0;
scat_index++;
Modified: branches/spread_5/daemon/protocol.c
===================================================================
--- branches/spread_5/daemon/protocol.c 2016-08-22 15:26:37 UTC (rev 857)
+++ branches/spread_5/daemon/protocol.c 2016-10-18 15:49:50 UTC (rev 858)
@@ -323,7 +323,8 @@
/* delete random
r1 = ((-My.id)%17)+3;
r2 = get_rand() % (r1+3 );
- if ( r2 == 0 ) return; */
+ if ( r2 == 0 ) return;
+ */
if ( Is_membership( pack_ptr->type ) )
{
More information about the Spread-cvs
mailing list