Skip to content

Commit

Permalink
delaying client disconnect using freeClientAsync()
Browse files Browse the repository at this point in the history
- when a client is marked for closing (i.e. after protocol error) we are delaying
  it slightly by using freeClientAsync() instead of freeClient() as sometimes
  the latter was closing connection too fast without reply being actually sent
  • Loading branch information
Tomasz Poradowski committed Sep 29, 2019
1 parent 2392f88 commit 3318609
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,13 @@ static void acceptCommonHandler(int fd, int flags, char *ip) {
/* Nothing to do, Just to avoid the warning... */
}
server.stat_rejected_conn++;
#ifdef _WIN32
//[tporadowski] freeClient was sometimes causing sent reply to be not delivered, so give it some
// additional time via freeing asynchronously
freeClientAsync(c);
#else
freeClient(c);
#endif
return;
}

Expand Down Expand Up @@ -1065,7 +1071,13 @@ int writeToClient(int fd, client *c, int handler_installed) {

/* Close connection after entire reply has been sent. */
if (c->flags & CLIENT_CLOSE_AFTER_REPLY) {
#ifdef _WIN32
//[tporadowski] freeClient was sometimes causing sent reply to be not delivered, so give it some
// additional time via freeing asynchronously
freeClientAsync(c);
#else
freeClient(c);
#endif
return C_ERR;
}
}
Expand Down

0 comments on commit 3318609

Please sign in to comment.