You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by wh...@apache.org on 2005/05/27 12:26:00 UTC

cvs commit: ws-axis/c/src/transport/axis3 ChannelFactory.cpp ChannelFactory.hpp HTTPTransport.cpp HTTPTransportInstantiator.cpp

whitlock    2005/05/27 03:26:00

  Modified:    c/src/engine SOAPTransportFactory.cpp
               c/src/engine/client Call.cpp
               c/src/transport/axis3 ChannelFactory.cpp ChannelFactory.hpp
                        HTTPTransport.cpp HTTPTransportInstantiator.cpp
  Log:
  AXISCPP-657 Load the channel libraries during ModuleInitialize. This improves performance by avoiding unnecessary loading and unloading and solves stress test problems on AIX with dlopen. SOAPTransportFactory::initialize calls preloadChannels which is a C-style function on the transport library. preloadChannels calls ChannelFactory::preloadChannels which is static and so can be called long before the transport object exists.
  
  Revision  Changes    Path
  1.28      +11 -13    ws-axis/c/src/engine/SOAPTransportFactory.cpp
  
  Index: SOAPTransportFactory.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/engine/SOAPTransportFactory.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SOAPTransportFactory.cpp	13 May 2005 16:06:58 -0000	1.27
  +++ SOAPTransportFactory.cpp	27 May 2005 10:25:59 -0000	1.28
  @@ -69,22 +69,20 @@
               strcpy(s,m_pcLibraryPath);
               throw AxisEngineException(SERVER_ENGINE_LOADING_TRANSPORT_FAILED,  s);
           }
  -        else
  -        {
   #ifdef ENABLE_AXISTRACE
  -            // Load function to do lib level inits
  -            void (*initializeLibrary) (AxisTraceEntrypoints*);
  -            initializeLibrary = (void (*)(AxisTraceEntrypoints*))PLATFORM_GETPROCADDR(m_LibHandler, INIT_FUNCTION);
  +        // Load function to do lib level inits
  +        void (*initializeLibrary) (AxisTraceEntrypoints*);
  +        initializeLibrary = (void (*)(AxisTraceEntrypoints*))PLATFORM_GETPROCADDR(m_LibHandler, INIT_FUNCTION);
   
  -            if (initializeLibrary)
  -                 (*initializeLibrary)(AxisTrace::getTraceEntrypoints());
  +        if (initializeLibrary)
  +            (*initializeLibrary)(AxisTrace::getTraceEntrypoints());
   #endif
  -/*
  -            // Load functions that does start and stop of event loop
  -            m_startEventLoop = (void (*)(void))PLATFORM_GETPROCADDR(m_LibHandler, START_EVENT_LOOP_FUNCTION);
  -            m_stopEventLoop = (void (*)(void))PLATFORM_GETPROCADDR(m_LibHandler, STOP_EVENT_LOOP_FUNCTION);
  -*/
  -        }		
  +
  +		void (*preloadChannels) (char*, char*);
  +		preloadChannels = (void (*)(char*, char*))PLATFORM_GETPROCADDR(m_LibHandler, "preloadChannels");
  +		if (preloadChannels)
  +			(*preloadChannels)(g_pConfig->getAxisConfProperty( AXCONF_CHANNEL_HTTP), 
  +				g_pConfig->getAxisConfProperty( AXCONF_SSLCHANNEL_HTTP));
   	}
   	else
   	{
  
  
  
  1.110     +1 -15     ws-axis/c/src/engine/client/Call.cpp
  
  Index: Call.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/engine/client/Call.cpp,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- Call.cpp	25 May 2005 05:23:32 -0000	1.109
  +++ Call.cpp	27 May 2005 10:25:59 -0000	1.110
  @@ -394,22 +394,8 @@
   			}
   		}
   
  -        char * pcChannelHTTPLibraryPath = g_pConfig->getAxisConfProperty( AXCONF_CHANNEL_HTTP);
  -        char * pcChannelHTTPSSLLibraryPath = g_pConfig->getAxisConfProperty( AXCONF_SSLCHANNEL_HTTP);
  -        char * pcSSLChannelInfo = g_pConfig->getAxisConfProperty( AXCONF_SECUREINFO);
  -
  -        if( pcChannelHTTPLibraryPath)
  -		{
  -			m_nStatus = m_pTransport->setTransportProperty( CHANNEL_HTTP_DLL_NAME, pcChannelHTTPLibraryPath);
  -		}
  -
  -        if( strcmp( "Unknown", pcChannelHTTPSSLLibraryPath) != 0)
  -		{
  -			m_nStatus = m_pTransport->setTransportProperty( CHANNEL_HTTP_SSL_DLL_NAME, pcChannelHTTPSSLLibraryPath);
  -		}
  -
           m_pTransport->setEndpointUri( m_pcEndPointUri);
  -
  +        char * pcSSLChannelInfo = g_pConfig->getAxisConfProperty( AXCONF_SECUREINFO);
   		if( pcSSLChannelInfo && strlen( pcSSLChannelInfo) > 0)
   		{
   			char *	pszArgPtr = NULL;
  
  
  
  1.16      +88 -17    ws-axis/c/src/transport/axis3/ChannelFactory.cpp
  
  Index: ChannelFactory.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/ChannelFactory.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ChannelFactory.cpp	13 May 2005 16:06:59 -0000	1.15
  +++ ChannelFactory.cpp	27 May 2005 10:25:59 -0000	1.16
  @@ -32,6 +32,9 @@
   
   AXIS_CPP_NAMESPACE_START
   
  +#define MAXCHANNELS (int)MaxChannelCount
  +ChannelLibrary *ChannelFactory::m_ChannelLibrary[MAXCHANNELS] = {NULL,NULL};
  +
   ChannelFactory::ChannelFactory()
   {
   	for( int iCount = 0; iCount < (int) MaxChannelCount; iCount++)
  @@ -46,7 +49,7 @@
   {
   	for( int eChannelType = 0; eChannelType < (int) MaxChannelCount; eChannelType++)
   	{
  -		UnLoadChannelLibrary( (g_ChannelType) eChannelType, m_pChannel[eChannelType]);
  +		UnLoadChannelLibrary( (g_ChannelType) eChannelType);
   	}
   }
   
  @@ -54,11 +57,9 @@
   {
   	DLHandler	sLibHandler;
   	IChannel *	pChannel = NULL;
  -	int			iLibCount = 0;
  -
  -	iLibCount = (int) eChannelType;
  +	int			iLibCount = (int) eChannelType;
   
  -// Additional code added to block reloading of DLL if name has not changed.
  +    // Additional code added to block reloading of DLL if name has not changed.
   	if( m_pLibName[iLibCount] == NULL ||
   		strcmp( pcLibraryName, m_pLibName[iLibCount]) != 0)
   	{
  @@ -102,26 +103,23 @@
   			}
   #endif
   
  -// Additional code added to that when the user wants to load a different
  -// library from that which is already loaded, it will now allow the change.
  -			UnLoadChannelLibrary( eChannelType, m_pChannel[iLibCount]);
  +            // Additional code added to that when the user wants to load a different
  +            // library from that which is already loaded, it will now allow the change.
  +			UnLoadChannelLibrary(eChannelType);
                           
  -                        if (m_pLibName[iLibCount])
  -                        {
  -                            delete [] m_pLibName[iLibCount];
  -                            m_pLibName[iLibCount] = NULL;
  -                        }
  +            if (m_pLibName[iLibCount])
  +            {
  +                delete [] m_pLibName[iLibCount];
  +                m_pLibName[iLibCount] = NULL;
  +            }
   
   			m_pLibName[iLibCount] = new char[ strlen( pcLibraryName) + 1];
  -
   			strcpy( m_pLibName[iLibCount], pcLibraryName);
  -
   			m_LibHandler[iLibCount] = sLibHandler;
   
   			if( sCreate)
   			{
   				sCreate( &pChannel);
  -
   				m_pChannel[iLibCount] = pChannel;
   			}
   		}
  @@ -134,7 +132,7 @@
   	return pChannel;
   }
   
  -bool ChannelFactory::UnLoadChannelLibrary( g_ChannelType eChannelType, IChannel * pIChannel)
  +bool ChannelFactory::UnLoadChannelLibrary( g_ChannelType eChannelType)
   {
   	bool	bSuccess = false;
   	int		iLibIndex = (int) eChannelType;
  @@ -177,4 +175,77 @@
   	return bSuccess;
   }
   
  +void ChannelFactory::preloadChannels(char *unsecChannel, char *secChannel)
  +{
  +	if (unsecChannel && strcmp(unsecChannel,"Unknown")) preloadChannel(UnsecureChannel, unsecChannel);
  +	if (secChannel && strcmp(secChannel,"Unknown")) preloadChannel(SecureChannel, secChannel);
  +}
  +
  +void ChannelFactory::preloadChannel(g_ChannelType type, const char *pcLibraryName)
  +{
  +	int iLibCount = (int)type;
  +	ChannelLibrary *pCh = new ChannelLibrary();
  +
  +	pCh->m_Library = PLATFORM_LOADLIB( pcLibraryName);
  +	if( !pCh->m_Library)
  +	{
  +		delete pCh;
  +		throw HTTPTransportException( SERVER_TRANSPORT_LOADING_CHANNEL_FAILED, PLATFORM_LOADLIB_ERROR);
  +	}
  +
  +	pCh->m_Create = (CREATE_OBJECT3) PLATFORM_GETPROCADDR( pCh->m_Library, CREATE_FUNCTION3);
  +	pCh->m_Delete = (DELETE_OBJECT3) PLATFORM_GETPROCADDR( pCh->m_Library, DELETE_FUNCTION3);
  +	if (!pCh->m_Create || !pCh->m_Delete)
  +	{
  +		PLATFORM_UNLOADLIB( pCh->m_Library);
  +		delete pCh;
  +		char * pszErrorInfo = new char[ strlen( pcLibraryName) + 1];
  +		strcpy( pszErrorInfo, pcLibraryName);
  +		if( type == UnsecureChannel)
  +		{
  +			throw HTTPTransportException( SERVER_TRANSPORT_LOADING_CHANNEL_FAILED, pszErrorInfo);
  +		}
  +		else
  +		{
  +			throw HTTPTransportException( SERVER_TRANSPORT_LOADING_SSLCHANNEL_FAILED, pszErrorInfo);
  +		}
  +	}
  +
  +#ifdef ENABLE_AXISTRACE
  +	// Load function to do lib level inits
  +	void (*initializeLibrary) (AxisTraceEntrypoints*);
  +	initializeLibrary = (void (*)(AxisTraceEntrypoints*))PLATFORM_GETPROCADDR(pCh->m_Library, "initializeLibrary");
  +	if( initializeLibrary)
  +	{
  +		(*initializeLibrary) (AxisTrace::getTraceEntrypoints());
  +	}
  +#endif
  +	m_ChannelLibrary[iLibCount] = pCh;
  +}
  +
  +IChannel *ChannelFactory::createChannel(g_ChannelType type) 
  +{
  +	int iLibCount = (int)type;
  +	IChannel *pChannel = NULL;
  +	if (m_ChannelLibrary[iLibCount])
  +	{
  +		m_ChannelLibrary[iLibCount]->m_Create(&pChannel);
  +		m_pChannel[iLibCount] = pChannel;
  +	}
  +	return pChannel;
  +}
  +
  +void ChannelFactory::unloadChannels()
  +{
  +	for (int i=0; i<(int)MaxChannelCount; i++) 
  +	{
  +		if (m_ChannelLibrary[i])
  +		{
  +			PLATFORM_UNLOADLIB(m_ChannelLibrary[i]->m_Library);
  +			delete m_ChannelLibrary[i];
  +			m_ChannelLibrary[i] = NULL;
  +		}
  +	}
  +}
  +
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.7       +20 -4     ws-axis/c/src/transport/axis3/ChannelFactory.hpp
  
  Index: ChannelFactory.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/ChannelFactory.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ChannelFactory.hpp	23 Mar 2005 15:45:02 -0000	1.6
  +++ ChannelFactory.hpp	27 May 2005 10:25:59 -0000	1.7
  @@ -36,19 +36,35 @@
   
   typedef int (* CREATE_OBJECT3) (IChannel** inst);
   typedef int (* DELETE_OBJECT3) (IChannel* inst);
  +
   AXIS_CPP_NAMESPACE_START
  +
  +class ChannelLibrary
  +{
  +public:
  +	DLHandler m_Library;
  +	CREATE_OBJECT3 m_Create;
  +	DELETE_OBJECT3 m_Delete;
  +};
  +
   class ChannelFactory  
   {
   public:
   	ChannelFactory();
   	virtual ~ChannelFactory();
   	virtual IChannel * LoadChannelLibrary( g_ChannelType eChannelType, const char * pcLibraryName);
  -	virtual bool UnLoadChannelLibrary( g_ChannelType eChannelType, IChannel *);
  +	static void preloadChannels(char *unsecChannel, char *secChannel);
  +	static void unloadChannels();
  +	virtual IChannel *createChannel(g_ChannelType eChannelType);
   
   private:
  -	char *			m_pLibName[(int) MaxChannelCount];
  -	DLHandler		m_LibHandler[(int) MaxChannelCount];
  -	IChannel *		m_pChannel[(int) MaxChannelCount];
  +	static void preloadChannel(g_ChannelType eChannelType, const char *pcLibraryName);
  +	virtual bool UnLoadChannelLibrary( g_ChannelType eChannelType);
  +
  +	char *					m_pLibName[(int) MaxChannelCount];
  +	DLHandler				m_LibHandler[(int) MaxChannelCount];
  +	IChannel *				m_pChannel[(int) MaxChannelCount];
  +	static ChannelLibrary	*m_ChannelLibrary[(int) MaxChannelCount];
   };
   AXIS_CPP_NAMESPACE_END
   #endif 
  
  
  
  1.30      +2 -0      ws-axis/c/src/transport/axis3/HTTPTransport.cpp
  
  Index: HTTPTransport.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/HTTPTransport.cpp,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- HTTPTransport.cpp	25 May 2005 11:13:42 -0000	1.29
  +++ HTTPTransport.cpp	27 May 2005 10:25:59 -0000	1.30
  @@ -99,6 +99,8 @@
   #else
   	m_lChannelTimeout = 0;
   #endif
  +	m_pNormalChannel = m_pChannelFactory->createChannel(UnsecureChannel);
  +	m_pSecureChannel = m_pChannelFactory->createChannel(SecureChannel);
   }
   
   /*
  
  
  
  1.14      +7 -0      ws-axis/c/src/transport/axis3/HTTPTransportInstantiator.cpp
  
  Index: HTTPTransportInstantiator.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/HTTPTransportInstantiator.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HTTPTransportInstantiator.cpp	13 May 2005 16:06:59 -0000	1.13
  +++ HTTPTransportInstantiator.cpp	27 May 2005 10:25:59 -0000	1.14
  @@ -32,6 +32,7 @@
   #endif
   
   #include "HTTPTransport.hpp"
  +#include "ChannelFactory.hpp"
   
   // Instanciate functions for HTTPTransport instances.
   extern "C"
  @@ -71,6 +72,7 @@
       STORAGE_CLASS_INFO void uninitializeLibrary (void)
       {
           // Do uninit actions
  +		ChannelFactory::unloadChannels();
   
       }
   
  @@ -91,5 +93,10 @@
   #endif
   		return pszWhatAmI;
   	}
  +
  +	STORAGE_CLASS_INFO void preloadChannels(char *unsecChannel, char *secChannel)
  +	{
  +		ChannelFactory::preloadChannels(unsecChannel, secChannel);
  +	}
   }