[PATCH BlueZ 2/3] shared/queue: Make queue_destroy safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This makes queue_destroy and queue_remove_all safe even if destroy
callback end up calling queue_remove.
---
 src/shared/queue.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/shared/queue.c b/src/shared/queue.c
index 6bfe995..0bf0bd3 100644
--- a/src/shared/queue.c
+++ b/src/shared/queue.c
@@ -329,6 +329,10 @@ unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function,
 
 		queue->entries -= count;
 	} else {
+		queue->head = NULL;
+		queue->tail = NULL;
+		queue->entries = 0;
+
 		while (entry) {
 			struct queue_entry *tmp = entry;
 
@@ -340,10 +344,6 @@ unsigned int queue_remove_all(struct queue *queue, queue_match_func_t function,
 			free(tmp);
 			count++;
 		}
-
-		queue->head = NULL;
-		queue->tail = NULL;
-		queue->entries = 0;
 	}
 
 	return count;
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux