Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

CVS update of carob (include/SystemDependantDefs.hpp src/JavaSocket.cpp): msg#00002

db.carob.cvs

Subject: CVS update of carob (include/SystemDependantDefs.hpp src/JavaSocket.cpp)

Date: Tuesday, December 19, 2006 @ 12:14:15
Author: marc
Path: /cvsroot/carob/carob

Modified: include/SystemDependantDefs.hpp (1.9 -> 1.10) src/JavaSocket.cpp
(1.62 -> 1.63)

Considerably simplified MSG_NOSIGNAL/SO_NOSIGPIPE logic.
Related to CAROB-117, CAROB-118 and others.


---------------------------------+
include/SystemDependantDefs.hpp | 42 ++++++++++++++++----------------------
src/JavaSocket.cpp | 4 +--
2 files changed, 20 insertions(+), 26 deletions(-)


Index: carob/include/SystemDependantDefs.hpp
diff -u carob/include/SystemDependantDefs.hpp:1.9
carob/include/SystemDependantDefs.hpp:1.10
--- carob/include/SystemDependantDefs.hpp:1.9 Mon Dec 18 19:57:14 2006
+++ carob/include/SystemDependantDefs.hpp Tue Dec 19 12:14:15 2006
@@ -35,47 +35,41 @@


////////////////////////////////////////////////////////////////////////////////
// Sockets options
-
/**
* In Carob, we want to recover from closed socket errors. So we will tell the
* system *not* to send sigpipes when writing on a closed socket.
* Solutions to this are system dependant:
* -> *nixes have MSG_NOSIGNAL flag for send(2/3) function
- * -> MaxOS/X >= 10.1 and FreeBSD have no MSG_NOSIGNAL but a socket option
SO_NOSIGPIPE
+ * -> MaxOS/X >= 10.1 and old FreeBSD have no MSG_NOSIGNAL but a socket option
SO_NOSIGPIPE
* (check socket(7) and setsockopt(2))
+ *
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/setsockopt.2.html
* -> ...
*/

-// --- MINGW32 ---
-
-// bare Windows has no signals anyway, let's do nothing (not even
-// including sys/socket.h)
-#if defined(__MINGW32__)
-# define MSG_NOSIGNAL 0
-# define CAROB_USE_SO_NOSIGPIPE 0
-
-// --- Mac OSX ----
-
-// no MSG_NOSIGNAL available but SO_NOSIGPIPE is
-//
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/setsockopt.2.html
-#elif defined(__APPLE__) && defined(__MACH__) // TODO: add FreeBSD & co here?
- //
http://developer.apple.com/technotes/tn2002/tn2071.html#Section10
+#ifdef __MINGW32__
+# include <ws2tcpip.h>
+#else
# include <sys/socket.h>
-# define MSG_NOSIGNAL 0 // provide dummy value
-# define CAROB_USE_SO_NOSIGPIPE 1
+#endif

-// --- Default case / fallback --- (OK for most unices?)

-// if MSG_NOSIGNAL is available, then we can safely skip the
setsockopt(SO_NOSIGPIPE) call
-#else
-# include <sys/socket.h>
-# if defined(MSG_NOSIGNAL)
-# define CAROB_USE_SO_NOSIGPIPE 0
+#if !defined(MSG_NOSIGNAL)
+
+# if defined(SO_NOSIGPIPE)
+ // If we can rely on setsockopt(SO_NOSIGPIPE)
+ // then we safely provide a dummmy MSG_NOSIGNAL
+# define MSG_NOSIGNAL 0
+
+# elif defined(__MINGW32__)
+ // NOP! MINGW32 is OK (really?)
+
# else
# error "Could not find either MSG_NOSIGNAL nor SO_NOSIGPIPE"
// Solaris provides neither and DOES sends a SIGPIPE (see
setsockopt(3SOCKET)
// We have a problem here... See tentative solutions in CAROB-116
+
# endif
+
#endif


Index: carob/src/JavaSocket.cpp
diff -u carob/src/JavaSocket.cpp:1.62 carob/src/JavaSocket.cpp:1.63
--- carob/src/JavaSocket.cpp:1.62 Mon Dec 18 19:57:14 2006
+++ carob/src/JavaSocket.cpp Tue Dec 19 12:14:15 2006
@@ -93,8 +93,8 @@
int opt_value = 1;
if (setsockopt(socket_fd, IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<char*>(&opt_value), sizeof opt_value) == -1
-#if CAROB_USE_SO_NOSIGPIPE
- // 3. Disable sigpipe
+#ifdef SO_NOSIGPIPE
+ // 3. Disable sigpipe, see SystemDependantDefs.hpp
|| setsockopt(socket_fd, SOL_SOCKET, SO_NOSIGPIPE,
reinterpret_cast<char*>(&opt_value), sizeof (opt_value) ==
-1)
#endif


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | advertise | OSDir is an inevitable website. super tiny logo