Author: dreiss
Date: Thu Jun  4 00:10:50 2009
New Revision: 781626

URL: http://svn.apache.org/viewvc?rev=781626&view=rev
Log:
THRIFT-497. cpp: Fix TSocket::read and peek on Max OS

Modified:
    incubator/thrift/trunk/lib/cpp/src/transport/TSocket.cpp

Modified: incubator/thrift/trunk/lib/cpp/src/transport/TSocket.cpp
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cpp/src/transport/TSocket.cpp?rev=781626&r1=781625&r2=781626&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cpp/src/transport/TSocket.cpp (original)
+++ incubator/thrift/trunk/lib/cpp/src/transport/TSocket.cpp Thu Jun  4 
00:10:50 2009
@@ -108,7 +108,7 @@
   int r = recv(socket_, &buf, 1, MSG_PEEK);
   if (r == -1) {
     int errno_copy = errno;
-    #ifdef __FreeBSD__
+    #if defined __FreeBSD__ || defined __MACH__
     /* shigin:
      * freebsd returns -1 and ECONNRESET if socket was closed by 
      * the other side
@@ -338,20 +338,22 @@
       goto try_again;
     }
 
-    // Now it's not a try again case, but a real probblez
-    GlobalOutput.perror("TSocket::read() recv() " + getSocketInfo(), 
errno_copy);
-
-    // If we disconnect with no linger time
+    #if defined __FreeBSD__ || defined __MACH__
     if (errno_copy == ECONNRESET) {
-      #ifdef __FreeBSD__
       /* shigin: freebsd doesn't follow POSIX semantic of recv and fails with
        * ECONNRESET if peer performed shutdown 
        */
       close();
       return 0;
-      #else
+    }
+    #endif
+
+    // Now it's not a try again case, but a real probblez
+    GlobalOutput.perror("TSocket::read() recv() " + getSocketInfo(), 
errno_copy);
+
+    // If we disconnect with no linger time
+    if (errno_copy == ECONNRESET) {
       throw TTransportException(TTransportException::NOT_OPEN, "ECONNRESET");
-      #endif
     }
 
     // This ish isn't open


Reply via email to