summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorjoerg <joerg>2010-01-24 16:54:23 +0000
committerjoerg <joerg>2010-01-24 16:54:23 +0000
commitfd0db65e55c91600b46e2cdc11681df800a9d761 (patch)
tree8e9a32ed48ca6252ea40e0c40ec75db8f6c5cf86 /net
parentcb48f8973160dd0d48385b2dbe71a7e3f335fb99 (diff)
downloadpkgsrc-fd0db65e55c91600b46e2cdc11681df800a9d761.tar.gz
Use the hard-core approach of killing SIGPIPE explicitly on
platforms that don't have MSG_NOSIGNAL like Solaris.
Diffstat (limited to 'net')
-rw-r--r--net/libfetch/files/common.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/net/libfetch/files/common.c b/net/libfetch/files/common.c
index 81cb54a5dc1..fd2c0aa8a68 100644
--- a/net/libfetch/files/common.c
+++ b/net/libfetch/files/common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.24 2010/01/23 14:25:26 joerg Exp $ */
+/* $NetBSD: common.c,v 1.25 2010/01/24 16:54:23 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg@NetBSD.org>
@@ -62,6 +62,10 @@
#include <string.h>
#include <unistd.h>
+#ifndef MSG_NOSIGNAL
+#include <signal.h>
+#endif
+
#include "fetch.h"
#include "common.h"
@@ -624,6 +628,17 @@ fetch_write(conn_t *conn, const void *buf, size_t len)
fd_set writefds;
ssize_t wlen, total;
int r;
+#ifndef MSG_NOSIGNAL
+ static int killed_sigpipe;
+#endif
+
+#ifndef MSG_NOSIGNAL
+ if (!killed_sigpipe) {
+ signal(SIGPIPE, SIG_IGN);
+ killed_sigpipe = 1;
+ }
+#endif
+
if (fetchTimeout) {
FD_ZERO(&writefds);
@@ -661,7 +676,11 @@ fetch_write(conn_t *conn, const void *buf, size_t len)
wlen = SSL_write(conn->ssl, buf, len);
else
#endif
+#ifndef MSG_NOSIGNAL
+ wlen = send(conn->sd, buf, len, 0);
+#else
wlen = send(conn->sd, buf, len, MSG_NOSIGNAL);
+#endif
if (wlen == 0) {
/* we consider a short write a failure */
errno = EPIPE;