diff mbox

[10/23] adapter: Clear timer handle when DEP timer stopped

Message ID 20170615182516.4508-11-mgreer@animalcreek.com (mailing list archive)
State Accepted
Delegated to: Samuel Ortiz
Headers show

Commit Message

Mark Greer June 15, 2017, 6:25 p.m. UTC
__near_adapter_set_dep_state() stops the neard DEP timer but
doesn't clear the timer handle.  This can cause neard to try
to stop the timer when it isn't running.  To fix that, clear
the handle so neard doesn't try to stop an already stopped timer.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
---
 src/adapter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/adapter.c b/src/adapter.c
index 7be87e2..eb1a407 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -615,8 +615,10 @@  int __near_adapter_set_dep_state(uint32_t idx, bool dep)
 		target_idx =  __neard_device_get_idx(adapter->device_link);
 		__near_adapter_remove_target(idx, target_idx);
 	} else {
-		if (adapter->dep_timer > 0)
+		if (adapter->dep_timer > 0) {
 			g_source_remove(adapter->dep_timer);
+			adapter->dep_timer = 0;
+		}
 
 		if (!__near_device_register_interface(adapter->device_link))
 			return -ENODEV;