diff -u -r ./spread-src-4.0.0rc2/daemon/protocol.c ./spread-localmess/daemon/protocol.c --- ./spread-src-4.0.0rc2/daemon/protocol.c 2006-03-02 12:22:12.000000000 -0800 +++ ./spread-localmess/daemon/protocol.c 2006-09-12 13:24:03.000000000 -0700 @@ -838,6 +838,7 @@ int pack_entry; int num_sent; int ret; + int local_only; num_sent = 0; while( num_sent < num_allowed ) @@ -862,6 +863,11 @@ Send_pack.elements[1].buf = scat_ptr->elements[ Down_queue_ptr->cur_element].buf; + /* + * determine if this message should just be + * sent locally and not bcast. + */ + local_only = Is_local_mess(pack_ptr->type); Down_queue_ptr->cur_element++; if( Down_queue_ptr->cur_element < scat_ptr->num_elements ) @@ -891,11 +897,15 @@ Send_pack.elements[0].buf = (char *) pack_ptr; Send_pack.elements[1].len = pack_ptr->data_len; + if (local_only) { + ret = Net_ucast( My.id, &Send_pack ); + } else { #if 1 - ret = Net_queue_bcast( &Send_pack ); + ret = Net_queue_bcast( &Send_pack ); #else - ret = Net_bcast( &Send_pack ); + ret = Net_bcast( &Send_pack ); #endif + } if( ret > 0 ) { num_sent++; diff -u -r ./spread-src-4.0.0rc2/daemon/sess_types.h ./spread-localmess/daemon/sess_types.h --- ./spread-src-4.0.0rc2/daemon/sess_types.h 2006-03-02 11:03:45.000000000 -0800 +++ ./spread-localmess/daemon/sess_types.h 2006-09-12 14:13:38.000000000 -0700 @@ -58,6 +58,9 @@ #define SELF_DISCARD 0x00000040 /* allow the sender to hint whether it wants the message back or not */ +#define LOCAL_MESS 0x01000000 /* indicates that the message should + only be sent to members on the + local node. */ #define DROP_RECV 0x01000000 /* if set on recv, then drop data that doesn't fit in buffers. Else, return error from recv and @@ -96,6 +99,7 @@ #define Is_only_regular_mess(type) (((type) & REGULAR_MESS)&&(!((type) & NOT_REGULAR_MESS))) #define Is_self_discard( type ) ( type & SELF_DISCARD ) +#define Is_local_mess( type ) ( type & LOCAL_MESS ) #define Is_drop_recv( type ) ( type & DROP_RECV ) #define Is_reg_memb_mess( type ) ( type & REG_MEMB_MESS ) diff -u -r ./spread-src-4.0.0rc2/daemon/session.c ./spread-localmess/daemon/session.c --- ./spread-src-4.0.0rc2/daemon/session.c 2006-03-02 11:03:45.000000000 -0800 +++ ./spread-localmess/daemon/session.c 2006-09-12 13:52:11.000000000 -0700 @@ -1501,6 +1501,8 @@ head_ptr->type = Set_endian( head_ptr->type ); /* If original message was SELF_DISCARD, then maintain that state */ if (Is_self_discard( old_type) ) head_ptr->type |= SELF_DISCARD; + /* If original message was LOCAL_MESS, then maintain that state */ + if (Is_local_mess( old_type) ) head_ptr->type |= LOCAL_MESS; Message_add_oldtype_to_reject( msg, old_type ); diff -u -r ./spread-src-4.0.0rc2/docs/SP_multicast.3 ./spread-localmess/docs/SP_multicast.3 --- ./spread-src-4.0.0rc2/docs/SP_multicast.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-localmess/docs/SP_multicast.3 2006-09-13 11:13:05.000000000 -0700 @@ -44,8 +44,11 @@ .B SAFE_MESS .RE This type -can be bit ORed with other flags like SELF_DISCARD -if desired. Currently SELF_DISCARD is the only additional flag. +can be bit ORed with other flags like SELF_DISCARD or LOCAL_MESS +if desired. SELF_DISCARD will prevent the message from being sent +to the mbox that sent the message, LOCAL_MESS will cause delivery +to only occur to joined group members on the local node. SELF_DISCARD +and LOCAL_MESS can be used in conjunction. If the .B SP_multicast diff -u -r ./spread-src-4.0.0rc2/examples/user.c ./spread-localmess/examples/user.c --- ./spread-src-4.0.0rc2/examples/user.c 2006-03-02 11:03:45.000000000 -0800 +++ ./spread-localmess/examples/user.c 2006-09-12 13:58:01.000000000 -0700 @@ -214,11 +214,13 @@ unsigned int mess_len; int ret; int i; + int service_type; for( i=0; i < sizeof(command); i++ ) command[i] = 0; if( fgets( command, 130, stdin ) == NULL ) Bye(); + service_type = 0; switch( command[0] ) { case 'j': @@ -245,6 +247,8 @@ break; + case 'S': + service_type = LOCAL_MESS; case 's': num_groups = sscanf(&command[2], "%s%s%s%s%s%s%s%s%s%s", groups[0], groups[1], groups[2], groups[3], groups[4], @@ -258,6 +262,7 @@ if (fgets(mess, 200, stdin) == NULL) Bye(); mess_len = strlen( mess ); + service_type |= SAFE_MESS; #ifdef _REENTRANT #ifdef __bsdi__ /* bsdi bug - doing a close when another thread blocks on the socket causes a seg fault */ ret = send( Mbox, mess, 0, 0 ); @@ -268,7 +273,8 @@ } #endif /* __bsdi__ */ #endif /* _REENTRANT */ - ret= SP_multigroup_multicast( Mbox, SAFE_MESS, num_groups, (const char (*)[MAX_GROUP_NAME]) groups, 1, mess_len, mess ); +printf("service_type out %x\n", service_type); + ret= SP_multigroup_multicast( Mbox, service_type, num_groups, (const char (*)[MAX_GROUP_NAME]) groups, 1, mess_len, mess ); if( ret < 0 ) { SP_error( ret ); @@ -278,6 +284,8 @@ break; + case 'B': + service_type = LOCAL_MESS; case 'b': ret=sscanf( &command[2], "%s", group ); if( ret != 1 ) strcpy( group, "dummy_group_name" ); @@ -289,6 +297,7 @@ if( mess_len > MAX_MESSLEN ) mess_len = MAX_MESSLEN; Previous_len = mess_len; printf("sending 10 messages of %u bytes\n", mess_len ); + service_type |= FIFO_MESS; for( i=0; i<10; i++ ) { Num_sent++; @@ -363,7 +372,9 @@ printf("\tl -- leave a group\n"); printf("\n"); printf("\ts -- send a message\n"); + printf("\tS -- send a local message\n"); printf("\tb -- send a burst of messages\n"); + printf("\tB -- send a burst of local messages\n"); printf("\n"); #ifndef _REENTRANT printf("\tr -- receive a message (stuck) \n"); @@ -424,12 +435,15 @@ if( Is_regular_mess( service_type ) ) { mess[ret] = 0; - if ( Is_unreliable_mess( service_type ) ) printf("received UNRELIABLE "); - else if( Is_reliable_mess( service_type ) ) printf("received RELIABLE "); - else if( Is_fifo_mess( service_type ) ) printf("received FIFO "); - else if( Is_causal_mess( service_type ) ) printf("received CAUSAL "); - else if( Is_agreed_mess( service_type ) ) printf("received AGREED "); - else if( Is_safe_mess( service_type ) ) printf("received SAFE "); +printf("service type in %x\n", service_type); + printf("received "); + if ( Is_local_mess( service_type ) ) printf("LOCAL "); + if ( Is_unreliable_mess( service_type ) ) printf("UNRELIABLE "); + else if( Is_reliable_mess( service_type ) ) printf("RELIABLE "); + else if( Is_fifo_mess( service_type ) ) printf("FIFO "); + else if( Is_causal_mess( service_type ) ) printf("CAUSAL "); + else if( Is_agreed_mess( service_type ) ) printf("AGREED "); + else if( Is_safe_mess( service_type ) ) printf("SAFE "); printf("message from %s, of type %d, (endian %d) to %d groups \n(%d bytes): %s\n", sender, mess_type, endian_mismatch, num_groups, ret, mess ); }else if( Is_membership_mess( service_type ) ) diff -u -r ./spread-src-4.0.0rc2/include/sp.h ./spread-localmess/include/sp.h --- ./spread-src-4.0.0rc2/include/sp.h 2006-03-02 11:03:45.000000000 -0800 +++ ./spread-localmess/include/sp.h 2006-09-12 14:12:48.000000000 -0700 @@ -72,6 +72,7 @@ #define REGULAR_MESS 0x0000003f #define SELF_DISCARD 0x00000040 +#define LOCAL_MESS 0x01000000 #define DROP_RECV 0x01000000 #define REG_MEMB_MESS 0x00001000 @@ -95,6 +96,7 @@ #define Is_regular_mess( type ) ( (type & REGULAR_MESS) && !(type & REJECT_MESS) ) #define Is_self_discard( type ) ( type & SELF_DISCARD ) +#define Is_local_mess( type ) ( type & LOCAL_MESS ) #define Is_reg_memb_mess( type ) ( type & REG_MEMB_MESS ) #define Is_transition_mess( type ) ( type & TRANSITION_MESS )