summaryrefslogtreecommitdiff
path: root/libtreefs
diff options
context:
space:
mode:
Diffstat (limited to 'libtreefs')
-rw-r--r--libtreefs/dir-lookup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libtreefs/dir-lookup.c b/libtreefs/dir-lookup.c
index ce2acafd..8665059c 100644
--- a/libtreefs/dir-lookup.c
+++ b/libtreefs/dir-lookup.c
@@ -199,9 +199,12 @@ _treefs_s_dir_lookup (struct treefs_handle *h,
in the right order. */
if (strcmp (path, "..") != 0)
{
- pthread_mutex_unlock (&node->lock);
- pthread_mutex_lock (&dir->lock);
- pthread_mutex_lock (&node->lock);
+ if (pthread_mutex_trylock (&dir->lock))
+ {
+ pthread_mutex_unlock (&node->lock);
+ pthread_mutex_lock (&dir->lock);
+ pthread_mutex_lock (&node->lock);
+ }
}
else
pthread_mutex_lock (&dir->lock);