summaryrefslogtreecommitdiff
path: root/res/res_pktccops.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-12-04 04:52:24 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-12-04 04:52:24 +0000
commitaa9ec67f977c5761e30f65862059b58f84b1097a (patch)
tree02f06e81b33992843d9cfe15d5ce96bb651e43ec /res/res_pktccops.c
parent8599628e0be2734372e042b4db6307ab24967501 (diff)
OS X does not define MSG_NOSIGNAL, but it does have a socket option SO_NOSIGPIPE.
(closes issue #16178) Reported by: oej git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@232950 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pktccops.c')
-rw-r--r--res/res_pktccops.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/res/res_pktccops.c b/res/res_pktccops.c
index 60e5c4efd..cdd464ab8 100644
--- a/res/res_pktccops.c
+++ b/res/res_pktccops.c
@@ -378,7 +378,7 @@ static int cops_getmsg (int sfd, struct copsmsg *recmsg)
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 @@ static int cops_sendmsg (int sfd, struct copsmsg * sendmsg)
}
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 @@ static int cops_connect(char *host, char *port)
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 @@ static int cops_connect(char *host, char *port)
}
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");