< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Exception encountered when using reSIProcate in a multi-threaded program


Hi,
 
Let me first describe how i'm using reSIProcate (ver. 0.90.5019).
 
1. There is a global SipStack object available to all threads in the program.
2. There is one dedicated 'receiver' thread which is the one doing the following in a loop -
while (true)
{      
  FdSet fdset;
  g_sipStack.buildFdSet(fdset);
  int err = fdset.selectMilliSeconds(20);
  assert (err != -1);
  g_sipStack.process(fdset);
  SharedPtr<SipMessage> receivedMsg(g_sipStack.receive());
  if (receivedMsg == NULL) continue;
 
  ... Figure out what message this is ...
  ... Post a message to the thread that is handling this call...
}
3. There are many 'call' threads that are using the the global SipStack object and calling the send method on it (e.g. g_sipStack.send(*msgInvite),...). For now all they do is send an INVITE, wait for an OK, send an ACK and then send a BYE shortly after that and wait for the OK for the bye. Thats it.
4. When you run the program, it wil spawn a bunch of the above 'call' threads and will wait for them to run and exit.
 
So now, if i run my program in Debug mode, i encounter this exception after a few calls have already been made successfully -
"Assertion failed in TransactionState::processClientNonInvite - TransactionState.cxx, line 433".
The call stack is as follows - 'Receiver thread' is calling sipStack.process which is in turn calling TransactionController::process which then calls TransactionState::process which believes that the current state is - ClientNonInvite so it calls TransactionState::processClientNonInvite which then fails this assertion.
 
If i run this program in Release mode, then it works fine.
 
I'm guessing i'm not using the stack in the right way (for a multithreaded program). Can anyone help me here ?
 
thanks,
andy