git » libjio » commit e0aa432

Allow pthread_mutex_lock()/unlock() to fail in the preloader.

author Alberto Bertogli
2005-03-10 04:51:39 UTC
committer Alberto Bertogli
2007-07-15 13:47:33 UTC
parent 6de638a5213d950e42aa74a28f4d69e3f33761da

Allow pthread_mutex_lock()/unlock() to fail in the preloader.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

bindings/preload/libjio_preload.c +8 -4

diff --git a/bindings/preload/libjio_preload.c b/bindings/preload/libjio_preload.c
index 6d201ec..fb9c7dd 100644
--- a/bindings/preload/libjio_preload.c
+++ b/bindings/preload/libjio_preload.c
@@ -108,26 +108,30 @@ static struct fd_entry fd_table[MAXFD];
  * catch out of bounds accesses */
 static inline int fd_lock(int fd)
 {
+	int r;
+
 	if (fd < 0 || fd >= MAXFD) {
 		printd("locking out of bounds fd %d\n", fd);
 		return 0;
 	}
 	//printd("L %d\n", fd);
-	pthread_mutex_lock(&(fd_table[fd].lock));
+	r = pthread_mutex_lock(&(fd_table[fd].lock));
 	//printd("OK %d\n", fd);
-	return 1;
+	return !r;
 }
 
 static inline int fd_unlock(int fd)
 {
+	int r;
+
 	if (fd < 0 || fd >= MAXFD) {
 		printd("unlocking out of bounds fd %d\n", fd);
 		return 0;
 	}
 	//printd("U %d\n", fd);
-	pthread_mutex_unlock(&(fd_table[fd].lock));
+	r = pthread_mutex_unlock(&(fd_table[fd].lock));
 	//printd("OK %d\n", fd);
-	return 1;
+	return !r;
 }