aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2013-08-14 05:55:35 +0000
committerLRN <lrn1986@gmail.com>2013-08-14 05:55:35 +0000
commitce027a58ee2f50b2b20eba590d885530f12c7032 (patch)
tree92079f8963d01f9df3d4deb3a88acc00373986ca /src/microhttpd/daemon.c
parent156482cc4f1b0ea9b7fae0f41b4c483b29e97be4 (diff)
downloadlibmicrohttpd-ce027a58ee2f50b2b20eba590d885530f12c7032.tar.gz
libmicrohttpd-ce027a58ee2f50b2b20eba590d885530f12c7032.zip
W32: shutdown a socket for writing before closing it
Turns out that closing a socket while having unread data in recv buffer causes winsock to terminate the connection without sending any pending data. This is fixed by shutting down socket for writing before closing it.
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 5d3c47bb..8f85c49a 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1582,9 +1582,14 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
1582 MHD_destroy_response (pos->response); 1582 MHD_destroy_response (pos->response);
1583 pos->response = NULL; 1583 pos->response = NULL;
1584 } 1584 }
1585 if ( (-1 != pos->socket_fd) && 1585 if (-1 != pos->socket_fd)
1586 (0 != CLOSE (pos->socket_fd)) ) 1586 {
1587 MHD_PANIC ("close failed\n"); 1587#ifdef WINDOWS
1588 SHUTDOWN (pos->socket_fd, SHUT_WR);
1589#endif
1590 if (0 != CLOSE (pos->socket_fd))
1591 MHD_PANIC ("close failed\n");
1592 }
1588 if (NULL != pos->addr) 1593 if (NULL != pos->addr)
1589 free (pos->addr); 1594 free (pos->addr);
1590 free (pos); 1595 free (pos);