OpenLDAP
Up to top level
Build   Contrib   Development   Documentation   Historical   Incoming   Software Bugs   Software Enhancements   Web  

Logged in as guest

Viewing Build/7363
Full headers

From: cmikk@qwest.net
Subject: libmdb should use POSIX semaphores on non-apple BSD systems too.
Compose comment
Download message
State:
1 replies: 1
7 followups: 1 2 3 4 5 6 7

Major security issue: yes  no

Notes:

Notification:


Date: Wed, 22 Aug 2012 20:02:27 +0000
From: cmikk@qwest.net
To: openldap-its@OpenLDAP.org
Subject: libmdb should use POSIX semaphores on non-apple BSD systems too.
Full_Name: Chris Miikkelson
Version: 2.4.32
OS: FreeBSD
URL: 
Submission from: (NULL) (204.147.85.37)


mdb on BSD-derived systems other than OS X also needs to use POSIX semaphores
for inter-process synchronization. I was working around this by adding
"-D__APPLE__" to CFLAGS, but that could have side-effects on some systems. The
following patch tells mdb to use posix semaphores if either BSD or __APPLE__ is
defined, which seems like a more targeted fix.

http://mikk.net/~chris/patches/0001-Use-posix-semaphores-on-apple-and-bsd-systems.patch

Followup 1

Download message
Date: Wed, 22 Aug 2012 14:10:30 -0700
From: Howard Chu <hyc@symas.com>
To: cmikk@qwest.net
CC: openldap-its@OpenLDAP.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
cmikk@qwest.net wrote:
> Full_Name: Chris Miikkelson
> Version: 2.4.32
> OS: FreeBSD
> URL: 
> Submission from: (NULL) (204.147.85.37)
> 
> 
> mdb on BSD-derived systems other than OS X also needs to use POSIX
semaphores
> for inter-process synchronization. I was working around this by adding
> "-D__APPLE__" to CFLAGS, but that could have side-effects on some systems.
The
> following patch tells mdb to use posix semaphores if either BSD or
__APPLE__ is
> defined, which seems like a more targeted fix.
> 
> http://mikk.net/~chris/patches/0001-Use-posix-semaphores-on-apple-and-bsd-systems.patch
> 
> 
Thanks for the patch, applied.

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/



Followup 2

Download message
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Date: Wed, 29 Aug 2012 08:07:31 +0200
To: Chris Miikkelson <cmikk@qwest.net>
Cc: openldap-its@openldap.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
Please try this patch, I can't.  It's split up for readability.
Replace defined(BSD) in 1st patch with defined(__BSD__) or whatever,
see below.

  http://folk.uio.no/hbf/its7363-cleanup.txt

Also, maybe we can drop __APPLE__ - it may #define __BSD__ too.
ANDROID should be something like __ANDROID__.  I can't test either.


Explanation:

defined(BSD) breaks in strict ISO C mode.  Is there a symbol like
__BSD__ or __BSD to use instead?

Namespace-wise, "MDB_USE_POSIX_SEM" would be better.

MDB_FDATASYNC should not depend on USE_POSIX_SEM.

We can #ifndef PTHREAD_PROCESS_SHARED instead of BSD, unless someone
#define it without supporting it.  Not for MDB_FDATASYNC though.

-- 
Hallvard



Followup 3

Download message
Date: Tue, 28 Aug 2012 23:20:51 -0700
From: Howard Chu <hyc@symas.com>
To: h.b.furuseth@usit.uio.no
CC: openldap-its@openldap.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
h.b.furuseth@usit.uio.no wrote:
> We can #ifndef PTHREAD_PROCESS_SHARED instead of BSD, unless someone
> #define it without supporting it.  Not for MDB_FDATASYNC though.
> 
PTHREAD_PROCESS_SHARED is defined just about everywhere, that's not a useful
test. (You only discover at runtime that the mutex creation/init failed...)

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/



Followup 4

Download message
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Date: Wed, 29 Aug 2012 08:50:17 +0200
To: Howard Chu <hyc@symas.com>
Cc: openldap-its@openldap.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
Howard Chu writes:
> PTHREAD_PROCESS_SHARED is defined just about everywhere, that's not a
useful
> test. (You only discover at runtime that the mutex creation/init failed...)

Argh.  Oh well, we should only do the namespace cleanup, then.  __BSD__
symbols etc.

BTW, I think the lock file should contain a field indicating the sync
primitive type, so different compilations of MDB won't use different
sync primitives.  Which maybe also means we might as well pick the
primitive at runtime (try PTHREAD_PROCESS_SHARED first, then sem_open).

-- 
Hallvard



Followup 5

Download message
Date: Wed, 29 Aug 2012 09:27:24 -0500
From: Chris Mikkelson <cmikk@qwest.net>
To: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Cc: openldap-its@OpenLDAP.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
On Wed, Aug 29, 2012 at 08:07:31AM +0200, Hallvard Breien Furuseth wrote:
> We can #ifndef PTHREAD_PROCESS_SHARED instead of BSD, unless someone
> #define it without supporting it.  Not for MDB_FDATASYNC though.

The *BSD systems define PTHREAD_PROCESS_SHARED but do
not implement sharable pthread mutexes. The flag name
is part of the API, but implementation of the behavior
it requests is optional.

-- 
Chris Mikkelson  | Quidquid latine dictum sit, altum viditur
cmikk@qwest.net  | 



Followup 6

Download message
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Date: Sat, 1 Sep 2012 13:16:01 +0200
To: Chris Mikkelson <cmikk@qwest.net>
Cc: openldap-its@openldap.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
Chris Mikkelson writes:
> The *BSD systems define PTHREAD_PROCESS_SHARED but do
> not implement sharable pthread mutexes. The flag name
> is part of the API, but implementation of the behavior
> it requests is optional.

Yes, sorry about that.

How about something like a "__BSD" preprocessor symbol to replace
"BSD"?  There surely is one.  It'll start with an underscore
followed by either another underscore or an uppercase letter.

-- 
Hallvard



Followup 7

Download message
From: Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>
Date: Mon, 17 Sep 2012 16:28:32 +0200
To: Chris Mikkelson <cmikk@qwest.net>
cc: openldap-its@openldap.org
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD
 systems too.
I've cleaned up preprocessor names, and remove semaphores more
thoroughly - at init, and after ITS#7377 at at exit failure.

Anything else - like SysV semaphores - can wait until
someone shows up who cares about it.

-- 
Hallvard



Reply 1

Resend
From: Hallvard B Furuseth <openldap-its@OpenLDAP.org>
To: h.b.furuseth@usit.uio.no
Subject: Re: (ITS#7363) libmdb should use POSIX semaphores on non-apple BSD systems too.
Date: Mon Sep 17 15:04:38 2012
Oops, part of last message was for ITS#7364.

Up to top level
Build   Contrib   Development   Documentation   Historical   Incoming   Software Bugs   Software Enhancements   Web  

Logged in as guest


The OpenLDAP Issue Tracking System uses a hacked version of JitterBug

______________
© Copyright 2013, OpenLDAP Foundation, info@OpenLDAP.org