[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] sort: fix two race conditions reported by valgrind.
From: |
Shayan Pooya |
Subject: |
[PATCH] sort: fix two race conditions reported by valgrind. |
Date: |
Mon, 13 Jan 2014 19:22:55 -0500 |
Valgrind reported two race conditions when I ran sort on a small file.
Both of them seem to be legitimate.
---
src/sort.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sort.c b/src/sort.c
index 3380be6..e6658e6 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -3354,8 +3354,8 @@ queue_insert (struct merge_node_queue *queue, struct merge_node *node)
pthread_mutex_lock (&queue->mutex);
heap_insert (queue->priority_queue, node);
node->queued = true;
- pthread_mutex_unlock (&queue->mutex);
pthread_cond_signal (&queue->cond);
+ pthread_mutex_unlock (&queue->mutex);
}
/* Pop the top node off the priority QUEUE, lock the node, return it. */
@@ -3950,7 +3950,7 @@ sort (char *const *files, size_t nfiles, char const *output_file,
sortlines (line, nthreads, buf.nlines, root,
&queue, tfp, temp_output);
queue_destroy (&queue);
- pthread_mutex_destroy (&root->lock);
+ pthread_mutex_destroy (&merge_tree->lock);
merge_tree_destroy (merge_tree);
}
else
--
1.8.4.2
- [PATCH] sort: fix two race conditions reported by valgrind.,
Shayan Pooya <=
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Pádraig Brady, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Shayan Pooya, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Shayan Pooya, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Pádraig Brady, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Pádraig Brady, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Shayan Pooya, 2014/01/13
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Pádraig Brady, 2014/01/22
- Re: [PATCH] sort: fix two race conditions reported by valgrind., Shayan Pooya, 2014/01/22