aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-11-17 07:56:19 +0000
committerChristian Grothoff <christian@grothoff.org>2007-11-17 07:56:19 +0000
commitb1284bff7358c92b93bf311a81278c5a8607427c (patch)
tree4e84f6e96cb5a45589e506cdf98710bd6168e3a5
parent0692908cdbb5cf80de854c217702f6ea6d28595a (diff)
downloadlibmicrohttpd-b1284bff7358c92b93bf311a81278c5a8607427c.tar.gz
libmicrohttpd-b1284bff7358c92b93bf311a81278c5a8607427c.zip
sigpipe
-rw-r--r--ChangeLog6
-rw-r--r--README11
-rw-r--r--src/daemon/connection.c16
-rw-r--r--src/daemon/daemon.c14
4 files changed, 43 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b05d3820..79d2c275 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
1Sat Nov 17 00:55:24 MST 2007
2 Fixed off-by-one in error message string matching.
3 Added code to avoid generating SIGPIPE on platforms
4 where this is possible (everywhere else, the main
5 application should install a handler for SIGPIPE).
6
1Thu Oct 11 11:02:06 MDT 2007 7Thu Oct 11 11:02:06 MDT 2007
2 Releasing libmicrohttpd 0.1.1. - CG 8 Releasing libmicrohttpd 0.1.1. - CG
3 9
diff --git a/README b/README
index 66c6edc5..e83480f0 100644
--- a/README
+++ b/README
@@ -27,6 +27,15 @@ space!). If you are concerned about space, you should set "CFLAGS" to
27resulting binary should be less than 25k (on x86). 27resulting binary should be less than 25k (on x86).
28 28
29 29
30Portability
31===========
32
33The latest version of libmicrohttpd will try to avoid SIGPIPE on its
34sockets. This should work on OS X, Linux and recent BSD systems (at
35least). On other systems that may trigger a SIGPIPE on send/recv, the
36main application should install a signal handler to handle SIGPIPE.
37
38
30Development Status 39Development Status
31================== 40==================
32 41
@@ -67,3 +76,5 @@ Documentation:
67============== 76==============
68- manual (texinfo, man) 77- manual (texinfo, man)
69- tutorial 78- tutorial
79
80
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index 7abe0205..73603dcd 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -32,6 +32,10 @@
32#include "response.h" 32#include "response.h"
33#include "reason_phrase.h" 33#include "reason_phrase.h"
34 34
35#ifndef MSG_NOSIGNAL
36#define MSG_NOSIGNAL 0
37#endif
38
35/** 39/**
36 * Message to transmit when http 1.1 request is received 40 * Message to transmit when http 1.1 request is received
37 */ 41 */
@@ -888,7 +892,8 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
888 } 892 }
889 bytes_read = RECV (connection->socket_fd, 893 bytes_read = RECV (connection->socket_fd,
890 &connection->read_buffer[connection->readLoc], 894 &connection->read_buffer[connection->readLoc],
891 connection->read_buffer_size - connection->readLoc, 0); 895 connection->read_buffer_size - connection->readLoc,
896 MSG_NOSIGNAL);
892 if (bytes_read < 0) 897 if (bytes_read < 0)
893 { 898 {
894 if (errno == EINTR) 899 if (errno == EINTR)
@@ -1056,7 +1061,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1056 { 1061 {
1057 ret = SEND (connection->socket_fd, 1062 ret = SEND (connection->socket_fd,
1058 &HTTP_100_CONTINUE[connection->continuePos], 1063 &HTTP_100_CONTINUE[connection->continuePos],
1059 strlen (HTTP_100_CONTINUE) - connection->continuePos, 0); 1064 strlen (HTTP_100_CONTINUE) - connection->continuePos,
1065 MSG_NOSIGNAL);
1060 if (ret < 0) 1066 if (ret < 0)
1061 { 1067 {
1062 if (errno == EINTR) 1068 if (errno == EINTR)
@@ -1099,7 +1105,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1099 } 1105 }
1100 ret = SEND (connection->socket_fd, 1106 ret = SEND (connection->socket_fd,
1101 &connection->write_buffer[connection->writePos], 1107 &connection->write_buffer[connection->writePos],
1102 connection->writeLoc - connection->writePos, 0); 1108 connection->writeLoc - connection->writePos,
1109 MSG_NOSIGNAL);
1103 if (ret < 0) 1110 if (ret < 0)
1104 { 1111 {
1105 if (errno == EINTR) 1112 if (errno == EINTR)
@@ -1148,7 +1155,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1148 ret = SEND (connection->socket_fd, 1155 ret = SEND (connection->socket_fd,
1149 &response->data[connection->messagePos - response->data_start], 1156 &response->data[connection->messagePos - response->data_start],
1150 response->data_size - (connection->messagePos - 1157 response->data_size - (connection->messagePos -
1151 response->data_start), 0); 1158 response->data_start),
1159 MSG_NOSIGNAL);
1152 if (response->crc != NULL) 1160 if (response->crc != NULL)
1153 pthread_mutex_unlock (&response->mutex); 1161 pthread_mutex_unlock (&response->mutex);
1154 if (ret < 0) 1162 if (ret < 0)
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index d35be3a6..326a13b8 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -254,6 +254,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
254 struct sockaddr *addr = (struct sockaddr *) &addr6; 254 struct sockaddr *addr = (struct sockaddr *) &addr6;
255 socklen_t addrlen; 255 socklen_t addrlen;
256 int s; 256 int s;
257#if OSX
258 static int on=1;
259#endif
257 260
258 261
259 if (sizeof (struct sockaddr) > sizeof (struct sockaddr_in6)) 262 if (sizeof (struct sockaddr) > sizeof (struct sockaddr_in6))
@@ -296,6 +299,17 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
296 CLOSE (s); 299 CLOSE (s);
297 return MHD_YES; 300 return MHD_YES;
298 } 301 }
302#if OSX
303#ifdef SOL_SOCKET
304#ifdef SO_NOSIGPIPE
305 setsockopt(s,
306 SOL_SOCKET,
307 SO_NOSIGPIPE,
308 &on,
309 sizeof(on));
310#endif
311#endif
312#endif
299 connection = malloc (sizeof (struct MHD_Connection)); 313 connection = malloc (sizeof (struct MHD_Connection));
300 if (connection == NULL) 314 if (connection == NULL)
301 { 315 {