Skip to content

Commit

Permalink
cp: Fix 'REPLY_BUSY' handling logic
Browse files Browse the repository at this point in the history
Looks like REPLY_BUSY from a PD was just ignored by the CP. Not sure
when this was broken (due to too many changes lately and blame isn't
helpful).

This was just accidentally caught during an unrelated work. Also
indicates we don't have sufficient test coverage.

Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Aug 31, 2024
1 parent 485e34d commit 8537c52
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/osdp_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,12 +868,6 @@ static int cp_phy_state_update(struct osdp_pd *pd)
if (sc_is_active(pd)) {
pd->sc_tstamp = osdp_millis_now();
}
if (pd->reply_id == REPLY_BUSY) {
pd->phy_tstamp = osdp_millis_now();
pd->wait_ms = OSDP_CMD_RETRY_WAIT_MS;
pd->phy_state = OSDP_CP_PHY_STATE_WAIT;
return OSDP_CP_ERR_CAN_YIELD;
}
pd->phy_state = OSDP_CP_PHY_STATE_DONE;
return OSDP_CP_ERR_NONE;
}
Expand All @@ -888,6 +882,12 @@ static int cp_phy_state_update(struct osdp_pd *pd)
if (rc == OSDP_CP_ERR_GENERIC || rc == OSDP_CP_ERR_UNKNOWN) {
goto error;
}
if (rc == OSDP_CP_ERR_RETRY_CMD) {
pd->phy_tstamp = osdp_millis_now();
pd->wait_ms = OSDP_CMD_RETRY_WAIT_MS;
pd->phy_state = OSDP_CP_PHY_STATE_WAIT;
return OSDP_CP_ERR_CAN_YIELD;
}
if (osdp_millis_since(pd->phy_tstamp) > OSDP_RESP_TOUT_MS) {
if (pd->phy_retry_count < OSDP_CMD_MAX_RETRIES) {
pd->wait_ms = OSDP_CMD_RETRY_WAIT_MS;
Expand All @@ -902,10 +902,6 @@ static int cp_phy_state_update(struct osdp_pd *pd)
osdp_cmd_name(pd->cmd_id), pd->cmd_id);
goto error;
}
if (rc == OSDP_CP_ERR_RETRY_CMD) {
pd->phy_state = OSDP_CP_PHY_STATE_DONE;
return OSDP_CP_ERR_NONE;
}
ret = OSDP_CP_ERR_INPROG;
break;
}
Expand Down

0 comments on commit 8537c52

Please sign in to comment.