Hello everyone,
I have a question regarding the nua_respond() function.

I have encountered a problem with this construct:


void doSomething()
{
  std::string message;

  switch()
  {
    case a: message = "something"; break;
    case b: message = "soemthing else"; break;
  }

  nua_respond(nh, status, message.c_str());

  return;
}

It sometimes happens that the string gets destroyed before the actual
message gets sent and as a result the SIP message contains random data.

In this case the easy remedy is to use const char* instead of
std::string, but if I wanted to use dynamic data, I am out of luck. I
presume that there is some internal queue that holds these request
before sending them and this queue does not copy the data provided and
use supplied pointers instead.

My question is what should I do if I want to pass dynamically
constructed data tu nua_respond (and maybe some other) function? Should
I allocate the data and free them when the conection is closed? [Not a
big fan of this approach.] Or is there some event that is going to tell
me - your structure is ready to be released? Or have I missed someting
obvious?

Thank you for your answer

Regards
Martin

-- 
  Martin Drasar, Developer / Analyst
  OptimSys, s.r.o.
  dra...@optimsys.cz
  Tel: +420 541 143 065
  Fax: +420 541 143 066
  http://www.optimsys.cz


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to