[Osip] lock twice when kill transaction

OuyangWW oovoov008 at gmail.com
Wed Mar 4 12:48:29 CET 2009


On Wed, Mar 4, 2009 at 6:29 PM, Aymeric Moizard <jack at atosc.org> wrote:
>
> On Wed, 4 Mar 2009, OuyangWW wrote:
>
>> hi, everyone.
>>
>> I make a thread to check if there are transactions which is in
>> TERMINATED state and no event in its FIFO.
>> If so, the thread will kill the transaction with:
>> osip_transaction_free(tr);
>> osip_free(tr);
>>
>> Here comes the problem.
>> Before I check a transaction list, for example,
>> osip->osip_ict_transactions, I lock ict_fastmutex. I think it is
>> necessary.
>> But the function __osip_remove_ict_transaction() called by
>> osip_transaction_free() will lock it again.
>> So the thread will pause in __osip_remove_ict_transaction().
>>
>> How to solve this problem? Is it not necessary to lock ict_fastmutex
>> before we checking the state?
>
> In my multithread application, I have a user defined lock that
> I use to avoid such case.

Do you mean that we define a new lock to protect the transaction list?
But there are so many times the application access the list, for example,
adding events. Do we need to lock the list by ourselves when we need
 to add an event to an tr? I don't think it is a good idea... Or maybe
I misunderstand what you mean.
>
> For this specific case, I personnally check the state of transaction in the
> same thread used for calling the *execute* methods.

Here is my code,
In one thread, there are:
188         while(1)
189         {
190                 pthread_testcancel();
192                 osip_ict_execute(server->osip);
193                 osip_nict_execute(server->osip);
194                 osip_ist_execute(server->osip);
195                 osip_nist_execute(server->osip);
197         }

and in another thread:

240         while(1)
241         {
242                 pthread_testcancel();
244                 myapp_kill_ict(server->osip);
245                 myapp_kill_ist(server->osip);
246                 myapp_kill_nict(server->osip);
247                 myapp_kill_nist(server->osip);
248         }

In my opinion, it does not make any difference if we put these in the
same thread.
>
> Regards,
>
> Aymeric MOIZARD / ANTISIP
> amsip - http://www.antisip.com
> osip2 - http://www.osip.org
> eXosip2 - http://savannah.nongnu.org/projects/exosip/
>
>> thanks!
>> _______________________________________________
>> Osip mailing list
>> Osip at atosc.org
>> http://www.atosc.org/mailinglist/listinfo/osip
>>
>


More information about the Osip mailing list