Threading libsmbclient - a proposal.

Jeremy Allison jra at samba.org
Tue Apr 7 23:56:37 GMT 2009


On Tue, Apr 07, 2009 at 04:50:25PM -0700, Howard Chu wrote:
> Jeremy Allison wrote:
>> On Tue, Apr 07, 2009 at 04:15:26PM -0700, Howard Chu wrote:
>>>
>>> We often find the need for a trylock() op - fail immediately if the lock
>>> is in use, instead of waiting.
>>
>> I thought about that one, but I don't see an immediate need
>> for it in our code which will be mainly mutex locks around
>> globals.
>
> In that case, your prototype is deceptive - you advertise read locks and 
> write locks, which are typically held for the duration of a lengthy 
> operation, not just taken and released quickly. If you're only expecting 
> these locks to be used to essentially support atomic test-and-set, then 
> the RDLOCK and WRLOCK usage makes no sense.

Well the goal is to allow the implementation to be
upgraded at a later date to use pthread_rwlocks
without changing the external interface.

Hmmm. Although in that case you're right, the
interface doesn't work as we'd need to tell
create_lock what kind of lock we'll need.

Do you think it's worth widening the interface
now to include the reader/writer lock behaviour,
or cut it down to just provide simple mutex's
(which are all I think we'll need for the initial
work anyway).

If we go fully threaded at a later date we may
need to add rw locks then though...

Jeremy.


More information about the samba-technical mailing list