BUG#: 8704
authorthilo.boehm <thilo.boehm>
Mon, 1 Feb 2010 11:40:17 +0000 (11:40 +0000)
committerthilo.boehm <thilo.boehm>
Mon, 1 Feb 2010 11:40:17 +0000 (11:40 +0000)
TITLE: Message PGS08101 is confusing if client times out.

DESCRIPTION: Add SocketWriteError Internal Exception.

src/Pegasus/Common/HTTPConnection.cpp
src/Pegasus/Common/InternalException.cpp
src/Pegasus/Common/InternalException.h
src/Pegasus/msg/Server/pegasusServer_en.txt

index d26bda8bf84cbc7c89d8ddec7147b7cf15fcf7be..f8af069bdf99cde02fdecd3b29549f5f4f581ee4 100644 (file)
@@ -164,11 +164,14 @@ static void _throwEventFailure(
 #define _socketWriteError()                                                   \
     do                                                                        \
     {                                                                         \
+        String failureText = PEGASUS_SYSTEM_NETWORK_ERRORMSG;                 \
+                                                                              \
         PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,                        \
-            "Socket write failed with error %d; could not write response "    \
-                "to client.  (Client may have timed out.)",                   \
-            getSocketError()));                                               \
-        throw Exception("socket write error");                                \
+            "Could not write response to client. Client may have timed out. " \
+            "Socket write failed with error: %s ",                            \
+            (const char*)failureText.getCString()));                          \
+                                                                              \
+        throw SocketWriteError(failureText);                                  \
     }                                                                         \
     while (0)
 
@@ -215,10 +218,10 @@ Uint32 HTTPConnection::getIdleConnectionTimeout()
 }
 
 /*
-    Note: This method is called in client code for reconnecting with the Server 
-    and can also be used in the server code to check the connection status  and 
-    take appropriate actions.it checks whether the connection is alive by 
-    attempting to read 1 byte from the socket.This method MUST not be used when 
+    Note: This method is called in client code for reconnecting with the Server
+    and can also be used in the server code to check the connection status  and
+    take appropriate actions.it checks whether the connection is alive by
+    attempting to read 1 byte from the socket.This method MUST not be used when
     incoming data is expected from the connection.
 
     Returns TRUE when there is no data and peer has closed the connection
@@ -232,7 +235,7 @@ Boolean HTTPConnection::needsReconnect()
     char buffer;
 
     int n =  _socket->read(&buffer, sizeof(buffer));
-    
+
     return n >= 0;
 }
 
@@ -338,7 +341,7 @@ void HTTPConnection::handleInternalServerError(
     message.setIndex(respMsgIndex);
     message.setComplete(isComplete);
     AutoMutex connectionLock(_connection_mut);
-    _handleWriteEvent(message); 
+    _handleWriteEvent(message);
     PEG_METHOD_EXIT();
 }
 
@@ -493,7 +496,7 @@ Boolean HTTPConnection::_handleWriteEvent(HTTPMessage& httpMessage)
             }
 
             // If there is an internal error on this connection, just return
-            // from here if the current message is not the last message becasue
+            // from here if the current message is not the last message because
             // this connection will be closed once all messages are received.
             if (_internalError)
             {
@@ -1044,6 +1047,12 @@ Boolean HTTPConnection::_handleWriteEvent(HTTPMessage& httpMessage)
 
     } // try
 
+    catch (SocketWriteError &e)
+    {
+        // On the server side, the socket write error is suppressed
+        // and not handled as an internal error.
+        httpStatusString = e.getMessage();
+    }
     catch (Exception &e)
     {
         httpStatusString = e.getMessage();
index 82996158d0bad1ca58529e9384f41087a12a42a6..9e2a23cd7c7ac4c84a689cf6e3f6b226e6be202b 100644 (file)
@@ -176,6 +176,12 @@ const char UnauthorizedAccess::KEY[] =
 
 const char InternalSystemError::MSG[] = "Unable to authenticate user";
 
+const char SocketWriteError::MSG[] =  "Could not write response to client. "
+                                      "Client may have timed out. "
+                                      "Socket write failed with error: $0";
+const char SocketWriteError::KEY[] =
+    "Common.InternalException.SOCKET_WRITE_ERROR";
+
 ////////////////////////////////////////////////////////////////////////////////
 //
 // TraceableCIMException
@@ -930,6 +936,24 @@ InternalSystemError::~InternalSystemError()
 {
 }
 
+//==============================================================================
+//
+// SocketWriteError
+//
+//==============================================================================
+
+SocketWriteError::SocketWriteError(const String& error)
+    : Exception(MessageLoaderParms(
+          SocketWriteError::KEY,
+          SocketWriteError::MSG,
+          error))
+{
+}
+
+SocketWriteError::~SocketWriteError()
+{
+}
+
 void ThrowUninitializedObjectException()
 {
     throw UninitializedObjectException();
index 7fd507f9e14091868747e02af4a6fff892689e45..e364f91d4f730882c852971ae18f6d950e1de47d 100644 (file)
@@ -435,6 +435,16 @@ public:
     virtual ~InternalSystemError();
 };
 
+class PEGASUS_COMMON_LINKAGE SocketWriteError : public Exception
+{
+public:
+
+    static const char MSG[];
+    static const char KEY[];
+
+    SocketWriteError(const String& error);
+    virtual ~SocketWriteError();
+};
 
 /** The CIMException defines the CIM exceptions that are formally defined in
     the CIM Operations over HTTP specification.  TraceableCIMException allows
index 898f2d34706fc9c73154aa3099ddd170d87abbe9..bbbf06d3b524679f5397b465e7995765c67e4c72 100644 (file)
@@ -428,6 +428,12 @@ en:table {
         */
         Common.InternalException.CREATE_EVENT_FAILED:string {"PGS00242: CreateEvent failed: {0}"}
 
+        /**
+        * @note  PGS00243:
+        *    Substitution {0} is a string describing the system error
+        */
+        Common.InternalException.SOCKET_WRITE_ERROR:string {"PGS00243: Could not write response to client. Client may have timed out. Socket write failed with error: {0}"}
+
         // ==========================================================
         // Messages for Exception
         //  Please use message prefix "PGS00400"