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

[reSIProcate] exception thrown in lock.cxx line 28


Hi,

the exception thrown in lock.cxx line 28: myLockable.lock();

follow is the whole code:
 
// sip001.cpp 
//

#include <stdio.h>
#include <sstream>
#include <time.h>

#include "resip/stack/SipStack.hxx"
#include "resip/stack/SdpContents.hxx"
#include "resip/stack/SipMessage.hxx"
#include "resip/stack/ShutdownMessage.hxx"

#include "resip/dum/ClientAuthManager.hxx"
#include "resip/dum/ClientRegistration.hxx"
#include "resip/dum/DialogUsageManager.hxx"
#include "resip/dum/MasterProfile.hxx"
#include "resip/dum/RegistrationHandler.hxx"
#include "resip/dum/KeepAliveManager.hxx"
#include "resip/dum/ClientInviteSession.hxx"
#include "resip/dum/DumShutdownHandler.hxx"
#include "resip/dum/InviteSessionHandler.hxx"
#include "resip/dum/MasterProfile.hxx"
#include "resip/dum/ServerInviteSession.hxx"
#include "resip/dum/ServerOutOfDialogReq.hxx"
#include "resip/dum/OutOfDialogHandler.hxx"
#include "resip/dum/AppDialog.hxx"
#include "resip/dum/AppDialogSet.hxx"
#include "resip/dum/AppDialogSetFactory.hxx"

#include "rutil/Log.hxx"
#include "rutil/Logger.hxx"
#include "rutil/Subsystem.hxx"
#include "rutil/Random.hxx"

using namespace resip;
using namespace std;

// Generic InviteSessionHandler
class TestInviteSessionHandler : public InviteSessionHandler, public 
ClientRegistrationHandler, public OutOfDialogHandler
{
   public:
      Data name;
      bool registered;
      ClientRegistrationHandle registerHandle;
      
      TestInviteSessionHandler(const Data& n) : name(n), registered(false) 
      {
      }

      virtual ~TestInviteSessionHandler()
      {
      }
      
      virtual void onSuccess(ClientRegistrationHandle h, const SipMessage& 
response)
      {         
         registerHandle = h;   
         assert(registerHandle.isValid());         
         cout << name << ": ClientRegistration-onSuccess - " << 
response.brief() << endl;
         registered = true;
      }

      virtual void onFailure(ClientRegistrationHandle, const SipMessage& msg)
      {
         cout << name << ": ClientRegistration-onFailure - " << msg.brief() << 
endl;
         //throw;  // Ungracefully end
      }

      virtual void onRemoved(ClientRegistrationHandle)
      {
          cout << name << ": ClientRegistration-onRemoved" << endl;
      }

      virtual int onRequestRetry(ClientRegistrationHandle, int retrySeconds, 
const SipMessage& response)
      {
          cout << name << ": ClientRegistration-onRequestRetry (" << 
retrySeconds << ") - " << response.brief() << endl;
          return -1;
      }

      virtual void onNewSession(ClientInviteSessionHandle, 
InviteSession::OfferAnswerType oat, const SipMessage& msg)
      {
         cout << name << ": ClientInviteSession-onNewSession - " << msg.brief() 
<< endl;
      }
      
      virtual void onNewSession(ServerInviteSessionHandle, 
InviteSession::OfferAnswerType oat, const SipMessage& msg)
      {
         cout << name << ": ServerInviteSession-onNewSession - " << msg.brief() 
<< endl;
      }

      virtual void onFailure(ClientInviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": ClientInviteSession-onFailure - " << msg.brief() << 
endl;
      }
      
      virtual void onProvisional(ClientInviteSessionHandle, const SipMessage& 
msg)
      {
         cout << name << ": ClientInviteSession-onProvisional - " << 
msg.brief() << endl;
      }

      virtual void onConnected(ClientInviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": ClientInviteSession-onConnected - " << msg.brief() 
<< endl;
      }

      virtual void onStaleCallTimeout(ClientInviteSessionHandle handle)
      {
         cout << name << ": ClientInviteSession-onStaleCallTimeout" << endl;
      }

      virtual void onConnected(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onConnected - " << msg.brief() << 
endl;
      }

      virtual void onRedirected(ClientInviteSessionHandle, const SipMessage& 
msg)
      {
         cout << name << ": ClientInviteSession-onRedirected - " << msg.brief() 
<< endl;
      }

      virtual void onTerminated(InviteSessionHandle, 
InviteSessionHandler::TerminatedReason reason, const SipMessage* msg)
      {
         cout << name << ": InviteSession-onTerminated - " << msg->brief() << 
endl;
         assert(0); // This is overrideen in UAS and UAC specific handlers
      }

      virtual void onAnswer(InviteSessionHandle, const SipMessage& msg, const 
SdpContents& sdp)
      {
         cout << name << ": InviteSession-onAnswer(SDP)" << endl;
         //sdp->encode(cout);
      }

      virtual void onOffer(InviteSessionHandle is, const SipMessage& msg, const 
SdpContents& sdp)      
      {
         cout << name << ": InviteSession-onOffer(SDP)" << endl;
         //sdp->encode(cout);
      }

      virtual void onEarlyMedia(ClientInviteSessionHandle, const SipMessage& 
msg, const SdpContents& sdp)
      {
         cout << name << ": InviteSession-onEarlyMedia(SDP)" << endl;
         //sdp->encode(cout);
      }

      virtual void onOfferRequired(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onOfferRequired - " << msg.brief() << 
endl;
      }

      virtual void onOfferRejected(InviteSessionHandle, const SipMessage* msg)
      {
         cout << name << ": InviteSession-onOfferRejected" << endl;
      }

      virtual void onDialogModified(InviteSessionHandle, 
InviteSession::OfferAnswerType oat, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onDialogModified - " << msg.brief() 
<< endl;
      }

      virtual void onRefer(InviteSessionHandle, ServerSubscriptionHandle, const 
SipMessage& msg)
      {
         cout << name << ": InviteSession-onRefer - " << msg.brief() << endl;
      }

      virtual void onReferAccepted(InviteSessionHandle, 
ClientSubscriptionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onReferAccepted - " << msg.brief() << 
endl;
      }

      virtual void onReferRejected(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onReferRejected - " << msg.brief() << 
endl;
      }

      virtual void onInfo(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onInfo - " << msg.brief() << endl;
      }

      virtual void onInfoSuccess(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onInfoSuccess - " << msg.brief() << 
endl;
      }

      virtual void onInfoFailure(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onInfoFailure - " << msg.brief() << 
endl;
      }

      virtual void onMessage(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onMessage - " << msg.brief() << endl;
      }

      virtual void onMessageSuccess(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onMessageSuccess - " << msg.brief() 
<< endl;
      }

      virtual void onMessageFailure(InviteSessionHandle, const SipMessage& msg)
      {
         cout << name << ": InviteSession-onMessageFailure - " << msg.brief() 
<< endl;
      }

      virtual void onForkDestroyed(ClientInviteSessionHandle)
          {
         cout << name << ": ClientInviteSession-onForkDestroyed" << endl;
          }

      // Out-of-Dialog Callbacks
      virtual void onSuccess(ClientOutOfDialogReqHandle, const SipMessage& 
successResponse)
      {
          cout << name << ": ClientOutOfDialogReq-onSuccess - " << 
successResponse.brief() << endl;
      }
      virtual void onFailure(ClientOutOfDialogReqHandle, const SipMessage& 
errorResponse)
      {
          cout << name << ": ClientOutOfDialogReq-onFailure - " << 
errorResponse.brief() << endl;
      }
      virtual void onReceivedRequest(ServerOutOfDialogReqHandle ood, const 
SipMessage& request)
      {
          cout << name << ": ServerOutOfDialogReq-onReceivedRequest - " << 
request.brief() << endl;
          // Add SDP to response here if required
          cout << name << ": Sending 200 response to OPTIONS." << endl;
          ood->send(ood->answerOptions());
      }
};

class TestUac : public TestInviteSessionHandler
{
   public:
      bool done;
      SdpContents* sdp;     
      HeaderFieldValue* hfv;      
      Data* txt;      

      TestUac() 
         : TestInviteSessionHandler("UAC"), 
           done(false),
           sdp(0),
           hfv(0),
           txt(0)
      {
         txt = new Data("v=0\r\n"
                        "o=1900 369696545 369696545 IN IP4 192.168.2.15\r\n"
                        "s=X-Lite\r\n"
                        "c=IN IP4 192.168.2.15\r\n"
                        "t=0 0\r\n"
                        "m=audio 8000 RTP/AVP 8 3 98 97 101\r\n"
                        "a=rtpmap:8 pcma/8000\r\n"
                        "a=rtpmap:3 gsm/8000\r\n"
                        "a=rtpmap:98 iLBC\r\n"
                        "a=rtpmap:97 speex/8000\r\n"
                        "a=rtpmap:101 telephone-event/8000\r\n"
                        "a=fmtp:101 0-15\r\n");
         
         hfv = new HeaderFieldValue(txt->data(), txt->size());
         Mime type("application", "sdp");
         sdp = new SdpContents(hfv, type);
      }

      virtual ~TestUac()
      {
         delete sdp;
      }

      virtual void onOffer(InviteSessionHandle is, const SipMessage& msg, const 
SdpContents& sdp)      
      {
         cout << name << ": InviteSession-onOffer(SDP)" << endl;
         //sdp->encode(cout);
         is->provideAnswer(sdp);
      }

      virtual void onConnected(ClientInviteSessionHandle is, const SipMessage& 
msg)
      {
         cout << name << ": ClientInviteSession-onConnected - " << msg.brief() 
<< endl;
         cout << "Connected now - requestingOffer from UAS" << endl;
         is->requestOffer();
      }

      virtual void onTerminated(InviteSessionHandle, 
InviteSessionHandler::TerminatedReason reason, const SipMessage* msg)
      {
         cout << name << ": InviteSession-onTerminated - " << msg->brief() << 
endl;
         done = true;
      }
};


SipStack sip_stack;
int _tmain(int argc, _TCHAR* argv[])
{
        //Log::initialize(Log::File, Log::Stack, argv[0], "sip.log");

        //SipStack sip_stack;
        DialogUsageManager* dum = new DialogUsageManager( sip_stack );
        dum->addTransport( UDP, 12345 );
        
        SharedPtr<MasterProfile> profile( new MasterProfile );
        auto_ptr<ClientAuthManager> uaAuth( new ClientAuthManager );
        auto_ptr<KeepAliveManager> keepAlive(new KeepAliveManager);
        dum->setMasterProfile( profile );
        dum->setClientAuthManager( uaAuth );
        dum->setKeepAliveManager(keepAlive);

        TestUac uac;
        dum->setClientRegistrationHandler( &uac );
        dum->setInviteSessionHandler( &uac );
        dum->addOutOfDialogHandler( OPTIONS, &uac );

        //auto_ptr<AppDialogSetFactory> ua_dsf(new testAppDialogSetFactory);
        //dum->setAppDialogSetFactory(ua_dsf);

        NameAddr User = NameAddr( "sip:2201@xxxxxxxxxxxxxx" );
        //dum->getMasterProfile()->setOutboundProxy( 
Uri("sip:192.168.101.85:5060") );
        dum->getMasterProfile()->setDefaultFrom( User );
        dum->getMasterProfile()->setDefaultRegistrationTime(70);
        dum->getMasterProfile()->setDigestCredential(User.uri().host(), 
User.uri().user(), "");
        
        SipMessage& regMessage = dum->makeRegistration( User );
        
        cout << "Sending register for UA" << endl << endl << regMessage ;
        dum->send( regMessage );
        
        bool done = false;
        while ( ! done )
        {
                resip::FdSet fdset;

                sip_stack.buildFdSet( fdset );
                int err = fdset.selectMilliSeconds( 
sip_stack.getTimeTillNextProcessMS() );
                assert ( err != -1 );

                sip_stack.process( fdset );
                while( dum->process() );
        }   

        return 0;
}



---------- Forwarded message ----------
From: Scott Godin <slgodin@xxxxxxxxxxxx>
Date: 2005-11-3 上午10:27 
Subject: RE: [reSIProcate] (no subject)
To: maodonghu <hhmmdd@xxxxxxx>, resiprocate-devel 
<resiprocate-devel@xxxxxxxxxxxxxxxxxxx >

Sounds strange - where is the exception thrown?

-----Original Message-----
From: resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx 
[mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of maodonghu
Sent: Wednesday, November 02, 2005 8:24 PM
To: resiprocate-devel
Subject: [reSIProcate] (no subject)

Hi,

I am a fresh man on reSIProcate, now I encounter a problem in my program.
if the program written like this, it is good for work:

//--------------------------------------------------- 
int _tmain(int argc, _TCHAR* argv[])
{
       //Log::initialize(Log::Cout, Log::Stack, argv[0]);

       SipStack sip_stack;
       DialogUsageManager* dum = new DialogUsageManager( sip_stack );
       dum->addTransport( UDP, 12345 ); 


but if written like this, it will throw a exception:

//----------------------------------------------------
SipStack sip_stack;
int _tmain(int argc, _TCHAR* argv[])
{
       //Log::initialize(Log::Cout, Log::Stack, argv[0]); 


       DialogUsageManager* dum = new DialogUsageManager( sip_stack );
       dum->addTransport( UDP, 12345 );
       ...

I dont know why the sip_stack must be local ?

maodonghu
hhmmdd@xxxxxxx
2005-11-03

_______________________________________________
resiprocate-devel mailing list
resiprocate-devel@xxxxxxxxxxxxxxxxxxx 
https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel



        maodonghu
        hhmmdd@xxxxxxx
          2005-11-03