Andy Spitzer wrote:
> Woof!
>
> On Thu, 03 May 2007 14:11:39 -0400, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> wrote:
>> class SomeClass
>> {
>> OsMutex *lock;
>> int someMember;
>
> A non static member variable "lock" can only be used to protect other member
> variables of this object. It cannot protect the object itself (as you noted,
> if the object is destructed, so is the lock!).
>
> A second lock is required to protect the lifetime of the object. Often that
> lock would be a static member of the object. As it is static, it doesn't
> live within the object, and so is not subject to destruction. Of course,
> that means it serializes destruction of all objects of that class, not just
> this particular one.
>
> Essentually, either a second lock is required, or one must be assured that
> there are no other threads that could possibly access the object before it is
> destructed. I believe that much of sipX uses the later approach, although it
> seems to be an unwritten rule, and could possibly be violated. Locking
> "yourself" just before destruction seems like a good idea, but as you so
> rightly pointed out, it doesn't really work!
>
> --Woof!
> _______________________________________________
> sipxtapi-dev mailing list
> [email protected]
> List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/
>
In sipxtapiinternal.cpp there is gCallAccessLock , which is used to
protect deletion of call mutex. I introduced the same mechanism for
protecting subscription mutex, which is not yet comited, but elsewhere,
as you said this is not carried out, and the code relies on the fact
that nobody should be using the lock during deletion.
Jaro
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/