summaryrefslogtreecommitdiff
path: root/net/libfetch
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2010-01-24 16:54:23 +0000
committerjoerg <joerg@pkgsrc.org>2010-01-24 16:54:23 +0000
commit213ed611675ed1987f3d7020fea00acaf25ddf67 (patch)
tree8e9a32ed48ca6252ea40e0c40ec75db8f6c5cf86 /net/libfetch
parent7432ef55a0df0e4cea24f22d32a4c4d111943613 (diff)
downloadpkgsrc-213ed611675ed1987f3d7020fea00acaf25ddf67.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/libfetch')
-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;