src/adv_monitor: Remove checking in device lost timeout
authorYun-Hao Chung <howardchung@chromium.org>
Mon, 28 Jun 2021 03:35:42 +0000 (11:35 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:36 +0000 (19:08 +0530)
commitf8fd04f17bacf375caf0a4761beec5ce055e964e
treea8d037fa63c768256b197b232eb82ffb8809fbf0
parent953d9bc294a664ea5b5100eaf58527d7813914ba
src/adv_monitor: Remove checking in device lost timeout

The time check in device lost timeout could cause DeviceLost never being
reported because of the following reasons:

1. Timer created in timeout_add_seconds, which calls
   g_timeout_add_seconds_full internally, can be fired one second
   earlier than |timeout| seconds.
2. When handle_device_lost_timeout is invoked early, time diff between
   |curr_time| and |last_seen| could be less than |low_rssi_timeout|. In
   this case, since handle_device_lost always returns FALSE, the
   timer will be removed, but DeviceLost has not been reported yet.
3. If we never receives any advertisement from that peer since then,
   DeviceLost will never be reported.

We can remove the checking in handle_device_lost_time because we restart
or remove the timer whenever an advertisement is received.

Reviewed-by: apusaka@chromium.org
Reviewed-by: mcchou@chromium.org
Reviewed-by: mmandlik@chromium.org
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adv_monitor.c