[svn-commits] tilghman: trunk r232950 - in /trunk: ./ include/asterisk/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 3 22:52:29 CST 2009


Author: tilghman
Date: Thu Dec  3 22:52:24 2009
New Revision: 232950

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=232950
Log:
OS X does not define MSG_NOSIGNAL, but it does have a socket option SO_NOSIGPIPE.
(closes issue #16178)
 Reported by: oej

Modified:
    trunk/configure
    trunk/configure.ac
    trunk/include/asterisk/autoconfig.h.in
    trunk/res/res_pktccops.c

Modified: trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/trunk/configure.ac?view=diff&rev=232950&r1=232949&r2=232950
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Thu Dec  3 22:52:24 2009
@@ -1706,6 +1706,10 @@
 				   ])
 AC_SUBST(PBX_IXJUSER)
 
+# Used in res/res_pktccops
+AST_C_DEFINE_CHECK([MSG_NOSIGNAL], [MSG_NOSIGNAL], [sys/socket.h])
+AST_C_DEFINE_CHECK([SO_NOSIGPIPE], [SO_NOSIGPIPE], [sys/socket.h])
+
 AST_EXT_TOOL_CHECK([SDL], [sdl-config])
 AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}])
 AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [-lpthread -lz -lm])

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=232950&r1=232949&r2=232950
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Thu Dec  3 22:52:24 2009
@@ -534,6 +534,12 @@
 /* Define to 1 if you have a working `mmap' system call. */
 #undef HAVE_MMAP
 
+/* Define if your system has the MSG_NOSIGNAL headers. */
+#undef HAVE_MSG_NOSIGNAL
+
+/* Define MSG_NOSIGNAL headers version */
+#undef HAVE_MSG_NOSIGNAL_VERSION
+
 /* Define to 1 if you have the `munmap' function. */
 #undef HAVE_MUNMAP
 
@@ -809,6 +815,12 @@
 
 /* Define to 1 if your system has soxmix application. */
 #undef HAVE_SOXMIX
+
+/* Define if your system has the SO_NOSIGPIPE headers. */
+#undef HAVE_SO_NOSIGPIPE
+
+/* Define SO_NOSIGPIPE headers version */
+#undef HAVE_SO_NOSIGPIPE_VERSION
 
 /* Define if your system has the SPANDSP headers. */
 #undef HAVE_SPANDSP

Modified: trunk/res/res_pktccops.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pktccops.c?view=diff&rev=232950&r1=232949&r2=232950
==============================================================================
--- trunk/res/res_pktccops.c (original)
+++ trunk/res/res_pktccops.c Thu Dec  3 22:52:24 2009
@@ -378,7 +378,7 @@
 static int cops_sendmsg (int sfd, struct copsmsg * sendmsg)
 {
 	char *buf;
-	int bufpos;
+	int bufpos, res;
 	struct pktcobj *pobject;
 	
 	if (sfd < 0) {
@@ -425,11 +425,17 @@
 	}
 	
 	errno = 0;
-	if (send(sfd, buf, sendmsg->length, MSG_NOSIGNAL | MSG_DONTWAIT ) == -1) {
+#ifdef HAVE_MSG_NOSIGNAL
+#define	SENDFLAGS	MSG_NOSIGNAL | MSG_DONTWAIT
+#else
+#define	SENDFLAGS	MSG_DONTWAIT
+#endif
+	if (send(sfd, buf, sendmsg->length, SENDFLAGS) == -1) {
 		ast_log(LOG_WARNING, "COPS: Send failed errno=%i\n", errno);
 		free(buf);
 		return -2;
 	}
+#undef SENDFLAGS
 	free(buf);
 	return 0;
 }
@@ -636,6 +642,9 @@
 	struct addrinfo hints;
 	struct addrinfo *rp;
 	struct addrinfo *result;
+#ifdef HAVE_SO_NOSIGPIPE
+	int trueval = 1;
+#endif
 
 	memset(&hints, 0, sizeof(struct addrinfo));
 
@@ -657,6 +666,9 @@
 		}
 		flags = fcntl(sfd, F_GETFL);
 		fcntl(sfd, F_SETFL, flags | O_NONBLOCK);
+#ifdef HAVE_SO_NOSIGPIPE
+		setsockopt(sfd, SO_SOCKET, SO_NOSIGPIPE, &trueval, sizeof(trueval));
+#endif
 		connect(sfd, rp->ai_addr, rp->ai_addrlen);
 		if (sfd == -1) {
 			ast_log(LOG_WARNING, "Failed connect\n");




More information about the svn-commits mailing list