[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#4662) ldap_create needs lock?

hyc@symas.com wrote:
> volz@cisco.com wrote:
>> Full_Name: Bernie Volz
>> Version: All
>> OS: Linux
>> URL: ftp://ftp.openldap.org/incoming/
>> Submission from: (NULL) (
>> In ldap_create, if multiple threads are calling ldap_init (or one of the other
>> initialization functions), they may compete to initialize the global options and
>> this results in a segmentation fault.
>> Shouldn't the above code be conditionalized on LDAP_R_COMPILE and use a static
>> global mutex to assure that only one thread is testing and potentially
>> initializing the global options.
> Unfortunately static mutex initializers are non-portable. I guess for 
> gcc we could arrange to have a constructor do the initialization, but 
> it's not clear what we can do for the more general case.
As far as I can tell, calling pthread_once() would be the "right" thing 
to do.  I have no clue
whether it's as portable as we need, though.


Ing. Pierangelo Masarati
OpenLDAP Core Team

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
Office:   +39.02.23998309
Mobile:   +39.333.4963172
Email:    pierangelo.masarati@sys-net.it