[Spread-cvs] commit: r623 - in branches/spread_4_2_debug: daemon examples

jschultz at spread.org jschultz at spread.org
Mon Nov 18 12:18:16 EST 2013


Author: jschultz
Date: 2013-11-18 12:18:16 -0500 (Mon, 18 Nov 2013)
New Revision: 623

Modified:
   branches/spread_4_2_debug/daemon/membership.c
   branches/spread_4_2_debug/daemon/network.c
   branches/spread_4_2_debug/daemon/protocol.c
   branches/spread_4_2_debug/daemon/spread.c
   branches/spread_4_2_debug/daemon/spread_params.h
   branches/spread_4_2_debug/examples/flooder.c
Log:
Cleanup of code before merge into trunk


Modified: branches/spread_4_2_debug/daemon/membership.c
===================================================================
--- branches/spread_4_2_debug/daemon/membership.c	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/daemon/membership.c	2013-11-18 17:18:16 UTC (rev 623)
@@ -665,36 +665,34 @@
     switch( State )
     {
 	case OP:
-	    
-	        if( Conf_leader( &Membership ) == My.id ) { Alarm( MEMB, "Handle_form1 in OP (leader swallow)\n");
-		} else { Alarm( MEMB, "Handle_form1 in OP\n"); Fill_form1( scat ); }
-		break;
+	        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 ); }
+	        break;
 
 	case SEG:
-	    Alarm( MEMB, "Handle_form1 in SEG (swallow)\n");
+	        Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in SEG (swallow)\n");
 		/* swallow this token */
 		break;
 
 	case REPRESENTED:
-	    Alarm( MEMB, "Handle_form1 in REPRESENTED\n");
+	        Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in REPRESENTED\n");
 		Fill_form1( scat );
 		break;
 
 	case GATHER:
-	    Alarm( MEMB, "Handle_form1 in GATHER\n");
+	        Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in GATHER\n");
 		Fill_form1( scat );
 		break;
 
 	case FORM:
-	    Alarm( MEMB, "Handle_form1 in FORM (swallow)\n");
+	        Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in FORM (swallow)\n");
 		/* swallow this token */
 		break;
 
 	case EVS:
-	    Alarm( MEMB, "Handle_form1 in EVS (swallow)\n");
+	        Alarmp( SPLOG_INFO, MEMB, "Handle_form1 in EVS (swallow)\n");
 		/* swallow this token */
 		break;
-
     }
 }
 
@@ -708,7 +706,7 @@
 		break;
 
 	case SEG:
-		Alarm( MEMB, "Handle_form2 in SEG (swalow)\n");
+		Alarm( MEMB, "Handle_form2 in SEG (swallow)\n");
 		/* swallow this token */
 		break;
 
@@ -832,7 +830,8 @@
 	    }
 	    break;
     }
-    Alarm( MEMB, "Memb_token_loss: ############### I lost my token, state is %d\n\n", State);
+
+    Alarmp( SPLOG_WARNING, MEMB, "Memb_token_loss: ############### I lost my token, state is %d\n\n", State);
     Shift_to_seg();
 
     Token_alive = 0;
@@ -847,6 +846,7 @@
 
     for( i=0; i < Conf_num_segments( Cn ); i++ )
 	Membership.segments[i].num_procs = 0;
+
     Conf_append_id_to_seg(&Membership.segments[My.seg_index], My.id);
 }
 
@@ -1364,7 +1364,7 @@
 	rg_info->aru		= Aru;
 	rg_info->highest_seq	= Highest_seq;
 
-	Alarm(MEMB, "Create_form1: putting Aru = %d and Highest_Seq = %d on rg_info form1 token\n", Aru, Highest_seq);
+	/*Alarmp(SPLOG_INFO, MEMB, "Create_form1: putting Aru = %d and Highest_Seq = %d on rg_info form1 token\n", Aru, Highest_seq);*/
 
 	/* update holes */
 	rg_info->num_holes	= 0;
@@ -1473,8 +1473,8 @@
         int             num_to_copy;
         members_info    valid_members;
 
-	if ( ( Alarm_get_types() & MEMB ) != 0 ) {
-	        Memb_print_form_token(scat);
+	if ( Alarm_get_priority() >= SPLOG_INFO && ( Alarm_get_types() & MEMB ) != 0 ) {
+	        Memb_print_form_token( scat );
 	}
 
 	num_bytes  = 0;
@@ -1652,7 +1652,7 @@
 	new_rg_info->aru	 = Aru;
 	new_rg_info->highest_seq = Highest_seq;
 
-	Alarm(MEMB, "Fill_form1: Putting Aru = %d and Highest_seq = %d on new_rg_info of form1 token\n", Aru, Highest_seq);
+	/*Alarmp(SPLOG_INFO, MEMB, "Fill_form1: Putting Aru = %d and Highest_seq = %d on new_rg_info of form1 token\n", Aru, Highest_seq);*/
 
 	if( my_rg_info == NULL )
 	{
@@ -1725,12 +1725,14 @@
 
 	    if( my_rg_info->aru         > Aru ) {
 		new_rg_info->aru 	= my_rg_info->aru;
-		Alarm(MEMB, "my_rg_info->aru (%d) > Aru (%d) -> setting new_rg_info->aru to my_rg_info\n", my_rg_info->aru, Aru);
+		/*Alarmp( SPLOG_INFO, MEMB, "my_rg_info->aru (%d) > Aru (%d) -> setting new_rg_info->aru to my_rg_info\n", 
+		  my_rg_info->aru, Aru );*/
 	    }
 
 	    if( my_rg_info->highest_seq > Highest_seq ) {
 		new_rg_info->highest_seq= my_rg_info->highest_seq;
-		Alarm(MEMB, "my_rg_info->highest_seq (%d) > Highest_seq (%d) -> setting new_rg_info->highest_seq to my_rg_info\n", my_rg_info->highest_seq, Highest_seq);
+		/*Alarmp( SPLOG_INFO, MEMB, "my_rg_info->highest_seq (%d) > Highest_seq (%d) -> setting new_rg_info->highest_seq to my_rg_info\n", 
+		  my_rg_info->highest_seq, Highest_seq );*/
 	    }
 
 	    for( i=0; i < my_rg_info->num_holes; i++ )
@@ -1739,7 +1741,7 @@
 		if( ! Packets[pack_entry].exist )
 		{
 			*new_holes_procs_ptr	= *my_holes_procs_ptr;
-			Alarm( MEMB, "INSERT HOLE 3 IS %d My_aru is %d, Highest_seq is %d\n", *new_holes_procs_ptr,My_aru, Highest_seq);
+			Alarmp( SPLOG_INFO, MEMB, "INSERT HOLE 3 IS %d, My_aru is %d, Highest_seq is %d\n", *new_holes_procs_ptr, My_aru, Highest_seq );
 			new_holes_procs_ptr++;
 			num_bytes	+= sizeof(int32);
 			new_rg_info->num_holes++;
@@ -1873,8 +1875,8 @@
 	int		i;
         int32           memb_time = 0;
 
-	if ( ( Alarm_get_types() & MEMB ) != 0 ) {
-	        Memb_print_form_token(scat);
+	if ( Alarm_get_priority() >= SPLOG_INFO && ( Alarm_get_types() & MEMB ) != 0 ) {
+	        Memb_print_form_token( scat );
 	}
 	
 	num_bytes  = 0;
@@ -1969,7 +1971,8 @@
                       *num_rings, num_bytes, Membership_id.proc_id, Membership_id.time); 
         }
 
-	Alarm(MEMB, "Read_form2: updating Highest_seq %d -> %d; Aru %d -> %d\n", Highest_seq, my_rg_info->highest_seq, Aru, my_rg_info->aru);
+	/*Alarmp( SPLOG_INFO, MEMB, "Read_form2: updating Highest_seq %d -> %d; Aru %d -> %d\n", 
+	  Highest_seq, my_rg_info->highest_seq, Aru, my_rg_info->aru );*/
 
 	Highest_seq = my_rg_info->highest_seq;
 	Aru	    = my_rg_info->aru;
@@ -2212,7 +2215,8 @@
 	int	pack_entry;
 	int	i;
 
-	Alarm(MEMB, "Backoff_membership entered: Last_discarded = %d; Highest_seq = %d; Aru = %d; My_aru = %d\n", Last_discarded, Highest_seq, Aru, My_aru);
+	/*Alarmp( SPLOG_INFO, MEMB, "Backoff_membership entered: Last_discarded = %d; Highest_seq = %d; Aru = %d; My_aru = %d\n", 
+	  Last_discarded, Highest_seq, Aru, My_aru );*/
 
 	pack_entry=-1;
 	for( i=Last_discarded+1; i <= Highest_seq; i++ )
@@ -2220,7 +2224,7 @@
 		/* clear dummy messages */
 		pack_entry = i & PACKET_MASK;
 		if( Packets[pack_entry].exist == 3 ) {
-			Alarm(MEMB, "Backoff_membership: reverting dummy hole to true hole for packet %d\n", pack_entry);
+		        Alarmp( SPLOG_INFO, MEMB, "Backoff_membership: reverting dummy hole to true hole for packet %d\n", pack_entry );
 			Packets[pack_entry].exist = 0;
 		}
 	}
@@ -2236,7 +2240,8 @@
 		My_aru++;
 	}
 
-	Alarm(MEMB, "Backoff_membership leaving: Last_discarded = %d; Highest_seq = %d; Aru = %d; My_aru = %d\n", Last_discarded, Highest_seq, Aru, My_aru);
+	/*Alarmp( SPLOG_INFO, MEMB, "Backoff_membership leaving: Last_discarded = %d; Highest_seq = %d; Aru = %d; My_aru = %d\n", 
+	  Last_discarded, Highest_seq, Aru, My_aru );*/
 }
 
 void	Memb_commit()

Modified: branches/spread_4_2_debug/daemon/network.c
===================================================================
--- branches/spread_4_2_debug/daemon/network.c	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/daemon/network.c	2013-11-18 17:18:16 UTC (rev 623)
@@ -643,11 +643,11 @@
         token_ptr->conf_hash = Cn->hash_code;
 	token_ptr->transmiter_id = My.id;
 
-	Alarm(PROTOCOL, 
-	      "Net_send_token: type = 0x%08X; transmitter_id = 0x%08X; seq = %d; proc_id = 0x%08X\n"
-	      "\taru = %d; aru_last_id = 0x%08X; Token_address = 0x%08X\n", 
-	      token_ptr->type, token_ptr->transmiter_id, token_ptr->seq, token_ptr->proc_id, 
-	      token_ptr->aru, token_ptr->aru_last_id, Token_address);
+	Alarmp( SPLOG_INFO, NETWORK, 
+		"Net_send_token: type = 0x%08X; transmitter_id = 0x%08X; seq = %d; proc_id = 0x%08X\n"
+		"\taru = %d; aru_last_id = 0x%08X; Token_address = 0x%08X\n", 
+		token_ptr->type, token_ptr->transmiter_id, token_ptr->seq, token_ptr->proc_id, 
+		token_ptr->aru, token_ptr->aru_last_id, Token_address );
 
         if ( token_ptr->rtr_len > (MAX_PACKET_SIZE - sizeof(token_header) ) )
         {

Modified: branches/spread_4_2_debug/daemon/protocol.c
===================================================================
--- branches/spread_4_2_debug/daemon/protocol.c	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/daemon/protocol.c	2013-11-18 17:18:16 UTC (rev 623)
@@ -457,30 +457,27 @@
 	r2 = get_rand() % (r1+3 );
 	if ( r2 == 0 ) return; */
 
-        Alarm( PROTOCOL, 
-	       "Prot_handle_token: ENTERED: received token: type = 0x%08X; transmitter = 0x%08X; seq = %d; proc_id = 0x%08X;\n"
-	       "\taru = %d; aru_last_id = 0x%08X;\n", 
-	       Token->type, Token->transmiter_id, Token->seq, Token->proc_id, Token->aru, Token->aru_last_id );
-
 	/* check if it is a regular token */
 	if( Is_form( Token->type ) )
 	{
-                Alarm(PROTOCOL, "Prot_handle_token: it is a Form Token.\n");
+	        Alarmp( SPLOG_INFO, PROTOCOL, "Prot_handle_token: it is a Form Token.\n" );
                 Memb_handle_token( &New_token );
 		goto END;
 	}
 
 	/* The Veto property for tokens - swallow this token */
 	if( ! Memb_token_alive() ) {
-                Alarm(PROTOCOL, "Prot_handle_token: Veto Property. Memb not alive.\n");
+	        Alarmp( SPLOG_INFO, PROTOCOL, "Prot_handle_token: Veto Property. Memb not alive.\n" );
 		goto END;
         }
 
+        Alarmp( SPLOG_INFO, PROTOCOL, 
+	       "Prot_handle_token: type = 0x%08X; transmitter = 0x%08X; seq = %d; proc_id = 0x%08X; aru = %d; aru_last_id = 0x%08X;\n", 
+	       Token->type, Token->transmiter_id, Token->seq, Token->proc_id, Token->aru, Token->aru_last_id );
+
 	if( ret != sizeof(token_header) + Token->rtr_len )
 	{
-		Alarm( PRINT, 
-		    "Prot_handle_token: recv token len is %d, should be %d\n",
-		    ret,sizeof(token_header) + Token->rtr_len );
+	        Alarmp( SPLOG_WARNING, PROTOCOL, "Prot_handle_token: recv token len is %d, should be %d\n", ret, sizeof(token_header) + Token->rtr_len );
 		goto END;
 	}
 
@@ -490,7 +487,7 @@
         /* Deal with wrapping seq values (2^32) by triggering a membership by dropping the token */
         if( (Memb_state() != EVS ) && (Token->seq > MAX_WRAP_SEQUENCE_VALUE ) )
         {
-            Alarm( PRINT, "Prot_handle_token: Token Sequence number (%ld) approaching 2^31 so trigger membership to reset it.\n", Token->seq);
+	    Alarmp( SPLOG_WARNING, PROTOCOL, "Prot_handle_token: seq (%ld) about to rollover; trigger membership to reset it.\n", Token->seq );
             /* return swallows token and will break ring and trigger membership */
             goto END;
         }
@@ -499,16 +496,16 @@
 	{
 		if( Get_arq(Token->type) != Get_arq(Last_token->type) )
 		{
-		    Alarm( PROTOCOL, 
-			"Prot_handle_token: leader swallowing token %d %d %d\n", 
-			 Get_arq(Token->type),Get_retrans(Token->type),Get_arq(Last_token->type) );
+		    Alarmp( SPLOG_INFO, PROTOCOL, 
+			"Prot_handle_token: leader swallowing token; type = %d; retrans = %d; arq = %d\n", 
+			 Get_arq(Token->type), Get_retrans(Token->type), Get_arq(Last_token->type) );
 		    /* received double token - swallow it */
 		    goto END; 
 
 		} else if (Memb_state() == OP && Just_Installed) {
-		  Just_Installed  = FALSE;
-		  Last_token->aru = 0;      /* wipe out EVS aru on last token due to transitioning from EVS -> OP */
-		  /* NOTE: we do this now rather than just when we installed to allow proper token retransmissions */
+		    Just_Installed  = FALSE;
+		    Last_token->aru = 0;      /* wipe out EVS aru on last token due to transitioning from EVS -> OP */
+		    /* NOTE: we do this now rather than just when we installed to allow proper token retransmissions */
 		}
 
 	}else{
@@ -619,7 +616,7 @@
 	/* Calculating Token->aru and Set_aru */
 	if( ( Token->aru == Set_aru    ) ||
             ( Token->aru_last_id == My.id ) ||
-	    ( Token->aru == Token->seq && Memb_state() != EVS ) )
+	    ( Token->aru == Token->seq && Memb_state() != EVS ) )  /* NOTE: Token->seq is meaningless in EVS */
 	{
 		Token->aru = My_aru;
                 Token->aru_last_id = My.id;
@@ -723,7 +720,7 @@
 	GlobalStatus.token_rounds = Token_rounds;
 
  END:
-	Alarm( PROTOCOL, "Prot_handle_token: LEAVING!\n");
+	/*Alarmp( SPLOG_INFO, PROTOCOL, "Prot_handle_token: LEAVING!\n" )*/;
 }
 
 /* Provide boolean result of whether the membership system needs to initiate a configuration reload
@@ -881,13 +878,13 @@
                                     ret = Net_ucast ( ring_rtr_ptr->proc_id, &Send_pack );
 				    GlobalStatus.u_retrans++;
 
-                                    Alarm( PROTOCOL, "Answer_retrans: retransmit %d to proc %d\n", *req_seq, ring_rtr_ptr->proc_id );
+                                    Alarmp( SPLOG_INFO, PROTOCOL, "Answer_retrans: retransmit %d to proc 0x%08X\n", *req_seq, ring_rtr_ptr->proc_id );
 
                                 }else if( ring_rtr_ptr->seg_index != -1 ) {
                                     ret = Net_scast ( ring_rtr_ptr->seg_index, &Send_pack );
 				    GlobalStatus.s_retrans++;
 
-                                    Alarm( PROTOCOL, "Answer_retrans: retransmit %d to seg %d\n", *req_seq, ring_rtr_ptr->seg_index );
+                                    Alarmp( SPLOG_INFO, PROTOCOL, "Answer_retrans: retransmit %d to seg 0x%08X\n", *req_seq, ring_rtr_ptr->seg_index );
 
                                 }else{
 #if 1
@@ -897,7 +894,7 @@
 #endif
 				    if( ret > 0 ) GlobalStatus.b_retrans++;
 
-                                    Alarm( PROTOCOL, "Answer_retrans: retransmit %d to all\n", *req_seq);
+                                    Alarmp( SPLOG_INFO, PROTOCOL, "Answer_retrans: retransmit %d to all\n", *req_seq);
                                 }
 				if( ret > 0 )
 				{
@@ -920,7 +917,7 @@
                     old_ptr += bytes_to_copy;
                     new_ptr += bytes_to_copy;
 
-                    Alarm( PROTOCOL, "Prot_handle_token: Coping foreign rtr\n");
+                    Alarmp( SPLOG_INFO, PROTOCOL, "Prot_handle_token: Coping foreign rtr\n");
                 }
             }
         }
@@ -1304,7 +1301,7 @@
         }
 
 	/* set variables for next membership */
-        if ( Conf_debug_initial_sequence() ) {
+        if ( Conf_debug_initial_sequence() ) {  /* TODO: get rid of this debug stuff */
             Highest_seq 	 = INITIAL_SEQUENCE_NEAR_WRAP;
             Highest_fifo_seq     = INITIAL_SEQUENCE_NEAR_WRAP;
             My_aru	    	 = INITIAL_SEQUENCE_NEAR_WRAP;
@@ -1322,7 +1319,7 @@
             Last_delivered	 = 0;
         }
 
-	Alarm(MEMB, "Discard_packets: Updated Aru to %d for next membership\n", Aru);
+	Alarmp( SPLOG_INFO, MEMB, "Discard_packets: Updated Aru to %d for next membership\n", Aru );
 
 	GlobalStatus.my_aru	 = My_aru;
 	Token_counter 	= 0;

Modified: branches/spread_4_2_debug/daemon/spread.c
===================================================================
--- branches/spread_4_2_debug/daemon/spread.c	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/daemon/spread.c	2013-11-18 17:18:16 UTC (rev 623)
@@ -32,10 +32,8 @@
  *
  */
 
-
-
-
 #include <string.h>
+
 #include "arch.h"
 #include "spread_params.h"
 #include "session.h"
@@ -45,20 +43,19 @@
 #include "log.h"
 #include "spu_alarm.h"
 
+#include "stdutil/stdutil.h"
+
 #ifndef ARCH_PC_WIN95
-#include <grp.h>
-#include <pwd.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#  include <grp.h>
+#  include <pwd.h>
+#  include <unistd.h>
+#  include <sys/types.h>
+#  include <sys/stat.h>
 #endif
 
 #ifdef	ARCH_PC_WIN95
-
-#include	<winsock.h>
-
+#  include	<winsock.h>
 WSADATA		WSAData;
-
 #endif	/* ARCH_PC_WIN95 */
 
 static	char		*My_name;
@@ -166,7 +163,7 @@
 	{
 	  sp_time t = E_get_time();
 
-	  set_rand((int) (t.sec + t.usec));
+	  set_rand( (int) (t.sec + t.usec) ^ (int) stdhcode_oaat( &My.id, sizeof(My.id) ) );
 	}
 
 #ifndef	ARCH_PC_WIN95

Modified: branches/spread_4_2_debug/daemon/spread_params.h
===================================================================
--- branches/spread_4_2_debug/daemon/spread_params.h	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/daemon/spread_params.h	2013-11-18 17:18:16 UTC (rev 623)
@@ -71,7 +71,7 @@
 #define		MAX_PACKETS_IN_STRUCT 	8192
 #define		PACKET_MASK		0x00001fff
 
-#define		MAX_SEQ_GAP		160	/* used in flow control to limit difference between highest_seq and aru */
+#define		MAX_SEQ_GAP		1600	/* used in flow control to limit difference between highest_seq and aru */
 
 #define		MAX_EVS_ROUNDS		500 	/* used in EVS state to limit total # of rounds to complete EVS */
 

Modified: branches/spread_4_2_debug/examples/flooder.c
===================================================================
--- branches/spread_4_2_debug/examples/flooder.c	2013-11-18 15:49:18 UTC (rev 622)
+++ branches/spread_4_2_debug/examples/flooder.c	2013-11-18 17:18:16 UTC (rev 623)
@@ -176,10 +176,10 @@
 		{
                     if (Num_members) 
                     {
-                        ret = SP_multicast( Mbox, AGREED_MESS, "flooder", 0, Num_bytes, mess );
+                        ret = SP_multicast( Mbox, FIFO_MESS, "flooder", 0, Num_bytes, mess );
                         Send_Counter++;
                     } else {
-                        ret = SP_multicast( Mbox, AGREED_MESS, "flooder", 0, Num_bytes, mess );
+                        ret = SP_multicast( Mbox, RELIABLE_MESS, "flooder", 0, Num_bytes, mess );
                     }
 		    if( ret != Num_bytes ) 
 		    {




More information about the Spread-cvs mailing list