void Stat_handle_message( sys_scatter *scat ) { sp_time now; sp_time delta; packet_header *pack_ptr; proc p; int ret; pack_ptr = (packet_header *)scat->elements[0].buf; if( ! ( pack_ptr->memb_id.proc_id == 15051963 && Conf_id_in_conf( Conf_ref(), pack_ptr->proc_id ) != -1 ) ) { Alarm( STATUS, "Stat_handle_message: Illegal monitor request\n"); return; } now = E_get_time(); delta = E_sub_time( now, Start_time ); GlobalStatus.sec = delta.sec; DL_send( Report_channel, pack_ptr->proc_id, pack_ptr->seq, &Report_scat ); ret = Conf_proc_by_id( pack_ptr->proc_id, &p ); if( ret < 0 ) Alarm( STATUS, "Stat_handle_message: sent status to Monitor at %d\n", pack_ptr->proc_id ); else Alarm( STATUS, "Stat_handle_message: sent status to Monitor at %s\n", p.name ); }
static void Handle_hurry( packet_header *pack_ptr ) { if( Conf_leader( Memb_active_ptr() ) == My.id && Is_token_hold() ) { if( Conf_id_in_conf( Memb_active_ptr(), pack_ptr->proc_id ) != -1 ) { Alarm( PROTOCOL, "Handle_hurry: sending token now\n"); Prot_token_hurry(); } } }
void FC_handle_message( sys_scatter *scat ) { int16 *cur_fc_buf; packet_header *pack_ptr; proc dummy_proc; int my_index; int16 temp_window,temp_personal_window; configuration *Cn; Cn = Conf_ref(); pack_ptr = (packet_header *)scat->elements[0].buf; if ( ! Conf_get_dangerous_monitor_state() ) { Alarm( FLOW_CONTROL, "FC_handle_message: Request to change flow control from (%d.%d.%d.%d) denied. Monitor in safe mode\n", IP1(pack_ptr->proc_id), IP2(pack_ptr->proc_id), IP3(pack_ptr->proc_id), IP4(pack_ptr->proc_id) ); return; } if( ! ( pack_ptr->memb_id.proc_id == 15051963 && Conf_id_in_conf( Cn, pack_ptr->proc_id ) != -1 ) ) { Alarm( FLOW_CONTROL, "FC_handle_message: Illegal monitor request\n"); return; } cur_fc_buf = (int16 *)scat->elements[1].buf; my_index = Conf_proc_by_id( Conf_my().id, &dummy_proc ); if( Same_endian( pack_ptr->type ) ) { temp_window = cur_fc_buf[Conf_num_procs( Cn )]; temp_personal_window = cur_fc_buf[my_index]; }else{ temp_window = Flip_int16( cur_fc_buf[Conf_num_procs( Cn )] ); temp_personal_window = Flip_int16( cur_fc_buf[my_index] ); } if( temp_window != -1 ) Window = temp_window; if( temp_personal_window != -1 ) Personal_window = temp_personal_window; GlobalStatus.window = Window; GlobalStatus.personal_window = Personal_window; Alarm( FLOW_CONTROL, "FC_handle_message: Got monitor mess, Window %d Personal %d\n", Window, Personal_window ); }
void Discard_packets() { int pack_entry; packet_body *body_ptr; up_queue *up_ptr; int proc_index; int i; if( Aru <= Last_discarded ) return; if( Memb_state() == EVS ) { int found_hole; membership_id reg_memb_id; if( Aru != Last_seq ) return; /* Deliver packets that must be delivered before the transitional signal. * Those up to the Aru for my old ring were delivered in Read_form2(). * So, it remains to deliver all packets up to the first hole or the first * SAFE message. */ Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: delivering messages after old ring Aru before transitional\n" ); for( i = Last_discarded+1; i <= Highest_seq; i++ ) { pack_entry = i & PACKET_MASK; if( ! Packets[pack_entry].exist ) Alarmp( SPLOG_FATAL, PROTOCOL, "Discard_packets: (EVS before transitional) packet %d not exist\n", i); if( Packets[pack_entry].exist == 3 ) { Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Found first Hole in %d\n", i); break; } if( Is_safe( Packets[pack_entry].head->type ) ) { Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Found first SAFE message in %d", i); break; } /* should deliver packet or dispose the body if it was delivered already */ if( Packets[pack_entry].exist == 1 ){ Deliver_packet( pack_entry, 0 ); } else { dispose( Packets[pack_entry].body ); } /* dispose packet header in any case */ dispose( Packets[pack_entry].head ); Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: delivering %d in EVS\n",i); Packets[pack_entry].exist = 0; Last_discarded = i; } /* calculate and deliver transitional membership */ Alarmp( SPLOG_INFO, PROTOCOL, "Discard_packets: Delivering transitional membership\n" ); Memb_transitional(); Sess_deliver_trans_memb( Trans_membership, Memb_trans_id() ); /* deliver all remaining packets for EVS */ found_hole = 0; for( i = Last_discarded+1; i <= Highest_seq; i++ ) { pack_entry = i & PACKET_MASK; if( ! Packets[pack_entry].exist ) Alarm( EXIT, "Discard_packets: (EVS after transitional) packet %d not exist\n", i); if( Packets[pack_entry].exist == 3 ) { /* * There is a hole! * from here, we need to check if the proc_id of the packet * is in commited membership. */ found_hole = 1; Alarm( PROTOCOL, "Discard_packets: Found a Hole in %d \n",i); }else if( (!found_hole) || (Conf_id_in_conf( &Commit_membership, Packets[pack_entry].head->proc_id ) != -1) ){ /* should deliver packet or dispose the body if it was delivered already */ if( Packets[pack_entry].exist == 1 ){ Deliver_packet( pack_entry, 0 ); }else{ dispose( Packets[pack_entry].body ); } /* dispose packet header in any case */ dispose( Packets[pack_entry].head ); Alarm( PROTOCOL, "Discard_packets: delivering %d in EVS\n",i); }else{ /* should not deliver packet */ dispose( Packets[pack_entry].head ); dispose( Packets[pack_entry].body ); Alarm( PROTOCOL, "Discard_packets: Due to hole, not delivering %d \n",i); } Packets[pack_entry].exist = 0; } /* check up_queue and down_queue */ if( Down_queue_ptr->num_mess > 0 ) { Down_queue_ptr->cur_element = 0; } for( proc_index=0; proc_index < MAX_PROCS_RING; proc_index++ ) { if( Up_queue[proc_index].exist ) { if( proc_index != My_index ) { /* * dispose only packets that are not mine * my packets will stay in Down_queue if the message is not * ready to be delivered (because not fully sent yet) * so we need not to dispose them! */ up_ptr = &Up_queue[proc_index]; for( i=0; i < up_ptr->mess->num_elements; i++ ) { body_ptr = (packet_body *)up_ptr->mess->elements[i].buf; dispose( body_ptr ); } } dispose( Up_queue[proc_index].mess ); Up_queue[proc_index].exist = 0; } } /* calculate and deliver regular membership */ Memb_regular(); Log_membership(); reg_memb_id = Memb_id(); Sess_deliver_reg_memb( Reg_membership, reg_memb_id ); /* If in change conf mode; then if singleton (which should be true) and GOP state then: * Remove partition * Initiate Memb_lookup() to find other daemons */ if( Conf_in_reload_singleton_state() ) { /* GOP state equals value 1, but is private declaration in groups.c */ if ( (GlobalStatus.gstate != 1 ) || ( Conf_num_procs( &Reg_membership ) != 1 ) ) { Alarmp( SPLOG_FATAL, MEMB, "Discard_packets: Failed to reload configuration - gstate: %d and num_procs in membership: %d\n", GlobalStatus.gstate, Conf_num_procs( &Reg_membership) ); } Net_clear_partition(); E_queue( Memb_lookup_new_members, 0, NULL, Zero_timeout); Conf_reload_singleton_state_end(); } /* set variables for next membership */ if ( Conf_debug_initial_sequence() ) { Last_token->aru = INITIAL_SEQUENCE_NEAR_WRAP; Highest_seq = INITIAL_SEQUENCE_NEAR_WRAP; Highest_fifo_seq = INITIAL_SEQUENCE_NEAR_WRAP; My_aru = INITIAL_SEQUENCE_NEAR_WRAP; Aru = INITIAL_SEQUENCE_NEAR_WRAP; Set_aru = INITIAL_SEQUENCE_NEAR_WRAP -1; Last_discarded = INITIAL_SEQUENCE_NEAR_WRAP; Last_delivered = INITIAL_SEQUENCE_NEAR_WRAP; } else { Last_token->aru = 0; Highest_seq = 0; Highest_fifo_seq = 0; My_aru = 0; Aru = 0; Set_aru = -1; Last_discarded = 0; Last_delivered = 0; } GlobalStatus.my_aru = My_aru; Token_counter = 0; }else{ for( i = Last_discarded+1; i <= Aru; i++ ) { pack_entry = i & PACKET_MASK; if( ! Packets[pack_entry].exist ) Alarm( EXIT, "Discard_packets: (NOT EVS) packet %d not exist\n",i); /* should deliver packet or dispose the body if it was delivered already */ if( Packets[pack_entry].exist == 1 ) Deliver_packet( pack_entry, 0 ); else dispose( Packets[pack_entry].body ); /* dispose packet header in any case */ dispose( Packets[pack_entry].head ); Packets[pack_entry].exist = 0; } Alarm( PROTOCOL, "Discard_packets: packets %d-%d were discarded\n", Last_discarded+1, Aru ); Last_discarded = Aru; if( Last_delivered < Last_discarded ) Last_delivered = Last_discarded; } }