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 na...@apache.org on 2007/02/20 06:22:24 UTC
svn commit: r509427 - in /webservices/axis/trunk/c: include/axis/client/
src/cbindings/client/ src/engine/client/ src/transport/
src/transport/axis3/ src/xml/xerces/ tests/auto_build/testcases/client/cpp/
tests/auto_build/testcases/output/
Author: nadiramra
Date: Mon Feb 19 21:22:19 2007
New Revision: 509427
URL: http://svn.apache.org/viewvc?view=rev&rev=509427
Log:
AXISCPP-1021 - Connections not being closed - resulting in unused connections over time
Modified:
webservices/axis/trunk/c/include/axis/client/Call.h
webservices/axis/trunk/c/include/axis/client/Call.hpp
webservices/axis/trunk/c/src/cbindings/client/CallC.cpp
webservices/axis/trunk/c/src/engine/client/Call.cpp
webservices/axis/trunk/c/src/transport/SOAPTransport.h
webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp
webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp
webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/ConnectionCloseClient.cpp
webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose.cpp.out
webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose_ServerResponse.expected
Modified: webservices/axis/trunk/c/include/axis/client/Call.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Call.h?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Call.h (original)
+++ webservices/axis/trunk/c/include/axis/client/Call.h Mon Feb 19 21:22:19 2007
@@ -115,6 +115,9 @@
const char * axiscCallGetTransportProperty(AXISCHANDLE call, const char * key,
AxiscBool response);
+AXISC_STORAGE_CLASS_INFO
+void axiscCloseTransportConnection(AXISCHANDLE call);
+
/**
* Set a handler property. This adds a new property to a list of properties
* that a handler can access when it is invoked.
Modified: webservices/axis/trunk/c/include/axis/client/Call.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Call.hpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Call.hpp (original)
+++ webservices/axis/trunk/c/include/axis/client/Call.hpp Mon Feb 19 21:22:19 2007
@@ -115,6 +115,11 @@
*/
const char * AXISCALL getTransportProperty( const char * key,
bool response = true);
+
+ /**
+ * Close the transport connection to the server, if active.
+ */
+ void closeTransportConnection() { closeConnection(); }
/**
* Set a handler property. This adds a new property to a list of properties
@@ -1769,8 +1774,8 @@
*/
void processSoapFault(AxisException *e, void *exceptionHandlerFp);
-private:
- void closeConnection();
+private:
+ void closeConnection(bool forceClose=true);
int makeArray();
void cleanup(); // clean memory in case of exceptions and destructor etc.
void resetSoapFaultList(); // added in support of C-binding implementation.
Modified: webservices/axis/trunk/c/src/cbindings/client/CallC.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/client/CallC.cpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/client/CallC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/client/CallC.cpp Mon Feb 19 21:22:19 2007
@@ -169,6 +169,28 @@
return (char *)NULL;
}
+AXISC_STORAGE_CLASS_INFO
+void axiscCloseTransportConnection(AXISCHANDLE call)
+{
+ Call *c = (Call*)call;
+
+ try
+ {
+ c->closeTransportConnection();
+ }
+ catch ( AxisException& e )
+ {
+
+ processException(c, e);
+ }
+ catch ( ... )
+ {
+
+
+ axiscAxisInvokeExceptionHandler(-1, "Unrecognized exception thrown.", NULL, NULL);
+ }
+}
+
AXISC_STORAGE_CLASS_INFO
int axiscCallSetHandlerProperty(AXISCHANDLE call,
AxiscChar * name,
Modified: webservices/axis/trunk/c/src/engine/client/Call.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/engine/client/Call.cpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/engine/client/Call.cpp (original)
+++ webservices/axis/trunk/c/src/engine/client/Call.cpp Mon Feb 19 21:22:19 2007
@@ -78,11 +78,6 @@
else
m_nStatus = m_pAxisEngine->initialize ();
}
- catch( AxisException& e)
- {
- cleanup();
- throw AxisGenException( e.getExceptionCode(), e.what());
- }
catch(...)
{
cleanup();
@@ -114,21 +109,17 @@
void Call::cleanup()
{
- if (m_pContentIdSet)
- delete m_pContentIdSet;
+ delete m_pContentIdSet;
m_pContentIdSet = NULL;
if (m_pTransport)
SOAPTransportFactory::destroyTransportObject(m_pTransport);
m_pTransport = NULL;
- if (m_pAxisEngine)
- delete m_pAxisEngine;
+ delete m_pAxisEngine;
m_pAxisEngine = NULL;
- if (m_pcEndPointUri)
- delete [] m_pcEndPointUri;
-
+ delete [] m_pcEndPointUri;
m_pcEndPointUri = NULL;
}
@@ -352,7 +343,7 @@
}
}
- closeConnection();
+ closeConnection(false);
return AXIS_SUCCESS;
}
@@ -407,21 +398,10 @@
}
}
else
- {
- try
- {
- iSuccess = m_pTransport->setTransportProperty( type, value);
- }
- catch( AxisException& e)
- {
- throw AxisGenException(e.getExceptionCode(), e.what());
- }
- }
+ iSuccess = m_pTransport->setTransportProperty( type, value);
if( iSuccess < 0)
- {
throw AxisGenException( -iSuccess, m_pTransport->getLastChannelError());
- }
return iSuccess;
}
@@ -447,10 +427,10 @@
/*
* This method closes the connection of this object to the server
*/
-void Call::closeConnection()
+void Call::closeConnection(bool forceClose)
{
if (m_pTransport)
- m_pTransport->closeConnection();
+ m_pTransport->closeConnection(forceClose);
}
void Call::setSOAPVersion (SOAP_VERSION version)
Modified: webservices/axis/trunk/c/src/transport/SOAPTransport.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/transport/SOAPTransport.h?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/transport/SOAPTransport.h (original)
+++ webservices/axis/trunk/c/src/transport/SOAPTransport.h Mon Feb 19 21:22:19 2007
@@ -230,11 +230,18 @@
* Else returns AXIS_FAIL
*/
virtual int openConnection()=0;
+
/**
* @brief Closes the connection established with OpenConnection.
+ * @param forceClose whether or not to force a close. If true,
+ * the connection will be closed. If false, the transport
+ * will determine whether connection should be closed based
+ * on transport dependent properties. For example,
+ * HTTP transport may use HTTP header "Connection: close"
+ * to determine if connection should be closed.
* @example AxisTransport.h
*/
- virtual void closeConnection()=0;
+ virtual void closeConnection(bool forceClose=true)=0;
/**
* Sets a predefined transport property to be included in the outgoing
Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp Mon Feb 19 21:22:19 2007
@@ -115,7 +115,7 @@
~HTTPTransport()
{
delete [] m_pcEndpointUri;
- delete m_pChannelFactory;
+ delete m_pChannelFactory; // should also destroy channels
delete [] m_pszRxBuffer;
}
@@ -143,20 +143,15 @@
void HTTPTransport::
setEndpointUri( const char * pcEndpointUri) throw (HTTPTransportException)
{
- bool bUpdateURL = true;
-
// if URI not valid, return
if (!pcEndpointUri || strlen(pcEndpointUri) < strlen("http://") )
return;
// Does the new URI equal the existing channel URI?
- if( m_pActiveChannel != NULL && m_pActiveChannel->getURL())
- if( strcmp (m_pActiveChannel->getURL (), pcEndpointUri) == 0)
- bUpdateURL = false;
-
- // If there is a new URI, then this flag will be set. A secure or unsecure channel
- // will be set. If the required channel is not available, an exception will be thrown.
- if( bUpdateURL)
+ // If there is a new URI, then connection will be closed and a secure or unsecure channel
+ // will be set. If the required channel is not available, an exception will be thrown.
+ if (m_pActiveChannel == NULL || m_pActiveChannel->getURL() == NULL
+ || strcmp(m_pActiveChannel->getURL(), pcEndpointUri) != 0)
{
if( m_pActiveChannel == NULL)
m_pActiveChannel = m_pNormalChannel;
@@ -176,9 +171,7 @@
}
if( !m_bChannelSecure)
- {
throw HTTPTransportException( CLIENT_TRANSPORT_HAS_NO_SECURE_TRANSPORT_LAYER);
- }
}
else if (m_bChannelSecure)
{
@@ -191,9 +184,7 @@
}
if( m_bChannelSecure)
- {
throw HTTPTransportException( CLIENT_TRANSPORT_HAS_NO_UNSECURE_TRANSPORT_LAYER);
- }
}
}
@@ -211,19 +202,17 @@
int HTTPTransport::
openConnection()
{
- if( m_bReopenConnection || m_pActiveChannel->reopenRequired())
+ // If connection not valid or reopen required, open a connection to server.
+ if (m_pActiveChannel->reopenRequired() || m_bReopenConnection)
{
- // Call closeConnection in order to reset various state variables.
- closeConnection();
-
- m_bReopenConnection = false;
-
+ closeConnection(true);
if( m_pActiveChannel->open() != AXIS_SUCCESS)
{
throw HTTPTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED,
m_pActiveChannel->GetLastErrorMsg().c_str());
}
}
+
return AXIS_SUCCESS;
}
@@ -231,11 +220,17 @@
* HTTPTransport::closeConnection().
*/
void HTTPTransport::
-closeConnection()
+closeConnection(bool forceClose)
{
resetInputStateMachine();
-
- // Samisa : closing the connection is done in setEndpointUri no need to close here Fix for AXISCPP-481
+
+ // We will close the connection if forced close, or if "Connection: close"
+ // header was detected.
+ if (forceClose || m_bReopenConnection)
+ {
+ m_bReopenConnection = false;
+ m_pActiveChannel->close();
+ }
}
/*
@@ -335,15 +330,12 @@
sprintf(buff, ":%u\r\n", uiPort);
m_strHeaderBytesToSend += buff;
+ // The Content-Type must be set, but it may already be set.
bool foundCT = false;
for (unsigned int j = 0; j < m_vHTTPHeaders.size (); j++)
- {
if (0==strcmp(AXIS_CONTENT_TYPE,m_vHTTPHeaders[j].first.c_str()))
foundCT = true;
- }
- // The Content-Type must be set, but it may already be set in m_strHeaderBytesToSend if we're using attachments, for
- // example.
if (!foundCT)
m_strHeaderBytesToSend += AXIS_CONTENT_TYPE ": text/xml; charset=UTF-8\r\n";
@@ -380,6 +372,10 @@
m_strHeaderBytesToSend += ": ";
m_strHeaderBytesToSend += m_vHTTPHeaders[i].second;
m_strHeaderBytesToSend += "\r\n";
+
+ if (0==strcmp("Connection",m_vHTTPHeaders[i].first.c_str())
+ && 0==strcmp("close", m_vHTTPHeaders[i].second.c_str()))
+ m_bReopenConnection = true;
}
}
@@ -828,7 +824,9 @@
case TRANSPORT_PROPERTIES:
{
- if( m_pActiveChannel != NULL)
+ if (value && strcmp(value, "Connection: close") == 0)
+ setTransportProperty("Connection", "close");
+ else if( m_pActiveChannel != NULL)
m_pActiveChannel->setTransportProperty( type, value);
break;
@@ -888,7 +886,9 @@
bool b_KeyFound = false;
// Check for well known headers that we add on in every iteration
- if( strcmp( pcKey, "SOAPAction") == 0 || strcmp( pcKey, "Content-Length") == 0)
+ if (strcmp( pcKey, "SOAPAction") == 0
+ || strcmp( pcKey, "Content-Length") == 0
+ || strcmp( pcKey, "Connection") == 0)
{
std::string strKeyToFind = std::string( pcKey);
Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp Mon Feb 19 21:22:19 2007
@@ -61,7 +61,7 @@
*/
void setEndpointUri( const char * pszEndpointURI) throw (HTTPTransportException);
int openConnection();
- void closeConnection();
+ void closeConnection(bool forceClose=true);
AXIS_TRANSPORT_STATUS sendBytes( const char *, const void *);
AXIS_TRANSPORT_STATUS getBytes( char *, int *) throw (AxisException, HTTPTransportException);
int setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE, const char *) throw (HTTPTransportException);
Modified: webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp (original)
+++ webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp Mon Feb 19 21:22:19 2007
@@ -90,9 +90,10 @@
{
// if exception is thrown on parseFirst()
m_bCanParseMore = false;
- m_bFirstParsed = true;
m_bCanParseMore = m_pParser->parseFirst( *m_pInputSource, m_ScanToken);
+
+ m_bFirstParsed = true;
if (!m_bCanParseMore)
return (const AnyElement*)NULL;
}
Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/ConnectionCloseClient.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/ConnectionCloseClient.cpp?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/ConnectionCloseClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/ConnectionCloseClient.cpp Mon Feb 19 21:22:19 2007
@@ -21,78 +21,67 @@
void sig_handler(int);
void PrintUsage();
-bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
- char endpoint[256];
- const char* url="http://localhost:80/axis/Calculator";
- const char* op = 0;
- int i1=0, i2=0;
- int iResult;
-
- signal(SIGILL, sig_handler);
- signal(SIGABRT, sig_handler);
- signal(SIGSEGV, sig_handler);
- //signal(SIGQUIT, sig_handler);
- //signal(SIGBUS, sig_handler);
- signal(SIGFPE, sig_handler);
-
- url = argv[1];
-
- bool bSuccess = false;
- int iRetryIterationCount = 3;
- sprintf(endpoint, "%s", url);
- Calculator ws(endpoint);
+ char endpoint[256];
+ const char* url="http://localhost:80/axis/Calculator";
+ const char* op = 0;
+ int i1=0, i2=0;
+ int iResult;
+
+ signal(SIGILL, sig_handler);
+ signal(SIGABRT, sig_handler);
+ signal(SIGSEGV, sig_handler);
+ //signal(SIGQUIT, sig_handler);
+ //signal(SIGBUS, sig_handler);
+ signal(SIGFPE, sig_handler);
+
+ url = argv[1];
+
+ int iIterationCount = 5;
+ sprintf(endpoint, "%s", url);
+ Calculator ws(endpoint);
- do
- {
+ do
+ {
try
- {
-
- op = "add";
- i1 = 2;
- i2 = 3;
-
- if (strcmp(op, "add") == 0)
- {
- iResult = ws.add(i1, i2);
- cout << iResult << endl;
- bSuccess = true;
- }
+ {
+ op = "add";
+ i1 = 2;
+ i2 = 3;
+
+ if (iIterationCount == 2)
+ ws.setTransportProperty("Connection", "close");
+
+ if (strcmp(op, "add") == 0)
+ {
+ iResult = ws.add(i1, i2);
+ cout << iResult << endl;
+ }
}
catch(AxisException& e)
{
cout << "Exception : " << e.what() << endl;
}
- catch(exception& e)
- {
- cout << "Unknown exception has occured" << endl;
- }
catch(...)
{
cout << "Unknown exception has occured" << endl;
}
- iRetryIterationCount--;
- } while( iRetryIterationCount > 0);
- cout<< "---------------------- TEST COMPLETE -----------------------------"<< endl;
- return 0;
+ iIterationCount--;
+ }
+ while( iIterationCount > 0);
+
+ cout<< "---------------------- TEST COMPLETE -----------------------------"<< endl;
+
+ return 0;
}
void PrintUsage()
{
printf("Usage :\n Calculator <url>\n\n");
exit(1);
-}
-
-bool IsNumber(const char* p)
-{
- for (int x=0; x < strlen(p); x++)
- {
- if (!isdigit(p[x])) return false;
- }
- return true;
}
void sig_handler(int sig) {
Modified: webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose.cpp.out
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose.cpp.out?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose.cpp.out (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose.cpp.out Mon Feb 19 21:22:19 2007
@@ -1,4 +1,6 @@
5
5
5
+5
+5
---------------------- TEST COMPLETE -----------------------------
Modified: webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose_ServerResponse.expected
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose_ServerResponse.expected?view=diff&rev=509427&r1=509426&r2=509427
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose_ServerResponse.expected (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/output/ConnectionClose_ServerResponse.expected Mon Feb 19 21:22:19 2007
@@ -32,3 +32,25 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
0
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-US
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-US
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org