mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
pd: fix negative timeout for waiting task
pd[port].timeout will be 0 immediate after set_state(), thus will cause a negative value result for timeout calculation in the pd_task's ending loop. This will cause task_wait_event to receive a negative timeout value. Obviously it causes no harm to the current implementation, but should be fixed by being paranoid. BUG=none BRANCH=none TEST=make buildall Change-Id: Ib2817e1d95ca6c6eedcaff16a9e7e95033953901 Reviewed-on: https://chromium-review.googlesource.com/229760 Commit-Queue: Bernard Shyu <bernard_shyu@bizlinktech.com> Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Bernard Shyu <bernard_shyu@bizlinktech.com>
This commit is contained in:
committed by
chrome-internal-fetch
parent
1e9491e07d
commit
d5803a0269
@@ -2056,12 +2056,14 @@ void pd_task(void)
|
||||
* timeout value to wake up on the next state timeout.
|
||||
*/
|
||||
now = get_time();
|
||||
if (pd[port].timeout && now.val >= pd[port].timeout) {
|
||||
set_state(port, pd[port].timeout_state);
|
||||
/* On a state timeout, run next state soon */
|
||||
timeout = timeout < 10*MSEC ? timeout : 10*MSEC;
|
||||
} else if (pd[port].timeout - now.val < timeout) {
|
||||
timeout = pd[port].timeout - now.val;
|
||||
if (pd[port].timeout) {
|
||||
if (now.val >= pd[port].timeout) {
|
||||
set_state(port, pd[port].timeout_state);
|
||||
/* On a state timeout, run next state soon */
|
||||
timeout = timeout < 10*MSEC ? timeout : 10*MSEC;
|
||||
} else if (pd[port].timeout - now.val < timeout) {
|
||||
timeout = pd[port].timeout - now.val;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for disconnection */
|
||||
|
||||
Reference in New Issue
Block a user