THRIFT-756. cpp: Exposing TSocket(int) constructor to public
authorBryan Duxbury <bryanduxbury@apache.org>
Thu, 2 Sep 2010 00:56:53 +0000 (00:56 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Thu, 2 Sep 2010 00:56:53 +0000 (00:56 +0000)
This patch changes the raw socket handle constructor from protected to public.

Patch: Rajat Goel

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991785 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/transport/TSocket.cpp
lib/cpp/src/transport/TSocket.h
lib/cpp/src/transport/TTransportException.h

index ce1ddcb..5da33bb 100644 (file)
@@ -127,7 +127,7 @@ bool TSocket::peek() {
 
 void TSocket::openConnection(struct addrinfo *res) {
   if (isOpen()) {
-    throw TTransportException(TTransportException::ALREADY_OPEN);
+    return;
   }
 
   socket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -235,7 +235,7 @@ void TSocket::openConnection(struct addrinfo *res) {
 
 void TSocket::open() {
   if (isOpen()) {
-    throw TTransportException(TTransportException::ALREADY_OPEN);
+    return;
   }
 
   // Validate port number
index 70c167f..0184362 100644 (file)
@@ -193,13 +193,12 @@ class TSocket : public TTransport {
    */
   static bool getUseLowMinRto();
 
- protected:
   /**
-   * Constructor to create socket from raw UNIX handle. Never called directly
-   * but used by the TServerSocket class.
+   * Constructor to create socket from raw UNIX handle.
    */
   TSocket(int socket);
 
+ protected:
   /** connect, called by open */
   void openConnection(struct addrinfo *res);
 
index a3ad02b..e0630ef 100644 (file)
@@ -41,13 +41,12 @@ class TTransportException : public apache::thrift::TException {
   enum TTransportExceptionType
   { UNKNOWN = 0
   , NOT_OPEN = 1
-  , ALREADY_OPEN = 2
-  , TIMED_OUT = 3
-  , END_OF_FILE = 4
-  , INTERRUPTED = 5
-  , BAD_ARGS = 6
-  , CORRUPTED_DATA = 7
-  , INTERNAL_ERROR = 8
+  , TIMED_OUT = 2
+  , END_OF_FILE = 3
+  , INTERRUPTED = 4
+  , BAD_ARGS = 5
+  , CORRUPTED_DATA = 6
+  , INTERNAL_ERROR = 7
   };
 
   TTransportException() :
@@ -89,7 +88,6 @@ class TTransportException : public apache::thrift::TException {
       switch (type_) {
         case UNKNOWN        : return "TTransportException: Unknown transport exception";
         case NOT_OPEN       : return "TTransportException: Transport not open";
-        case ALREADY_OPEN   : return "TTransportException: Transport already open";
         case TIMED_OUT      : return "TTransportException: Timed out";
         case END_OF_FILE    : return "TTransportException: End of file";
         case INTERRUPTED    : return "TTransportException: Interrupted";