Commit 4da70724 authored by Jean-Claude BAU's avatar Jean-Claude BAU

WR protocol extension improvements

- Give priority to the time-out and not the number of msg repetitions
- Call also wr_handshake_fail() function when a time-out is detected.
parent ecd72709
......@@ -44,6 +44,5 @@ int wr_handshake_retry(struct pp_instance *ppi)
pp_diag(ppi, ext, 1, "Retry on timeout\n");
return 1; /* yes, retry */
}
wr_handshake_fail(ppi);
return 0; /* don't retry, we are over already */
}
......@@ -48,13 +48,14 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
{
/* Check if tmo expired */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if (wr_handshake_retry(ppi))
sendmsg = 1;
else {
if ( rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
if ( !rms ) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
if (wr_handshake_retry(ppi))
sendmsg = 1;
}
}
}
......
......@@ -40,13 +40,14 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
{ /* Check remaining time */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if (wr_handshake_retry(ppi))
sendmsg = 1;
else {
if ( rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
if ( !rms ) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
if (wr_handshake_retry(ppi))
sendmsg = 1;
}
}
}
......
......@@ -40,13 +40,14 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
{ /* Check remaining time */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if (wr_handshake_retry(ppi))
sendmsg = 1;
else {
if ( rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
if ( !rms ) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
if (wr_handshake_retry(ppi))
sendmsg = 1;
}
}
}
......
......@@ -42,13 +42,14 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
{ /* Check remaining time */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if (wr_handshake_retry(ppi))
sendmsg = 1;
else {
if (rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
if (!rms) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
if (wr_handshake_retry(ppi))
sendmsg = 1;
}
}
}
......
......@@ -43,11 +43,13 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
{ /* Check remaining time */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if (!wr_handshake_retry(ppi)) {
if ( rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
if ( !rms ) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
wr_handshake_retry(ppi);
}
}
}
......
......@@ -30,14 +30,15 @@ int wr_s_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
{ /* Check remaining time */
int rms=pp_next_delay_1(ppi, wrTmoIdx);
if ( rms==0 || rms<(wrp->wrStateRetry*WR_TMO_MS)) {
if ( rms<=(wrp->wrStateRetry*WR_TMO_MS)) {
WRH_OPER()->locking_disable(ppi);
if (wr_handshake_retry(ppi))
enable = 1;
else {
if ( rms==0 ) {
wr_handshake_fail(ppi);
pp_diag(ppi, time, 1, "timeout expired: "WR_TMO_NAME"\n");
return 0; /* non-wr already */
}
if (wr_handshake_retry(ppi))
enable = 1;
}
}
}
......
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