diff mbox series

scan: call scan_finished() when periodic scans get aborted

Message ID 20221212211050.3109050-1-alvin@pqrs.dk (mailing list archive)
State New
Headers show
Series scan: call scan_finished() when periodic scans get aborted | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Alvin Šipraga Dec. 12, 2022, 9:10 p.m. UTC
From: Alvin Šipraga <alsi@bang-olufsen.dk>

The blamed commit argues that the periodic scan callback doesn't do
anything useful in the event of an aborted scan, but this is not
entirely true. In particular, the callback is responsible for re-arming
the periodic scan timer. Make sure to call scan_finished() so that iwd's
periodic scanning logic continues unabated even when a periodic scan is
aborted.

Also remove the periodic boolean member of struct scan_request, as it
serves no purpose anymore.

Fixes: 6051a1495227 ("scan: Don't callback on SCAN_ABORTED")
---
 src/scan.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

Comments

Denis Kenzior Dec. 12, 2022, 9:55 p.m. UTC | #1
Hi Alvin,

On 12/12/22 15:10, Alvin Šipraga wrote:
> From: Alvin Šipraga <alsi@bang-olufsen.dk>
> 
> The blamed commit argues that the periodic scan callback doesn't do
> anything useful in the event of an aborted scan, but this is not
> entirely true. In particular, the callback is responsible for re-arming
> the periodic scan timer. Make sure to call scan_finished() so that iwd's
> periodic scanning logic continues unabated even when a periodic scan is
> aborted.
> 
> Also remove the periodic boolean member of struct scan_request, as it
> serves no purpose anymore.
> 
> Fixes: 6051a1495227 ("scan: Don't callback on SCAN_ABORTED")
> ---
>   src/scan.c | 18 ++----------------
>   1 file changed, 2 insertions(+), 16 deletions(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/scan.c b/src/scan.c
index 5d2f2957748a..dbc46a754d16 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -83,7 +83,6 @@  struct scan_request {
 	bool canceled : 1; /* Is scan_cancel being called on this request? */
 	bool passive:1; /* Active or Passive scan? */
 	bool started : 1; /* Has TRIGGER_SCAN succeeded at least once? */
-	bool periodic : 1; /* Started as a periodic scan? */
 	/*
 	 * Set to true if the TRIGGER_SCAN command at the head of the 'cmds'
 	 * queue was acked by the kernel indicating that the scan request was
@@ -997,7 +996,6 @@  static void scan_periodic_destroy(void *user_data)
 static bool scan_periodic_queue(struct scan_context *sc)
 {
 	struct scan_parameters params = {};
-	struct scan_request *sr;
 
 	if (sc->sp.needs_active_scan && known_networks_has_hidden()) {
 		params.randomize_mac_addr_hint = true;
@@ -1015,13 +1013,7 @@  static bool scan_periodic_queue(struct scan_context *sc)
 					scan_periodic_notify, sc,
 					scan_periodic_destroy);
 
-	if (!sc->sp.id)
-		return false;
-
-	sr = l_queue_peek_tail(sc->requests);
-	sr->periodic = true;
-
-	return true;
+	return sc->sp.id != 0;
 }
 
 static bool scan_periodic_is_disabled(void)
@@ -2242,13 +2234,7 @@  static void scan_notify(struct l_genl_msg *msg, void *user_data)
 
 		if (sr->triggered) {
 			sr->triggered = false;
-
-			/* If periodic scan, don't report the abort */
-			if (sr->periodic) {
-				l_queue_remove(sc->requests, sr);
-				wiphy_radio_work_done(sc->wiphy, sr->work.id);
-			} else
-				scan_finished(sc, -ECANCELED, NULL, NULL, sr);
+			scan_finished(sc, -ECANCELED, NULL, NULL, sr);
 		} else if (wiphy_radio_work_is_running(sc->wiphy,
 							sr->work.id)) {
 			/*