[Libguestfs] [nbdkit PATCH 3/4] plugins: Check for mutex failures

Eric Blake eblake at redhat.com
Wed Apr 24 22:24:40 UTC 2019


Commit 9ceb4712 argued that for simple lock/unlock sequences, it was
easier to avoid the cleanup.h macros. But since that time, we added
additional sanity checking to the macros, at which point the
boilerplate of inlining that sanity checking is outweighed compared to
just using the macro in the last remaining bare use.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 plugins/file/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/file/file.c b/plugins/file/file.c
index ebfb71d..d2bab9c 100644
--- a/plugins/file/file.c
+++ b/plugins/file/file.c
@@ -529,9 +529,8 @@ file_can_extents (void *handle)
   /* A simple test to see whether SEEK_HOLE etc is likely to work on
    * the current filesystem.
    */
-  pthread_mutex_lock (&lseek_lock);
+  ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lseek_lock);
   r = lseek (h->fd, 0, SEEK_HOLE);
-  pthread_mutex_unlock (&lseek_lock);
   if (r == -1) {
     nbdkit_debug ("extents disabled: lseek: SEEK_HOLE: %m");
     return 0;
-- 
2.20.1




More information about the Libguestfs mailing list