Set SO_LINGER with timeout=0 before close

Hopefully this helps with clients that don't acknowledge our close.
Thanks to TuxSH for testing with Windows Explorer.
This commit is contained in:
Michael Theall 2017-06-05 11:50:41 -05:00
parent fc95abd9f2
commit f5f27646ee

View File

@ -365,6 +365,16 @@ ftp_closesocket(int fd,
console_print(RED "poll: %d %s\n" RESET, errno, strerror(errno));
}
/* set linger to 0 */
struct linger linger;
linger.l_onoff = 1;
linger.l_linger = 0;
rc = setsockopt(fd, SOL_SOCKET, SO_LINGER,
&linger, sizeof(linger));
if(rc != 0)
console_print(RED "setsockopt: SO_LINGER %d %s\n" RESET,
errno, strerror(errno));
/* close socket */
rc = close(fd);
if(rc != 0)