[Freeswitch-svn] [commit] r6119 - freeswitch/trunk/src/mod/endpoints/mod_opal

Freeswitch SVN lzwierko at freeswitch.org
Thu Nov 1 05:24:48 EDT 2007


Author: lzwierko
Date: Thu Nov  1 05:24:48 2007
New Revision: 6119

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
   freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp

Log:
mod_opal now loads and unloads without core dump, h323 endpoint seems to be established but call handling is yet to be implemented

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	Thu Nov  1 05:24:48 2007
@@ -109,6 +109,11 @@
         return s_startProcess;
     }
     
+    static bool checkInstanceExists()
+    {        
+        return s_startProcess!=NULL;
+    }
+    
     OpalStartProcess(
         const char* i_moduleName,
         switch_memory_pool_t *i_memoryPool,
@@ -116,7 +121,6 @@
     ):             
         PProcess("FreeSWITCH", "mod_opal"),
         m_pStopCondition(NULL),  
-        m_pWaitCondition(NULL),
         m_pModuleName(i_moduleName),
         m_pMemoryPool(i_memoryPool),
         m_pEndpointInterface(i_endpointInterface)
@@ -129,27 +133,17 @@
             {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not init stop condition.");
                 return;
-            }
-            
-            status = switch_thread_cond_create(&m_pWaitCondition, m_pMemoryPool);
-            assert(status==SWITCH_STATUS_SUCCESS);
-            if(status!=SWITCH_STATUS_SUCCESS) 
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not init wait condition.");
-                return;
-            }
+            }                        
             switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "OpalStartProcess created\n");
     }
         
     ~OpalStartProcess()
     {
-        switch_thread_cond_destroy(m_pWaitCondition);
         switch_thread_cond_destroy(m_pStopCondition);
                 
         m_pModuleName        = NULL;
         m_pMemoryPool        = NULL;
         m_pEndpointInterface = NULL; 
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "OpalStartProcess deleted\n");
     }
     
     FSOpalManager *getManager()
@@ -179,39 +173,16 @@
         }
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initilaized and running\n");       
         WaitUntilStopped();        
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "OpalStartProcess received stop signal\n");
-        delete m_pFSOpalManager;
-        m_pFSOpalManager = NULL;        
-        switch_thread_cond_signal(m_pWaitCondition); /* signal task waiting that it's all over ... */        
-    }
-        
-    /** 
-     * Waits until this process is terminated
-     * which means it exits Main() function
-     */
-    void WaitProcess()
-    {
-        switch_mutex_t* mutex = NULL;
-        switch_status_t status = switch_mutex_init(&mutex,SWITCH_MUTEX_NESTED,m_pMemoryPool);
-        if(status!=SWITCH_STATUS_SUCCESS)
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error acquiring mutex!\n");
-            assert(0);
-            return;
-        }
-        switch_mutex_lock(mutex);
-        switch_thread_cond_wait(m_pWaitCondition,mutex);
-        switch_mutex_unlock(mutex);
-        switch_mutex_destroy(mutex);        
-    }
+        delete m_pFSOpalManager;        
+        m_pFSOpalManager = NULL;                        
+    }        
     
     /** 
      * Waits until this process is terminated
      * which means it exits Main() function
      */
-    void StopProcessAndWait()
+    void StopProcess()
     {
-        switch_mutex_lock(m_pStopMutex)
         switch_thread_cond_signal(m_pStopCondition);
     }
     
@@ -245,11 +216,7 @@
       switch_memory_pool_t        *m_pMemoryPool;
       switch_endpoint_interface_t *m_pEndpointInterface;              
       FSOpalManager               *m_pFSOpalManager;
-      switch_thread_cond_t        *m_pStopCondition; /* the main thread waits on this condition until is to be stopped */
-      switch_thread_cond_t        *m_pWaitCondition; /* condition for managing thread to wait on until this process exits */
-      switch_mutex_t              *m_pStopMutex;
-      switch_mutex_t              *m_pWaitMutex;
-      
+      switch_thread_cond_t        *m_pStopCondition; /* the main thread waits on this condition until is to be stopped */      
         
 };
 OpalStartProcess* OpalStartProcess::s_startProcess = NULL;
@@ -325,8 +292,9 @@
 
 SWITCH_MODULE_RUNTIME_FUNCTION(mod_opal_runtime)
 {
-    OpalStartProcess::createInstance(modname,opal_pool,opalh323_endpoint_interface);
-    return SWITCH_STATUS_SUCCESS;
+    OpalStartProcess::createInstance(modname,opal_pool,opalh323_endpoint_interface);    
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"Opal runtime fun exit\n");
+    return SWITCH_STATUS_TERM;
 }
 
 /*
@@ -339,8 +307,12 @@
 {
     /* deallocate OPAL manager */
     
-    OpalStartProcess::getInstance()->StopProcess(); /* terminate process */
-    OpalStartProcess::getInstance()->WaitProcess(); /* wait here until stopped */
+    OpalStartProcess::getInstance()->StopProcess(); /* terminate process */    
+    while(OpalStartProcess::checkInstanceExists())
+    {
+        switch_yield(1000); /* wait 1s in each loop */
+    }
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"Opal shutdown succesfully\n");
     return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp	Thu Nov  1 05:24:48 2007
@@ -87,10 +87,10 @@
 {    
     /**
      *  Destroy all allocated resources, if any
+     *  !! all endpoints are automatically deleted in ~OpalManager, so leave them
      */
     if(m_isInitialized)
-    {
-        delete m_pH323Endpoint;
+    {                
         switch_mutex_destroy(m_pSessionsHashTableMutex);
         switch_core_hash_destroy(&m_pSessionsHashTable);
         
@@ -159,7 +159,7 @@
     ///TODO m_pH323Endpoint->SetVendorIdentifierInfo()
     
     ///TODO address should be configurable, should allow creaeing listeners on multiple interfaces
-    OpalTransportAddress opalTransportAddress("0.0.0.0",1720); //for time being create listener on all ip's and default port
+    OpalTransportAddress opalTransportAddress("localhost",1720); //for time being create listener on all ip's and default port
     if(!m_pH323Endpoint->StartListeners(opalTransportAddress))
     {
         assert(0);



More information about the Freeswitch-svn mailing list