activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r500074 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network: SocketOutputStream.cpp TcpSocket.cpp
Date Fri, 26 Jan 2007 00:51:02 GMT
Author: nmittler
Date: Thu Jan 25 16:51:01 2007
New Revision: 500074

URL: http://svn.apache.org/viewvc?view=rev&rev=500074
Log:
[AMQCPP-46] Fixed receipt of SIGPIPE on OS X when sending disconnect message on a broken socket

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp?view=diff&rev=500074&r1=500073&r2=500074
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
Thu Jan 25 16:51:01 2007
@@ -29,16 +29,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#if !defined(SOCKET_NOSIGNAL)
-
-    #if defined(SO_NOSIGPIPE)
-        #define SOCKET_NOSIGNAL SO_NOSIGPIPE
-    #elif defined(MSG_NOSIGNAL)
-        #define SOCKET_NOSIGNAL MSG_NOSIGNAL
-    #else
-        #define SOCKET_NOSIGNAL 0
-    #endif
-
+#if defined(SOCKET_NOSIGNAL)
+    #define AMQ_SEND_OPTS SOCKET_NOSIGNAL
+#elif defined(MSG_NOSIGNAL)
+    #define AMQ_SEND_OPTS MSG_NOSIGNAL
+#else
+    #define AMQ_SEND_OPTS 0
 #endif
 
 using namespace activemq::network;
@@ -68,7 +64,7 @@
     throw (IOException)
 {
     int remaining = len;
-    int sendOpts = SOCKET_NOSIGNAL;
+    int sendOpts = AMQ_SEND_OPTS;
 
     if( debug ){
         printf("SocketOutputStream:write(), numbytes:%d -", len);

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp?view=diff&rev=500074&r1=500073&r2=500074
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp
Thu Jan 25 16:51:01 2007
@@ -135,6 +135,21 @@
             "Socket::connect- Port out of range: %d", port );
     }
     
+#ifdef SO_NOSIGPIPE
+    {
+        int optval = 1;
+        if( ::setsockopt( socketHandle, 
+                          SOL_SOCKET, SO_NOSIGPIPE, 
+                          (char*)&optval, 
+                          sizeof(optval)) < 0 )
+        {
+            close();
+            throw SocketException ( __FILE__, __LINE__, 
+                "Socket::connect- Failed setting SO_NOSIGPIPE: %s", SocketError::getErrorString().c_str()
);
+        }
+    }
+#endif
+    
     sockaddr_in target_addr;
     target_addr.sin_family = AF_INET;
     target_addr.sin_port = htons( ( short ) port );



Mime
View raw message