diff options
-rw-r--r-- | libdiskfs/dir-lookup.c | 9 | ||||
-rw-r--r-- | libtreefs/dir-lookup.c | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index 1efdf75c..923be033 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -310,9 +310,12 @@ diskfs_S_dir_lookup (struct protid *dircred, pthread_mutex_lock (&dnp->lock); else { - pthread_mutex_unlock (&np->lock); - pthread_mutex_lock (&dnp->lock); - pthread_mutex_lock (&np->lock); + if (pthread_mutex_trylock (&dnp->lock)) + { + pthread_mutex_unlock (&np->lock); + pthread_mutex_lock (&dnp->lock); + pthread_mutex_lock (&np->lock); + } } } } 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); |