Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=7f806dce1673397f084ef1f6e55d9d5befd9a26e
commit 7f806dce1673397f084ef1f6e55d9d5befd9a26e Author: Miklos Vajna <[email protected]> Date: Tue Feb 21 20:09:11 2012 +0100 Revert "libftp: set SO_*TIMEO on sockets to avoid blocking I/O" This reverts commit a2f23cb3291b863db54e81b6ee6349ef8f4e05fa. diff --git a/lib/libftp/ftplib.c b/lib/libftp/ftplib.c index 9b960fe..0a32291 100644 --- a/lib/libftp/ftplib.c +++ b/lib/libftp/ftplib.c @@ -460,23 +460,6 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) net_close(sControl); return 0; } - struct timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; - if (setsockopt (sControl, SOL_SOCKET, SO_RCVTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sControl); - return -1; - } - if (setsockopt (sControl, SOL_SOCKET, SO_SNDTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sControl); - return -1; - } if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) { perror("connect"); @@ -691,24 +674,6 @@ static int FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir) net_close(sData); return -1; } - struct timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; - if (setsockopt (sData, SOL_SOCKET, SO_RCVTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sData); - return -1; - } - if (setsockopt (sData, SOL_SOCKET, SO_SNDTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sData); - return -1; - } - if (nControl->cmode == FTPLIB_PASSIVE) { if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1) @@ -936,11 +901,11 @@ GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData) { i = socket_wait(nData); if (i != 1) - return -1; + return 0; i = net_read(nData->handle, buf, max); } if (i == -1) - return -1; + return 0; nData->xfered += i; if (nData->idlecb && nData->cbbytes) { @@ -1004,7 +969,7 @@ GLOBALDEF int FtpClose(netbuf *nData) net_close(nData->handle); ctrl = nData->ctrl; free(nData); - if (ctrl) + if (ctrl && (nData->errcode != ETIMEDOUT)) { ctrl->data = NULL; return(readresp('2', ctrl)); @@ -1203,13 +1168,6 @@ static int FtpXfer(const char *localfile, const char *path, } } - if((l == -1) && (errno == EWOULDBLOCK)) - { - nControl->errcode = ETIMEDOUT; - strncpy(nControl->response, strerror(ETIMEDOUT), - sizeof(nControl->response)); - } - if (nData->errcode) rv = 0; @@ -1443,23 +1401,6 @@ GLOBALREF int HttpConnect(const char *host, unsigned short port, netbuf **nContr perror("socket"); return 0; } - struct timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; - if (setsockopt (sControl, SOL_SOCKET, SO_RCVTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sControl); - return -1; - } - if (setsockopt (sControl, SOL_SOCKET, SO_SNDTIMEO, - SETSOCKOPT_OPTVAL_TYPE &timeout, sizeof(timeout)) == -1) - { - perror("setsockopt"); - net_close(sControl); - return -1; - } if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) { perror("connect"); @@ -1587,13 +1528,6 @@ static int HttpXfer(const char *localfile, const char *path, int *size, } } - if((l == -1) && (errno == EWOULDBLOCK)) - { - nControl->errcode = ETIMEDOUT; - strncpy(nControl->response, strerror(ETIMEDOUT), - sizeof(nControl->response)); - } - if(nControl->errcode) rv = 0; nControl->dir = FTPLIB_CONTROL; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
