tdb API issues

Howard Chu hyc at highlandsun.com
Fri Apr 3 17:00:24 GMT 2009


Jeremy Allison wrote:
> On Thu, Apr 02, 2009 at 07:30:45PM -0700, Howard Chu wrote:
>>
>> I'm not sure what's the point of OpenSSL asking the caller to pre-create
>> some number of global locks; IMO the library should create whatever locks
>> it needs and the caller shouldn't know about them at all. That's more the
>> flavor of the approach I took, otherwise it's basically the same: the
>> caller must call tdb_set_mutex() and provide it a structure which
>> contains a table of mutex function pointers. The tdb_set_mutex() function
>> will then create whatever locks it needs.
>
> The reason it's easier to have the locks pre-created is you don't
> then need to add lock initialization functions to existing code that
> doesn't currently have an initialization call. We have a lot of old
> global state that has no concept of locking so it makes it very easy
> to add lock calls for global locks you know must already exist.

Sure, but that should be the library's responsibility. When a caller provides 
you set of mutex methods, you should at that point create whatever global 
locks you're going to need. (Which is what tdb_set_mutex() does - it checks 
the provided set of methods and then goes about creating the globals. Of 
course at that point in time, I only had 1 global...) I.e., the moment that a 
caller gives you a set of mutex methods *is* the lock initialization call for 
the entire library, you don't need any further initialization functions.

> I'm assuming this is why openssl did this as well.

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


More information about the samba-technical mailing list