commit: r265 - trunk/daemon

[email protected]
Newsgroups gmane.network.spread.cvs
Message-ID <[email protected]>
Author: jonathan
Date: 2005-08-16 13:45:55 -0400 (Tue, 16 Aug 2005)
New Revision: 265

Modified:
   trunk/daemon/config_parse.y
   trunk/daemon/configuration.c
   trunk/daemon/membership.c
   trunk/daemon/monitor.c
   trunk/daemon/net_types.h
   trunk/daemon/network.c
Log:
Fix bugs in hash checks that prevented some memberships from completing.
Allow monitor messages to always pass hash checks.


Modified: trunk/daemon/config_parse.y
===================================================================
--- trunk/daemon/config_parse.y	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/config_parse.y	2005-08-16 17:45:55 UTC (rev 265)
@@ -250,8 +250,8 @@
 
     if (curlen > strsize) {
         /* ran out of space in string -- should never happen. */
-        Alarmp( SPLOG_ERROR, CONF, "The segment string is too long! %d characters attemped is more then %d characters allowed", curlen, strsize);
-        Alarmp( SPLOG_ERROR, CONF, "The error occured on segment %d.%d.%d.%d. Successful string was: %s\n",
+        Alarmp( SPLOG_ERROR, CONF, "config_parse.y:convert_segment_to_string: The segment string is too long! %d characters attemped is more then %d characters allowed", curlen, strsize);
+        Alarmp( SPLOG_ERROR, CONF, "config_parse.y:convert_segment_to_string:The error occured on segment %d.%d.%d.%d. Successful string was: %s\n",
                 (seg->bcast_address & 0xff000000)>>24, 
                 (seg->bcast_address & 0xff0000)>>16, 
                 (seg->bcast_address & 0xff00)>>8, 
@@ -260,7 +260,7 @@
         return(-1);
     }
 
-    Alarmp( SPLOG_DEBUG, CONF, "The segment string is %d characters long:\n%s", curlen, segstr);
+    Alarmp( SPLOG_DEBUG, CONF, "config_parse.y:convert_segment_to_string:The segment string is %d characters long:\n%s", curlen, segstr);
     return(curlen);
 }
 
@@ -327,7 +327,7 @@
 			  Config->num_segments = segments;
 			  Config->num_total_procs = num_procs;
 			  Alarm(CONF, "Finished configuration file.\n");
-                          Alarmp( SPLOG_INFO, CONF, "The full segment string is %d characters long:\n%s", strlen(ConfStringRep), ConfStringRep);
+                          Alarmp( SPLOG_DEBUG, CONF, "config_parse.y:The full segment string is %d characters long:\n%s", strlen(ConfStringRep), ConfStringRep);
 			}
 
 

Modified: trunk/daemon/configuration.c
===================================================================
--- trunk/daemon/configuration.c	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/configuration.c	2005-08-16 17:45:55 UTC (rev 265)
@@ -377,7 +377,7 @@
          */
         Config->hash_code = conf_hash_string(ConfStringRep, ConfStringLen);
         Alarmp( SPLOG_DEBUG, CONF, "Full hash string is %d characters long:\n%s", ConfStringLen, ConfStringRep);
-        Alarmp( SPLOG_DEBUG, CONF, "Hash value for this configuration is: %u\n", Config->hash_code);
+        Alarmp( SPLOG_INFO, CONF, "Hash value for this configuration is: %u\n", Config->hash_code);
 
         /* Match my IP address to entry in configuration file */
 	if( my_name == NULL ){

Modified: trunk/daemon/membership.c
===================================================================
--- trunk/daemon/membership.c	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/membership.c	2005-08-16 17:45:55 UTC (rev 265)
@@ -257,19 +257,6 @@
 
 	pack_ptr = (packet_header *)scat->elements[0].buf;
 
-        /* First reject any message whose daemon has a different configuration */
-        if (pack_ptr->conf_hash != Cn->hash_code) {
-            Alarmp( SPLOG_WARNING, MEMB, "Memb_handle_message: Received message (pkthdr_len = %u) from host %d.%d.%d.%d with different spread configuration file (hash %u != local hash %u)\n", 
-                    scat->elements[0].len,
-                    IP1(pack_ptr->proc_id),
-                    IP2(pack_ptr->proc_id),
-                    IP3(pack_ptr->proc_id),
-                    IP4(pack_ptr->proc_id),
-                    pack_ptr->conf_hash, 
-                    Cn->hash_code);
-            return;
-        }
-
 	if( 	  Is_alive( pack_ptr->type ) )
 	{
 		Alarm( MEMB, "Memb_handle_message: handling alive message\n");
@@ -315,18 +302,6 @@
 
 	token_ptr = (token_header *)scat->elements[0].buf;
 
-        /* First reject any token whose daemon has a different configuration */
-        if (token_ptr->conf_hash != Cn->hash_code) {
-            Alarmp( SPLOG_WARNING, MEMB, "Memb_handle_token: Received token from host %d.%d.%d.%d with different spread configuration file (hash %u != local hash %u)\n", 
-                    IP1(token_ptr->proc_id),
-                    IP2(token_ptr->proc_id),
-                    IP3(token_ptr->proc_id),
-                    IP4(token_ptr->proc_id),
-                    token_ptr->conf_hash, 
-                    Cn->hash_code);
-            return;
-        }
-
 	if( 	  Is_form1( token_ptr->type ) )
 	{
 		Alarm( MEMB, "Memb_handle_token: handling form1 token\n");
@@ -987,7 +962,6 @@
 
 	pack_ptr = (packet_header *)Send_pack.elements[0].buf;
 	pack_ptr->type = ALIVE_TYPE;
-        pack_ptr->conf_hash = Cn->hash_code;
 	pack_ptr->data_len = 
 		2*sizeof(int16) + (F_members.num_members)*sizeof(int32);
 
@@ -1008,7 +982,6 @@
 
 	pack_ptr = (packet_header *)Send_pack.elements[0].buf;
 	pack_ptr->type = JOIN_TYPE;
-        pack_ptr->conf_hash = Cn->hash_code;
 	Send_pack.elements[1].buf = (char *)&F_members;
 	Send_pack.elements[1].len = 
 		2*sizeof(int16) + (F_members.num_members)*sizeof(int32);
@@ -1054,7 +1027,6 @@
 
 	pack_ptr = (packet_header *)Send_pack.elements[0].buf;
 	pack_ptr->type = JOIN_TYPE;
-        pack_ptr->conf_hash = Cn->hash_code;
 	Send_pack.elements[1].buf = (char *)&F_members;
 	Send_pack.elements[1].len = 
 		2*sizeof(int16) + (F_members.num_members)*sizeof(int32);
@@ -1318,7 +1290,6 @@
 	form_token.seq = Highest_seq+3333;
 	form_token.proc_id = My.id;
 	form_token.type = FORM1_TYPE;
-        form_token.conf_hash = Cn->hash_code;
 
 	/* if I am a ring leader - update my F_members */
 	if( F_reps.reps[0].type == RING_REP )
@@ -2121,6 +2092,7 @@
             snprintf(&form_name[0], 10, "FORM 2");
 
         Alarmp( SPLOG_PRINT, PRINT, "%s Token, sent by %u.%u.%u.%u. Seq: %d\n", form_name, IP1(form_token->transmiter_id), IP2(form_token->transmiter_id), IP3(form_token->transmiter_id), IP4(form_token->transmiter_id), form_token->seq);
+        Alarmp( SPLOG_PRINT, PRINT, "Configuration hash: %u (local hash %u)\n", form_token->conf_hash, Cn->hash_code);
         Alarmp( SPLOG_PRINT, PRINT, "ProcID: %u.%u.%u.%u\t ARU: %d, ARU LastID: %u.%u.%u.%u\n", IP1(form_token->proc_id), IP2(form_token->proc_id), IP3(form_token->proc_id), IP4(form_token->proc_id), form_token->aru, IP1(form_token->aru_last_id), IP2(form_token->aru_last_id), IP3(form_token->aru_last_id), IP4(form_token->aru_last_id) );
         Alarmp( SPLOG_PRINT, PRINT, "FlowControl: %hd\tRTR Len: %hd\n", form_token->flow_control, form_token->rtr_len);
         /* Print members list */

Modified: trunk/daemon/monitor.c
===================================================================
--- trunk/daemon/monitor.c	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/monitor.c	2005-08-16 17:45:55 UTC (rev 265)
@@ -85,8 +85,6 @@
 
 static	int		Status_vector[MAX_PROCS_RING];
 
-static	int		Status_vector[MAX_PROCS_RING];
-
 static	configuration	Cn;
 static  proc            My;
 static	int		My_port;
@@ -542,6 +540,7 @@
 
 	Pack.type    = PARTITION_TYPE;
 	Pack.type    = Set_endian( Pack.type );
+        Pack.conf_hash = MONITOR_HASH;
 	Pack.data_len= sizeof( Partition );;
 
 	Pack_scat.num_elements    = 2;
@@ -694,6 +693,7 @@
 
 	Pack.type    = FC_TYPE;
 	Pack.type    = Set_endian( Pack.type );
+        Pack.conf_hash = MONITOR_HASH;
 	Pack.data_len= sizeof( Fc_buf );;
 
 	Pack_scat.num_elements    = 2;
@@ -790,6 +790,7 @@
 
 	Pack.type    = STATUS_TYPE;
 	Pack.type    = Set_endian( Pack.type );
+        Pack.conf_hash = MONITOR_HASH;
 	Pack.data_len= 0;
 
 	Pack_scat.num_elements    = 1;
@@ -894,6 +895,7 @@
 	}
 	Pack.type    = PARTITION_TYPE;
 	Pack.type    = Set_endian( Pack.type );
+        Pack.conf_hash = MONITOR_HASH;
 	Pack.data_len= sizeof( Kill_partition );;
 
 	Pack_scat.num_elements    = 2;
@@ -1011,10 +1013,13 @@
 
 	Pack.type    = RELOAD_TYPE;
 	Pack.type    = Set_endian( Pack.type );
+        Pack.conf_hash = MONITOR_HASH;
 	Pack.data_len = 0;
 
 	Pack_scat.num_elements    = 1;
 
+        Alarm( PRINT, "Old configuration hash is: %u\n", Cn.hash_code);
+
 	Alarm( PRINT  , "Monitor: send conf reload command\n");
 	for( i=0; i < Cn.num_segments ; i++ )
 	{
@@ -1031,6 +1036,33 @@
 
         read_configuration();
 
+        for( i=0; i < Conf_num_procs( &Cn ); i++ )
+	{
+            Partition[i] = 0;
+            Work_partition[i] = 0;
+            Fc_buf[i] = 0;
+            Work_fc_buf[i] = 0;
+            Status_vector[i] = 0;
+	}
+        Mutex_lock( &Partition_mutex );
+        Partition_active = 0;
+        Mutex_unlock( &Partition_mutex );
+        
+#ifndef _REENTRANT
+        E_dequeue( Send_partition, 0, NULL );
+#endif
+
+        Mutex_lock( &Status_mutex );
+        Status_active = 0;
+        Mutex_unlock( &Status_mutex );
+
+#ifndef _REENTRANT
+	E_dequeue( Send_status_query, 0, NULL );
+#endif
+
+        Alarm( PRINT, "New configuration hash is: %u\n", Cn.hash_code);
+        Alarm( PRINT, "All Status, Partition, FC, etc commands are reset by configuration reload!\n");
+
 }
 
 static	void	Usage(int argc, char *argv[])

Modified: trunk/daemon/net_types.h
===================================================================
--- trunk/daemon/net_types.h	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/net_types.h	2005-08-16 17:45:55 UTC (rev 265)
@@ -104,6 +104,8 @@
 #define		Is_control( type )	( type &  CONTROL_TYPE    )
 
 
+#define MONITOR_HASH    1100    /* Conf_hash code for packets from spmonitor program */
+
 typedef	struct	dummy_packet_header {
 	int32		type;
 	int32		transmiter_id;

Modified: trunk/daemon/network.c
===================================================================
--- trunk/daemon/network.c	2005-08-10 02:07:49 UTC (rev 264)
+++ trunk/daemon/network.c	2005-08-16 17:45:55 UTC (rev 265)
@@ -249,6 +249,7 @@
 	pack_ptr = (packet_header *)scat->elements[0].buf;
 	pack_ptr->type  = Set_routed( pack_ptr->type );
 	pack_ptr->type  = Set_endian( pack_ptr->type );
+        pack_ptr->conf_hash = Cn->hash_code;
 	pack_ptr->transmiter_id = My.id;
 	for ( i=0; i< Num_send_needed; i++ )
 	{
@@ -318,6 +319,7 @@
                 pack_ptr = (packet_header *)scat->elements[0].buf;
                 pack_ptr->type  = Set_routed( pack_ptr->type );
                 pack_ptr->type  = Set_endian( pack_ptr->type );
+                pack_ptr->conf_hash = Cn->hash_code;
                 pack_ptr->transmiter_id = My.id;
         }
 
@@ -384,6 +386,7 @@
 	ret = 0;
 	pack_ptr = (packet_header *)scat->elements[0].buf;
 	pack_ptr->type = Set_endian( pack_ptr->type );
+        pack_ptr->conf_hash = Cn->hash_code;
 	pack_ptr->transmiter_id = My.id;
 	if( seg_index == My.seg_index )
 	{
@@ -419,6 +422,7 @@
 
 	pack_ptr = (packet_header *)scat->elements[0].buf;
 	pack_ptr->type = Set_endian( pack_ptr->type );
+        pack_ptr->conf_hash = Cn->hash_code;
 	pack_ptr->transmiter_id = My.id;
 	ret = Conf_proc_by_id( proc_id, &p );
 	if( ret < 0 )
@@ -468,6 +472,19 @@
 	/* Fliping packet header to my form if needed */
 	if( !Same_endian( pack_ptr->type ) ) Flip_pack( pack_ptr );
 
+        /* First reject any message whose daemon has a different configuration */
+        if ( (pack_ptr->conf_hash != Cn->hash_code) && (pack_ptr->conf_hash != MONITOR_HASH) ){
+            Alarmp( SPLOG_WARNING, NETWORK, "Net_recv: Received message (pkthdr_len = %u) from host %d.%d.%d.%d with different spread configuration file (hash %u != local hash %u)\n", 
+                    scat->elements[0].len,
+                    IP1(pack_ptr->proc_id),
+                    IP2(pack_ptr->proc_id),
+                    IP3(pack_ptr->proc_id),
+                    IP4(pack_ptr->proc_id),
+                    pack_ptr->conf_hash, 
+                    Cn->hash_code);
+            return( 0 );
+        }
+
 	if( Is_partition( pack_ptr->type ) )
 	{
 		/* Monitor : updating partition */
@@ -616,6 +633,7 @@
 
 	token_ptr = (token_header *)scat->elements[0].buf;
 	token_ptr->type = Set_endian( token_ptr->type );
+        token_ptr->conf_hash = Cn->hash_code;
 	token_ptr->transmiter_id = My.id;
 
         if ( token_ptr->rtr_len > (MAX_PACKET_SIZE - sizeof(token_header) ) )
@@ -655,6 +673,18 @@
 	/* Fliping token header to my form if needed */
 	if( !Same_endian( token_ptr->type ) ) Flip_token( token_ptr );
 
+        /* First reject any token whose daemon has a different configuration */
+        if (token_ptr->conf_hash != Cn->hash_code) {
+            Alarmp( SPLOG_WARNING, NETWORK, "Net_recv_token: Received token from host %d.%d.%d.%d with different spread configuration file (hash %u != local hash %u)\n", 
+                    IP1(token_ptr->proc_id),
+                    IP2(token_ptr->proc_id),
+                    IP3(token_ptr->proc_id),
+                    IP4(token_ptr->proc_id),
+                    token_ptr->conf_hash, 
+                    Cn->hash_code);
+            return( 0 );
+        }
+
 	/* Monitor : drop token from daemon in different monitor-caused partition */
 	if( !In_my_component( token_ptr->transmiter_id ) )
 		return( 0 );
@@ -670,6 +700,7 @@
 
 	token_ptr = (token_header *)scat->elements[0].buf;
 	token_ptr->type = Set_endian( token_ptr->type );
+        token_ptr->conf_hash = Cn->hash_code;
 	token_ptr->transmiter_id = My.id;
 	ret = Conf_proc_by_id( proc_id, &p );
 	if( ret < 0 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.