diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-04 04:52:24 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-04 04:52:24 +0000 |
commit | e3cfc784ddb1ac4599fefdf7ca6266093e36b3ea (patch) | |
tree | 02f06e81b33992843d9cfe15d5ce96bb651e43ec /res/res_pktccops.c | |
parent | dc26f23367bdc4a8b56dbb47ded722cc45a86406 (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: http://svn.digium.com/svn/asterisk/trunk@232950 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_pktccops.c')
-rw-r--r-- | res/res_pktccops.c | 16 |
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"); |