On 12/02/2014 05:51 PM, Bill Fischofer wrote:
On Tue, Dec 2, 2014 at 10:47 AM, Taras Kondratiuk
<[email protected] <mailto:[email protected]>> wrote:
+int odp_queue_destroy(odp_queue_t handle)
+{
+ queue_entry_t *queue;
+ queue = queue_to_qentry(handle);
+
Need to lock before this test. Otherwise have race condition if two
threads try to call odp_queue_destroy() at the same time. Both can
decide queue is not free and then both try to free it.
I assumed that queue destroying happens in a controlled manner from one
thread. Can move it under the lock.
+ if (queue->s.status == QUEUE_STATUS_FREE)
+ return -1; /* Queue is alredy freed */
+
+ LOCK(&queue->s.lock);
+ if (queue->s.head != NULL) {
+ UNLOCK(&queue->s.lock);
+ return -1; /* Queue is not empty */
+ }
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp