[SCM] Samba Shared Repository - branch master updated

[email protected] (Jeremy Allison)
Newsgroups gmane.network.samba.cvs
Message-ID <[email protected]>
The branch, master has been updated
       via  275d9fc tdb: Fix mutexes on FreeBSD
       via  5ce95ab tdb: Only mmap the mutex area if not already mmap'ed
       via  a2843cf tdb: NULL out tdb->mutexes in tdb_mutex_munmap
      from  bdc049d ctdb-common: Drop CTDB's copy of sys_read() and sys_write()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 275d9fc7d943048c5e580e656b6ad85b8fc6cc14
Author: Volker Lendecke <[email protected]>
Date:   Mon Nov 21 21:00:01 2016 +0100

    tdb: Fix mutexes on FreeBSD
    
    susv4 on mmap has the following snippet:
    
    > The state of synchronization objects such as mutexes, semaphores,
    > barriers, and conditional variables placed in shared memory mapped
    > with MAP_SHARED becomes undefined when the last region in any process
    > containing the synchronization object is unmapped.
    
    This means we can't keep the mutex mmap area unmapped at any point
    in time.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12455
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Tue Nov 29 23:59:52 CET 2016 on sn-devel-144

commit 5ce95abf37d5646dd5a6ed9acc018f0ab5d1023c
Author: Volker Lendecke <[email protected]>
Date:   Mon Nov 21 20:58:08 2016 +0100

    tdb: Only mmap the mutex area if not already mmap'ed
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12455
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit a2843cfd4dca32ccb9e97f20a9119f131db3b9d1
Author: Volker Lendecke <[email protected]>
Date:   Mon Nov 21 20:56:55 2016 +0100

    tdb: NULL out tdb->mutexes in tdb_mutex_munmap
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12455
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/mutex.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c
index 280dec1..cac3916 100644
--- a/lib/tdb/common/mutex.c
+++ b/lib/tdb/common/mutex.c
@@ -603,12 +603,13 @@ int tdb_mutex_init(struct tdb_context *tdb)
 fail:
 	pthread_mutexattr_destroy(&ma);
 fail_munmap:
-	tdb_mutex_munmap(tdb);
 
 	if (ret == 0) {
 		return 0;
 	}
 
+	tdb_mutex_munmap(tdb);
+
 	errno = ret;
 	return -1;
 }
@@ -623,6 +624,10 @@ int tdb_mutex_mmap(struct tdb_context *tdb)
 		return 0;
 	}
 
+	if (tdb->mutexes != NULL) {
+		return 0;
+	}
+
 	ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FILE,
 		   tdb->fd, 0);
 	if (ptr == MAP_FAILED) {
@@ -636,13 +641,20 @@ int tdb_mutex_mmap(struct tdb_context *tdb)
 int tdb_mutex_munmap(struct tdb_context *tdb)
 {
 	size_t len;
+	int ret;
 
 	len = tdb_mutex_size(tdb);
 	if (len == 0) {
 		return 0;
 	}
 
-	return munmap(tdb->mutexes, len);
+	ret = munmap(tdb->mutexes, len);
+	if (ret == -1) {
+		return -1;
+	}
+	tdb->mutexes = NULL;
+
+	return 0;
 }
 
 static bool tdb_mutex_locking_cached;


-- 
Samba Shared Repository
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.