Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0
@ 2020-05-31  0:56 Andrew Zaborowski
  2020-05-31  0:56 ` [PATCH 2/2] frame-xchg: Use frame_watch_group_match in frame_watch_group_get Andrew Zaborowski
  2020-06-04 14:19 ` [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2020-05-31  0:56 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

Don't match the default group's (group_id 0) wdev_id against the
provided wdev_id because the default group can be used on all wdevs and
its wdev_id is 0.  Also match individual item's wdev_id in the group to
make up for this although it normally wouldn't matter.
---
 src/frame-xchg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/frame-xchg.c b/src/frame-xchg.c
index 4c950fd3..44711997 100644
--- a/src/frame-xchg.c
+++ b/src/frame-xchg.c
@@ -661,6 +661,7 @@ bool frame_watch_wdev_remove(uint64_t wdev_id)
 }
 
 struct frame_watch_handler_check_info {
+	uint64_t wdev_id;
 	frame_watch_cb_t handler;
 	void *user_data;
 };
@@ -671,7 +672,8 @@ static bool frame_watch_item_remove_by_handler(void *data, void *user_data)
 		l_container_of(data, struct frame_watch, super);
 	struct frame_watch_handler_check_info *info = user_data;
 
-	if (watch->super.notify != info->handler ||
+	if (watch->wdev_id != info->wdev_id ||
+			watch->super.notify != info->handler ||
 			watch->super.notify_data != info->user_data)
 		return false;
 
@@ -702,9 +704,9 @@ static bool frame_watch_remove_by_handler(uint64_t wdev_id, uint32_t group_id,
 						void *user_data)
 {
 	struct watch_group_match_info group_info =
-		{ wdev_id, group_id };
+		{ group_id == 0 ? 0 : wdev_id, group_id };
 	struct frame_watch_handler_check_info handler_info =
-		{ handler, user_data };
+		{ wdev_id, handler, user_data };
 	struct watch_group *group = l_queue_find(watch_groups,
 						frame_watch_group_match,
 						&group_info);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] frame-xchg: Use frame_watch_group_match in frame_watch_group_get
  2020-05-31  0:56 [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Andrew Zaborowski
@ 2020-05-31  0:56 ` Andrew Zaborowski
  2020-06-04 14:19 ` [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2020-05-31  0:56 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2056 bytes --]

---
 src/frame-xchg.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/frame-xchg.c b/src/frame-xchg.c
index 44711997..f713c07e 100644
--- a/src/frame-xchg.c
+++ b/src/frame-xchg.c
@@ -439,21 +439,30 @@ err:
 	return NULL;
 }
 
-static struct watch_group *frame_watch_group_get(uint64_t wdev_id, uint32_t id)
+struct watch_group_match_info {
+	uint64_t wdev_id;
+	uint32_t id;
+};
+
+static bool frame_watch_group_match(const void *a, const void *b)
 {
-	const struct l_queue_entry *entry;
-	struct watch_group *group;
+	const struct watch_group *group = a;
+	const struct watch_group_match_info *info = b;
 
-	for (entry = l_queue_get_entries(watch_groups); entry;
-			entry = entry->next) {
-		group = entry->data;
+	return group->wdev_id == info->wdev_id && group->id == info->id;
+}
 
-		if (group->id == id && (id == 0 || group->wdev_id == wdev_id))
-			return group;
+static struct watch_group *frame_watch_group_get(uint64_t wdev_id, uint32_t id)
+{
+	struct watch_group_match_info info = { id == 0 ? 0 : wdev_id, id };
+	struct watch_group *group = l_queue_find(watch_groups,
+						frame_watch_group_match, &info);
+
+	if (!group) {
+		group = frame_watch_group_new(wdev_id, id);
+		l_queue_push_tail(watch_groups, group);
 	}
 
-	group = frame_watch_group_new(wdev_id, id);
-	l_queue_push_tail(watch_groups, group);
 	return group;
 }
 
@@ -590,19 +599,6 @@ bool frame_watch_add(uint64_t wdev_id, uint32_t group_id, uint16_t frame_type,
 	return true;
 }
 
-struct watch_group_match_info {
-	uint64_t wdev_id;
-	uint32_t id;
-};
-
-static bool frame_watch_group_match(const void *a, const void *b)
-{
-	const struct watch_group *group = a;
-	const struct watch_group_match_info *info = b;
-
-	return group->wdev_id == info->wdev_id && group->id == info->id;
-}
-
 bool frame_watch_group_remove(uint64_t wdev_id, uint32_t group_id)
 {
 	struct watch_group_match_info info = { wdev_id, group_id };
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0
  2020-05-31  0:56 [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Andrew Zaborowski
  2020-05-31  0:56 ` [PATCH 2/2] frame-xchg: Use frame_watch_group_match in frame_watch_group_get Andrew Zaborowski
@ 2020-06-04 14:19 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2020-06-04 14:19 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

Hi Andrew,

On 5/30/20 7:56 PM, Andrew Zaborowski wrote:
> Don't match the default group's (group_id 0) wdev_id against the
> provided wdev_id because the default group can be used on all wdevs and
> its wdev_id is 0.  Also match individual item's wdev_id in the group to
> make up for this although it normally wouldn't matter.
> ---
>   src/frame-xchg.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 

Both applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-04 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-31  0:56 [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Andrew Zaborowski
2020-05-31  0:56 ` [PATCH 2/2] frame-xchg: Use frame_watch_group_match in frame_watch_group_get Andrew Zaborowski
2020-06-04 14:19 ` [PATCH 1/2] frame-xchg: Fix frame_watch_remove_by_handler for group 0 Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox