Exemplo n.º 1
0
SystemDSM::~SystemDSM() {
  for (std::set<DSMDisposable*>::iterator it=
	 gc_trash.begin(); it != gc_trash.end(); it++)
    delete *it;

#ifdef USE_MONITORING
  MONITORING_MARK_FINISHED(dummy_session.getLocalTag());
#endif

}
Exemplo n.º 2
0
bool AmSessionContainer::clean_sessions() {
  ds_mut.lock();
  DBG("Session cleaner starting its work\n");
  
  try {
    SessionQueue n_sessions;
    
    while(!d_sessions.empty()){
      
      AmSession* cur_session = d_sessions.front();
      d_sessions.pop();
      
      ds_mut.unlock();
      
      if(cur_session->is_stopped() && !cur_session->isProcessingMedia()){
	
	MONITORING_MARK_FINISHED(cur_session->getLocalTag().c_str());

	DBG("session [%p] has been destroyed\n",(void*)cur_session->_pid);
	delete cur_session;
      }
      else {
	DBG("session [%p] still running\n",(void*)cur_session->_pid);
	n_sessions.push(cur_session);
      }
      
      ds_mut.lock();
    }
    
    swap(d_sessions,n_sessions);
    
  }catch(std::exception& e){
    ERROR("exception caught in session cleaner: %s\n", e.what());
    throw; /* throw again as this is fatal (because unlocking the mutex fails!! */
  }catch(...){
    ERROR("unknown exception caught in session cleaner!\n");
    throw; /* throw again as this is fatal (because unlocking the mutex fails!! */
  }
  bool more = !d_sessions.empty();
  ds_mut.unlock();
  return more;
}
Exemplo n.º 3
0
string AmSessionContainer::startSessionUAC(const AmSipRequest& req, string& app_name, AmArg* session_params) {

  auto_ptr<AmSession> session;
  try {
    session.reset(createSession(req, app_name, session_params));
    if(session.get() != 0) {
      session->dlg->initFromLocalRequest(req);
      session->setCallgroup(req.from_tag);
      
      switch(addSession(req.from_tag,session.get())) {
	
      case AmSessionContainer::Inserted:
	// successful case
	break;
	
      case AmSessionContainer::ShutDown:
	throw AmSession::Exception(AmConfig::ShutdownModeErrCode,
				   AmConfig::ShutdownModeErrReason);
	
      case AmSessionContainer::AlreadyExist:
	throw AmSession::Exception(482,
				   SIP_REPLY_LOOP_DETECTED);
	
      default:
	ERROR("adding session to session container\n");
	throw string(SIP_REPLY_SERVER_INTERNAL_ERROR);
      }
      
      MONITORING_LOG5(req.from_tag, 
		      "app", app_name.c_str(),
		      "dir", "out",
		      "from", req.from.c_str(),
		      "to", req.to.c_str(),
		      "ruri", req.r_uri.c_str());
      
      if (int err = session->sendInvite(req.hdrs)) {
	ERROR("INVITE could not be sent: error code = %d.\n", err);
	AmEventDispatcher::instance()->delEventQueue(req.from_tag);
	MONITORING_MARK_FINISHED(req.from_tag.c_str());
	return "";
      }
      
      if (AmConfig::LogSessions) {      
	INFO("Starting UAC session %s app %s\n",
	     req.from_tag.c_str(), app_name.c_str());
      }
      try {
	session->start();
      } catch (...) {
	AmEventDispatcher::instance()->delEventQueue(req.from_tag);
	throw;
      }
    }
  } 
  catch(const AmSession::Exception& e){
    ERROR("%i %s\n",e.code,e.reason.c_str());
    return "";
  }
  catch(const string& err){
    ERROR("startSession: %s\n",err.c_str());
    return "";
  }
  catch(...){
    ERROR("unexpected exception\n");
    return "";
  }

  session.release();
  return req.from_tag;
}