Commit fd2b09a0 authored by Alessandro Rubini's avatar Alessandro Rubini

kill ppi->record_update

The code, when receiving announce, was setting a flag in order to run
bmc at the next iteration, when that happened, the frame just received
was discarded in favour for the programmed state update.

This commits remove some fields and one helper function, so the new
announce is immediately processed and no frame is lost.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 692af7f3
......@@ -162,7 +162,6 @@ struct pp_instance {
UInteger16 number_foreign_records;
Integer16 foreign_record_i;
Integer16 foreign_record_best;
Boolean record_update;
struct pp_frgn_master frgn_master[PP_NR_FOREIGN_RECORDS];
TimeInternal sync_receive_time;
UInteger16 recv_sync_sequence_id;
......
......@@ -59,20 +59,6 @@ int st_com_execute_slave(struct pp_instance *ppi)
return 0;
}
/* Called by listening, master, passive, slave */
int st_com_check_record_update(struct pp_instance *ppi)
{
if (ppi->record_update) {
PP_VPRINTF("event STATE_DECISION_EVENT\n");
ppi->record_update = FALSE;
ppi->next_state = bmc(ppi);
if (ppi->next_state != ppi->state)
return 1;
}
return 0;
}
/* Called by this file, basically when an announce is got, all states */
static void st_com_add_foreign(struct pp_instance *ppi, unsigned char *buf)
{
......@@ -126,12 +112,6 @@ int st_com_slave_handle_announce(struct pp_instance *ppi, unsigned char *buf,
if (len < PP_ANNOUNCE_LENGTH)
return -1;
/*
* Valid announce message is received : BMC algorithm
* will be executed
*/
ppi->record_update = TRUE;
if (ppi->is_from_cur_par) {
msg_unpack_announce(buf, &ann);
s1(ppi, hdr, &ann);
......@@ -146,6 +126,8 @@ int st_com_slave_handle_announce(struct pp_instance *ppi, unsigned char *buf,
if (pp_hooks.handle_announce)
pp_hooks.handle_announce(ppi);
ppi->next_state = bmc(ppi); /* got a new announce: run bmc */
return 0;
}
......@@ -269,9 +251,7 @@ int st_com_master_handle_announce(struct pp_instance *ppi, unsigned char *buf,
PP_VPRINTF("Announce message from another foreign master\n");
st_com_add_foreign(ppi, buf);
ppi->record_update = TRUE;
ppi->next_state = bmc(ppi); /* got a new announce: run bmc */
return 0;
}
......
......@@ -15,8 +15,6 @@ int st_com_execute_slave(struct pp_instance *ppi);
void st_com_restart_annrec_timer(struct pp_instance *ppi);
int st_com_check_record_update(struct pp_instance *ppi);
/* Each of the following "handle" functions" return 0 in case of correct
* message, -1 in case the message contained in buf is not proper (e.g. size
* is not the expected one
......
......@@ -18,9 +18,6 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state)
pp_timeout_restart_annrec(ppi);
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto out;
......@@ -46,7 +43,6 @@ out:
if (e != 0)
ppi->next_state = PPS_FAULTY;
state_updated:
/* Leaving this state */
if (ppi->next_state != ppi->state)
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
......
......@@ -25,9 +25,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto out;
}
if (st_com_check_record_update(ppi))
goto state_updated;
if (pp_timeout_z(ppi, PP_TO_SYNC)) {
if ((e = msg_issue_sync(ppi) < 0))
goto out;
......@@ -107,7 +104,6 @@ out:
ppi->next_state = PPS_FAULTY;
}
state_updated:
d1 = pp_ms_to_timeout(ppi, PP_TO_ANN_INTERVAL);
d2 = pp_ms_to_timeout(ppi, PP_TO_SYNC);
ppi->next_delay = d1 < d2 ? d1 : d2;
......
......@@ -13,9 +13,6 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state)
pp_timeout_restart_annrec(ppi);
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto no_incoming_msg;
......@@ -42,9 +39,6 @@ no_incoming_msg:
if (e != 0)
ppi->next_state = PPS_FAULTY;
state_updated:
/* Leaving this state */
if (ppi->next_state != ppi->state) {
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
}
......
......@@ -30,9 +30,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->logMinDelayReqInterval);
}
if (st_com_check_record_update(ppi))
goto state_updated;
if (plen == 0)
goto out;
......@@ -129,8 +126,6 @@ out:
return 0;
}
state_updated:
/* Leaving this state */
if (ppi->next_state != ppi->state) {
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment