reduce dropped connections at end of transfer

This commit is contained in:
Michael Theall 2016-01-18 17:45:04 -06:00
parent c79616d2ef
commit 5617e2c32a

View File

@ -295,6 +295,7 @@ ftp_closesocket(int fd,
int rc;
struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
struct pollfd pollinfo;
if(connected)
{
@ -310,9 +311,17 @@ ftp_closesocket(int fd,
inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
/* shutdown connection */
rc = shutdown(fd, SHUT_RDWR);
rc = shutdown(fd, SHUT_WR);
if(rc != 0)
console_print(RED "shutdown: %d %s\n" RESET, errno, strerror(errno));
/* wait for client to close connection */
pollinfo.fd = fd;
pollinfo.events = POLLIN;
pollinfo.revents = 0;
rc = poll(&pollinfo, 1, 250);
if(rc < 0)
console_print(RED "poll: %d %s\n" RESET, errno, strerror(errno));
}
/* close socket */