From 8e44760c34bd40305d2c07d719c45298e52e2bb7 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 26 Feb 2019 15:28:58 -0800 Subject: [PATCH] scan: Fix scan request retry logic While triggering scan, we leave the scan command in the queue, so it can be replayed in the case of a busy device. --- src/scan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scan.c b/src/scan.c index 5033a5b6..546e7264 100644 --- a/src/scan.c +++ b/src/scan.c @@ -262,7 +262,9 @@ static void scan_request_triggered(struct l_genl_msg *msg, void *userdata) sc->state = sr->passive ? SCAN_STATE_PASSIVE : SCAN_STATE_ACTIVE; l_debug("%s scan triggered for ifindex: %u", sr->passive ? "Passive" : "Active", sc->ifindex); + sc->triggered = true; + l_genl_msg_unref(l_queue_pop_head(sr->cmds)); if (sr->trigger) { sr->trigger(0, sr->userdata); @@ -446,7 +448,7 @@ static void scan_cmds_add(struct l_queue *cmds, struct scan_context *sc, static int scan_request_send_next(struct scan_context *sc, struct scan_request *sr) { - struct l_genl_msg *cmd = l_queue_pop_head(sr->cmds); + struct l_genl_msg *cmd = l_queue_peek_head(sr->cmds); if (!cmd) return -ENOMSG; @@ -457,7 +459,6 @@ static int scan_request_send_next(struct scan_context *sc, return 0; } - l_genl_msg_unref(cmd); return -EIO; }