Commit 4ffeb141 authored by deuce's avatar deuce
Browse files

When shutting down, recv() on the socket until recv() returns 0 or -1.

This ensures that all data that has been send()ed is transmitted.  Timeout
after max_inactivity (max delay is max_inactivity*2).
parent 21469e45
......@@ -407,6 +407,7 @@ static char *find_last_slash(char *str);
static BOOL check_extra_path(http_session_t * session);
static BOOL exec_ssjs(http_session_t* session, char* script);
static BOOL ssjs_send_headers(http_session_t* session, int chunked);
static int sess_recv(http_session_t *session, char *buf, size_t length, int flags);
static time_t
sub_mkgmt(struct tm *tm)
......@@ -935,12 +936,22 @@ static void close_socket_cb(SOCKET sock, void *cbdata)
static int close_socket(SOCKET *sock)
int result;
char ch;
time_t end = time(NULL) + startup->max_inactivity;
BOOL rd;
if(sock==NULL || *sock==INVALID_SOCKET)
/* required to ensure all data is send when SO_LINGER is off (Not functional on Win32) */
/* required to ensure all data is sent */
while(socket_check(*sock, &rd, NULL, startup->max_inactivity*1000)) {
if (rd) {
if (recv(*sock,&ch,1,0) <= 0)
if (time(NULL) >= end)
if(startup!=NULL && startup->socket_open!=NULL) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment