From: James Prestwood <prestwoj at gmail.com>
To: iwd at lists.01.org
Subject: [PATCH 4/4] wiphy: make wiphy work queue reentrancy safe
Date: Mon, 22 Nov 2021 12:44:25 -0800 [thread overview]
Message-ID: <20211122204425.3567479-4-prestwoj@gmail.com> (raw)
In-Reply-To: 20211122204425.3567479-1-prestwoj@gmail.com
[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]
Now both the do_work and destroy callback can safely insert new
work items without causing problems.
---
src/wiphy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/wiphy.c b/src/wiphy.c
index 58ed0a87..339e13ca 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -118,6 +118,7 @@ struct wiphy {
char regdom_country[2];
/* Work queue for this radio */
struct l_queue *work;
+ bool work_in_callback;
bool support_scheduled_scan:1;
bool support_rekey_offload:1;
@@ -1924,14 +1925,19 @@ static void wiphy_radio_work_next(struct wiphy *wiphy)
work->priority = INT_MIN;
l_debug("Starting work item %u", work->id);
+
+ wiphy->work_in_callback = true;
done = work->ops->do_work(work);
+ wiphy->work_in_callback = false;
if (done) {
work->id = 0;
l_queue_remove(wiphy->work, work);
+ wiphy->work_in_callback = true;
destroy_work(work);
+ wiphy->work_in_callback = false;
wiphy_radio_work_next(wiphy);
}
@@ -1961,7 +1967,7 @@ uint32_t wiphy_radio_work_insert(struct wiphy *wiphy,
l_queue_insert(wiphy->work, item, insert_by_priority, NULL);
- if (l_queue_length(wiphy->work) == 1)
+ if (l_queue_length(wiphy->work) == 1 && !wiphy->work_in_callback)
wiphy_radio_work_next(wiphy);
return item->id;
@@ -1999,7 +2005,9 @@ void wiphy_radio_work_done(struct wiphy *wiphy, uint32_t id)
item->id = 0;
+ wiphy->work_in_callback = true;
destroy_work(item);
+ wiphy->work_in_callback = false;
if (next)
wiphy_radio_work_next(wiphy);
--
2.31.1
reply other threads:[~2021-11-22 20:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211122204425.3567479-4-prestwoj@gmail.com \
--to=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox