commit 7333727189f0c82dd42f6040149a1b1717bad615
parent 7b9cf32e4ea2763c16a14c44ab5b4423e8a9aaa9
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 3 Nov 2011 09:29:31 +0000
fixing shutdown issue on OS X -- 1760
Diffstat:
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Nov 3 10:14:59 CET 2011
+ shutdown(RDWR) fails on OS X after shutdown(RD), so only use
+ shutdown(WR) if we already closed the socket for reading (otherwise
+ OS X might not do shutdown (WR) at all). -CG
+
Tue Nov 1 18:51:50 CET 2011
Force adding of 'Connection: close' to the header if we (for whatever
reason) are shutting down the socket for reading (see also
diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c
@@ -14,7 +14,7 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
const char *page = "<html><body>Hello, browser!</body></html>";
struct MHD_Response *response;
int ret;
-
+
response =
MHD_create_response_from_buffer (strlen (page), (void *) page,
MHD_RESPMEM_PERSISTENT);
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
@@ -302,7 +302,8 @@ MHD_connection_close (struct MHD_Connection *connection,
struct MHD_Daemon *daemon;
daemon = connection->daemon;
- SHUTDOWN (connection->socket_fd, SHUT_RDWR);
+ SHUTDOWN (connection->socket_fd,
+ (connection->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
connection->state = MHD_CONNECTION_CLOSED;
if ( (NULL != daemon->notify_completed) &&
(MHD_YES == connection->client_aware) )
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
@@ -2445,7 +2445,8 @@ close_all_connections (struct MHD_Daemon *daemon)
abort();
}
for (pos = daemon->connections_head; pos != NULL; pos = pos->next)
- SHUTDOWN (pos->socket_fd, SHUT_RDWR);
+ SHUTDOWN (pos->socket_fd,
+ (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
if (0 != pthread_mutex_unlock(&daemon->cleanup_connection_mutex))
{
#if HAVE_MESSAGES