commit d0ccb8496ac750daa22e6ea8f5f75d3c558acd91
parent e295b73c4c57616717b72745ddefc5519d97192d
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Mon, 11 Mar 2019 15:43:14 +0100
scan: Fix tracking external scans in sc->state
sc->state would get set when the TRIGGERED event arrived or when the
triggered callback for our own SCAN_TRIGGER command is received.
However it would not get reset to NOT_RUNNING when the NEW_SCAN_RESULTS
event is received, instead we'd first request the results with GET_SCAN
and only reset sc->state when that returns. If during that command a
new scan gets triggered, the GET_SCAN callback would still reset
sc->state and clobber the value set by the new scan.
To fix that repurpose sc->state to only track that period from the
TRIGGERED signal to the NEW_SCAN_RESULTS signal. sc->triggered can be
used to check if we're still waiting for the GET_SCAN command and
sc->start_cmd_id to check if we're waiting for the scan to get
triggered, so one of these three variables will now always indicate if
a scan is in progress.
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/scan.c b/src/scan.c
@@ -133,7 +133,6 @@ static void scan_request_failed(struct scan_context *sc,
sc->current_sr = NULL;
sc->triggered = false;
sc->start_cmd_id = 0;
- sc->state = SCAN_STATE_NOT_RUNNING;
l_queue_remove(sc->requests, sr);
if (sr->trigger)
@@ -470,7 +469,8 @@ static uint32_t scan_common(uint32_t ifindex, bool passive,
if (l_queue_length(sc->requests) > 0)
goto done;
- if (sc->state != SCAN_STATE_NOT_RUNNING || sc->start_cmd_id)
+ if (sc->state != SCAN_STATE_NOT_RUNNING ||
+ sc->start_cmd_id || sc->triggered)
goto done;
if (!scan_request_send_trigger(sc, sr))
@@ -748,7 +748,8 @@ static bool start_next_scan_request(struct scan_context *sc)
{
struct scan_request *sr;
- if (sc->state != SCAN_STATE_NOT_RUNNING || sc->start_cmd_id)
+ if (sc->state != SCAN_STATE_NOT_RUNNING ||
+ sc->start_cmd_id || sc->triggered)
return true;
while (!l_queue_isempty(sc->requests)) {
@@ -1199,7 +1200,6 @@ static void scan_finished(struct scan_context *sc, uint32_t wiphy,
scan_request_free(sr);
sc->triggered = false;
- sc->state = SCAN_STATE_NOT_RUNNING;
if (!start_next_scan_request(sc) && sc->sp.rearm)
scan_periodic_rearm(sc);
@@ -1370,6 +1370,8 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
struct l_genl_msg *scan_msg;
struct scan_results *results;
+ sc->state = SCAN_STATE_NOT_RUNNING;
+
if (scan_send_next_cmd(sc))
return;
@@ -1397,6 +1399,8 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
break;
case NL80211_CMD_SCAN_ABORTED:
+ sc->state = SCAN_STATE_NOT_RUNNING;
+
scan_finished(sc, attr_wiphy, -ECANCELED, NULL);
break;