[Spread-cvs] commit: r374 - trunk/daemon
jonathan at spread.org
jonathan at spread.org
Sun Nov 19 16:02:17 EST 2006
Author: jonathan
Date: 2006-11-19 16:02:16 -0500 (Sun, 19 Nov 2006)
New Revision: 374
Modified:
trunk/daemon/Changelog
trunk/daemon/groups.c
trunk/daemon/groups.h
trunk/daemon/sess_body.h
Log:
Fix big-endian bug caused by int->char memcpy.
Bug reported by Ryan Caudy.
group->changed field is now a boolean instead of int.
Value sent in GROUPS message is an int16u to have fixed size.
Use GROUPS_BUF_* macros instead of recalcuating size.
Split into a version that returns changed status as a bool
and a void return for G_eliminate_partitioned_members().
Rename G_check_synced_set to void G_update_synced_set() and
bool G_update_synced_set_status().
Change return value of G_check_if_changed_by_cascade() to bool.
Use bool types for all 'changed' type variables.
Modified: trunk/daemon/Changelog
===================================================================
--- trunk/daemon/Changelog 2006-11-19 19:38:49 UTC (rev 373)
+++ trunk/daemon/Changelog 2006-11-19 21:02:16 UTC (rev 374)
@@ -1,3 +1,18 @@
+Sun Nov 19 15:13:47 2006 Jonathan Stanton <jonathan at cnds.jhu.edu>
+
+ * sess_body.h, groups.h, groups.c (group,G_build_groups_buf):
+ Fix big-endian bug caused by int->char memcpy.
+ group->changed field is now a boolean instead of int.
+ Value sent in GROUPS message is an int16u to have fixed size.
+ Use GROUPS_BUF_* macros instead of recalcuating size.
+
+ Split into a version that returns changed status as a bool
+ and a void return for G_eliminate_partitioned_members().
+ Rename G_check_synced_set to void G_update_synced_set() and
+ bool G_update_synced_set_status().
+ Change return value of G_check_if_changed_by_cascade() to bool.
+ Use bool types for all 'changed' type variables.
+
Fri Nov 17 13:43:42 2006 Jonathan Stanton <jonathan at cnds.jhu.edu>
* network.c (Net_init): Do not bind to broadcast address
Modified: trunk/daemon/groups.c
===================================================================
--- trunk/daemon/groups.c 2006-11-19 19:38:49 UTC (rev 373)
+++ trunk/daemon/groups.c 2006-11-19 21:02:16 UTC (rev 374)
@@ -162,11 +162,13 @@
static void G_update_daemon_memb_ids( group *grp );
static void G_add_to_synced_set( synced_set *s );
-static int G_check_synced_set( synced_set *s, configuration *m );
+static void G_update_synced_set( synced_set *s, configuration *m );
+static bool G_update_synced_set_status( synced_set *s, configuration *m );
static void G_print_synced_set( int priority, synced_set *s, char *func_name );
-static int G_eliminate_partitioned_daemons( group *grp );
-static int G_check_if_changed_by_cascade( group *grp );
+static void G_eliminate_partitioned_daemons( group *grp );
+static bool G_eliminate_partitioned_daemons_status( group *grp );
+static bool G_check_if_changed_by_cascade( group *grp );
static void G_remove_daemon( group *grp, daemon_members *dmn );
static void G_remove_group( group *grp );
static void G_remove_mailbox( group *grp, mailbox m );
@@ -301,7 +303,7 @@
synced_set sset;
int ret;
char ip_string[16];
- int group_changed, synced_set_changed;
+ bool group_changed, synced_set_changed;
stdit it;
IP_to_STR( reg_memb_id.proc_id, ip_string );
@@ -365,7 +367,7 @@
G_print_group_id( SPLOG_DEBUG, grp->grp_id, "G_handle_reg_memb" );
grp->grp_id.memb_id = Reg_memb_id;
grp->grp_id.index = 1;
- grp->changed = 0;
+ grp->changed = FALSE;
G_print_group_id( SPLOG_DEBUG, grp->grp_id, "G_handle_reg_memb" );
G_update_daemon_memb_ids( grp );
if( !stdarr_empty(&grp->mboxes) )
@@ -500,7 +502,7 @@
grp = *(group**) stdskl_it_key(&it);
stdskl_it_next(&it); /* NOTE: need to do advancement before potential erasure below */
- group_changed = G_eliminate_partitioned_daemons( grp );
+ group_changed = G_eliminate_partitioned_daemons_status( grp );
if( group_changed )
{
Groups_bufs_fresh = 0;
@@ -509,11 +511,11 @@
/* discard this empty group */
G_remove_group( grp );
} else {
- grp->changed = 1;
+ grp->changed = TRUE;
}
}
}
- synced_set_changed = G_check_synced_set( &MySyncedSet, &Trans_memb );
+ synced_set_changed = G_update_synced_set_status( &MySyncedSet, &Trans_memb );
G_print_synced_set( SPLOG_INFO, &MySyncedSet, "G_handle_reg_memb" );
/* Since one of the groups bufs holds the synced set... */
if( synced_set_changed )
@@ -548,7 +550,7 @@
{
group *grp;
daemon_members *dmn;
- int group_changed;
+ bool group_changed;
char ip_string[16];
stdit git, dit;
@@ -578,7 +580,7 @@
grp = *(group**) stdskl_it_key(&git);
stdskl_it_next(&git); /* NOTE: need to do advancement before potential erasure below */
- group_changed = 0;
+ group_changed = FALSE;
for (stdskl_begin(&grp->DaemonsList, &dit); !stdskl_is_end(&grp->DaemonsList, &dit); )
{
@@ -589,7 +591,7 @@
{
/* mark this daemon as partitioned - proc no longer in membership */
dmn->memb_id = unknown_memb_id;
- group_changed = 1;
+ group_changed = TRUE;
}
}
if( group_changed )
@@ -603,7 +605,7 @@
G_print_group_id( SPLOG_DEBUG, grp->grp_id, "G_handle_trans_memb" );
grp->grp_id.memb_id = Trans_memb_id;
grp->grp_id.index = 1;
- grp->changed = 1;
+ grp->changed = TRUE;
G_print_group_id( SPLOG_DEBUG, grp->grp_id, "G_handle_trans_memb" );
/* Here, we mark everyone who we are synced with as having the new memb_id
* Specifically, that is, everyone who isn't partitioned from us now in the GroupsList */
@@ -614,7 +616,7 @@
Gstate = GTRANS;
GlobalStatus.gstate = Gstate;
- G_check_synced_set( &MySyncedSet, &Trans_memb );
+ G_update_synced_set( &MySyncedSet, &Trans_memb );
G_print_synced_set( SPLOG_INFO, &MySyncedSet, "G_handle_trans_memb" );
break;
@@ -664,7 +666,7 @@
group_changed = G_check_if_changed_by_cascade( grp );
if( group_changed ) {
- grp->changed = 1;
+ grp->changed = TRUE;
}
}
@@ -754,7 +756,7 @@
/* NOTE: Older versions of groups do mark a new group as changed if it's
* created in GTRANS. This is only needed if the joiner is partitioned
* from us [handled below]. */
- new_grp->changed = 0;
+ new_grp->changed = FALSE;
if( Gstate == GOP) {
new_grp->grp_id.memb_id = Reg_memb_id;
@@ -837,7 +839,7 @@
new_mbox = -1;
if( Is_partitioned_daemon( dmn ) && !grp->changed )
- grp->changed = 1;
+ grp->changed = TRUE;
if( !stdarr_empty(&grp->mboxes) ) {
if( grp->changed )
@@ -1523,7 +1525,7 @@
/* the group has changed */
grp->grp_id.memb_id = Reg_memb_id;
grp->grp_id.index = 1;
- grp->changed = 0;
+ grp->changed = FALSE;
if( !stdarr_empty(&grp->mboxes) )
G_send_heavyweight_memb( grp );
G_update_daemon_memb_ids( grp );
@@ -1854,6 +1856,7 @@
int32u size_needed;
int couldnt_fit_daemon;
stdit mit;
+ int16u send_group_changed;
/* A GROUPS message looks like this:
* (Representative's name is in header, so we can get his proc id)
@@ -1871,7 +1874,7 @@
* changed in any respect by this membership) or this ID can be
* discarded. This is here so that daemons that don't know about
* the group at all can get the correct ID in the unchanged case.]
- * changed flag (byte)
+ * changed flag (int16u --boolean so always 0 or 1)
* number of daemons for this group (in this message) (int16u)
* For each daemon:
* daemon proc id (int32)
@@ -1917,7 +1920,7 @@
/* To have information about this group, we need to be able to fit
* its name, ID, and the number of daemons it has in this message. */
- size_needed = MAX_GROUP_NAME + sizeof(group_id) + sizeof(byte) + sizeof(int16u) + Message_get_data_header_size();
+ size_needed = GROUPS_BUF_GROUP_INFO_SIZE + Message_get_data_header_size();
if( size_needed > GROUPS_BUF_SIZE - num_bytes ) break;
memcpy( &buf[num_bytes], grp->name, MAX_GROUP_NAME );
@@ -1926,8 +1929,9 @@
memcpy( &buf[num_bytes], &grp->grp_id, sizeof(group_id) );
num_bytes += sizeof(group_id);
- memcpy( &buf[num_bytes], &grp->changed, sizeof(byte) );
- num_bytes += sizeof(byte);
+ send_group_changed = grp->changed;
+ memcpy( &buf[num_bytes], &send_group_changed, sizeof(int16u) );
+ num_bytes += sizeof(int16u);
num_dmns_ptr = &buf[num_bytes];
num_bytes += sizeof(int16u);
@@ -1939,7 +1943,7 @@
/* To store this daemon's information about the current group,
* we need to be able to store its proc_id, memb_id, number of
* local members, and the private group names of its local members. */
- size_needed = sizeof(int32) + sizeof(membership_id) + sizeof(int16u) +
+ size_needed = GROUPS_BUF_DAEMON_INFO_SIZE +
(stdskl_size(&dmn->MembersList) * MAX_GROUP_NAME) + Message_get_data_header_size();
/* This requires that the number of local group members be limited. */
if( size_needed > GROUPS_BUF_SIZE - num_bytes )
@@ -2085,7 +2089,7 @@
int i,j;
char ip_string[16];
stdit it;
- char sent_group_changed;
+ int16u sent_group_changed;
total_bytes = 0;
msg = mess_link->mess;
@@ -2143,7 +2147,7 @@
Alarmp( SPLOG_FATAL, GROUPS, "%s: %d: memory allocation failed\n", __FILE__, __LINE__ );
}
- grp->changed = 0;
+ grp->changed = FALSE;
grp->num_members = 0;
/* Set a group id here, so that if the group isn't changed,
@@ -2166,11 +2170,11 @@
}
num_bytes += sizeof(group_id);
/* Get the changed flag for sent group and set local group changed flag if sent group was marked changed */
- memcpy( &sent_group_changed, &Temp_buf[num_bytes], sizeof(byte) );
- num_bytes += sizeof(byte);
+ memcpy( &sent_group_changed, &Temp_buf[num_bytes], sizeof(int16u) );
+ num_bytes += sizeof(int16u);
if (sent_group_changed)
- grp->changed = 1;
+ grp->changed = TRUE;
memcpy( &num_dmns, &Temp_buf[num_bytes], sizeof(int16u) );
num_bytes += sizeof(int16u);
@@ -2216,7 +2220,7 @@
if( !grp->changed &&
!Memb_is_equal( dmn->memb_id, grp->grp_id.memb_id ) )
- grp->changed = 1;
+ grp->changed = TRUE;
/* creating members */
for( j = 0; j < num_memb; ++j )
@@ -2574,22 +2578,33 @@
}
/* Remove members who aren't in the membership. */
-static int G_check_synced_set( synced_set *s, configuration *memb_p ) {
- int i, j = 0, changed = 0;
+static void G_update_synced_set( synced_set *s, configuration *memb_p ) {
+ bool ret;
+ ret = G_update_synced_set_status( s, memb_p );
+ return;
+}
+/* Remove members who aren't in the membership and
+ * return true if group changed membership or false otherwise */
+static bool G_update_synced_set_status( synced_set *s, configuration *memb_p )
+{
+ int i, j = 0;
+ bool changed = FALSE;
+
for( i = 0; i < s->size; ++i )
if( Conf_id_in_conf( memb_p, s->proc_ids[i] ) >= 0 )
s->proc_ids[j++] = s->proc_ids[i];
/* If we lost members. */
if( j != s->size ) {
s->size = j;
- changed = 1;
+ changed = TRUE;
}
return changed;
}
/* Print the synced set. For debugging. */
-static void G_print_synced_set( int priority, synced_set *s, char *func_name ) {
+static void G_print_synced_set( int priority, synced_set *s, char *func_name )
+{
int i;
proc p;
Alarmp( priority, GROUPS, "%s: Synced Set (with %u members):\n", func_name, s->size );
@@ -2599,12 +2614,20 @@
}
}
+/* Eliminate the partitioned daemons of a group. */
+static void G_eliminate_partitioned_daemons( group *grp )
+{
+ bool ret;
+ ret = G_eliminate_partitioned_daemons_status( grp );
+ return;
+}
+
/* Eliminate the partitioned daemons of a group. Return true if we changed the
* group. */
-static int G_eliminate_partitioned_daemons( group *grp )
+static bool G_eliminate_partitioned_daemons_status( group *grp )
{
daemon_members *dmn;
- int group_changed = 0;
+ bool group_changed = FALSE;
int needed;
stdit it;
@@ -2635,7 +2658,7 @@
{
/* discard this daemon and its members - proc no longer in membership */
G_remove_daemon( grp, dmn );
- group_changed = 1;
+ group_changed = TRUE;
}
}
return group_changed;
@@ -2643,10 +2666,10 @@
/* This function is only called when we handle a cascading transitional membership.
* Gstate should be GGATHER, about to change to GGT */
-static int G_check_if_changed_by_cascade( group *grp )
+static bool G_check_if_changed_by_cascade( group *grp )
{
daemon_members *dmn;
- int group_changed = 0;
+ bool group_changed = FALSE;
stdit it;
for (stdskl_begin(&grp->DaemonsList, &it); !stdskl_is_end(&grp->DaemonsList, &it); stdskl_it_next(&it))
@@ -2654,7 +2677,7 @@
dmn = *(daemon_members**) stdskl_it_key(&it);
if( Conf_id_in_conf( &Trans_memb, dmn->proc_id ) == -1 )
{
- group_changed = 1;
+ group_changed = TRUE;
break;
}
}
Modified: trunk/daemon/groups.h
===================================================================
--- trunk/daemon/groups.h 2006-11-19 19:38:49 UTC (rev 373)
+++ trunk/daemon/groups.h 2006-11-19 21:02:16 UTC (rev 374)
@@ -45,7 +45,7 @@
#define GROUPS_BUF_SIZE 100000
#define GROUPS_BUF_PREAMBLE_SIZE ( sizeof(membership_id) + sizeof(char) )
#define GROUPS_BUF_GROUP_INFO_SIZE ( MAX_GROUP_NAME + sizeof(group_id) + \
- sizeof(int16u) )
+ sizeof(int16u) + sizeof(int16u) )
#define GROUPS_BUF_DAEMON_INFO_SIZE ( sizeof(int32) + sizeof(membership_id) + \
sizeof(int16u) )
#define MAX_LOCAL_GROUP_MEMBERS (( GROUPS_BUF_SIZE - GROUPS_BUF_PREAMBLE_SIZE \
Modified: trunk/daemon/sess_body.h
===================================================================
--- trunk/daemon/sess_body.h 2006-11-19 19:38:49 UTC (rev 373)
+++ trunk/daemon/sess_body.h 2006-11-19 21:02:16 UTC (rev 374)
@@ -84,7 +84,7 @@
typedef struct dummy_group {
char name[MAX_GROUP_NAME]; /* NOTE: groups.c depends on 'name' being the first member (GroupsList) */
group_id grp_id;
- int changed;
+ bool changed;
int num_members; /* sums over all daemons in DaemonsList */
stdskl DaemonsList; /* (daemon_members*) -> nil */
stdarr mboxes; /* (mailbox): local clients unordered */
More information about the Spread-cvs
mailing list