|
|
@ -403,7 +403,6 @@ int connect_socket(char *url, char *port) |
|
|
|
LOGDEBUG("Failed sock connect"); |
|
|
|
LOGDEBUG("Failed sock connect"); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
retry: |
|
|
|
|
|
|
|
FD_ZERO(&rw); |
|
|
|
FD_ZERO(&rw); |
|
|
|
FD_SET(sockd, &rw); |
|
|
|
FD_SET(sockd, &rw); |
|
|
|
selret = select(sockd + 1, NULL, &rw, NULL, &tv_timeout); |
|
|
|
selret = select(sockd + 1, NULL, &rw, NULL, &tv_timeout); |
|
|
@ -419,8 +418,6 @@ retry: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (selret < 0 && interrupted()) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
close(sockd); |
|
|
|
close(sockd); |
|
|
|
sockd = -1; |
|
|
|
sockd = -1; |
|
|
|
LOGDEBUG("Select timeout/failed connect"); |
|
|
|
LOGDEBUG("Select timeout/failed connect"); |
|
|
@ -447,12 +444,9 @@ int write_socket(int fd, const void *buf, size_t nbyte) |
|
|
|
fd_set writefds; |
|
|
|
fd_set writefds; |
|
|
|
int ret; |
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
|
|
retry: |
|
|
|
|
|
|
|
FD_ZERO(&writefds); |
|
|
|
FD_ZERO(&writefds); |
|
|
|
FD_SET(fd, &writefds); |
|
|
|
FD_SET(fd, &writefds); |
|
|
|
ret = select(fd + 1, NULL, &writefds, NULL, &tv_timeout); |
|
|
|
ret = select(fd + 1, NULL, &writefds, NULL, &tv_timeout); |
|
|
|
if (ret < 0 && interrupted()) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
if (ret < 1) { |
|
|
|
if (ret < 1) { |
|
|
|
if (!ret) |
|
|
|
if (!ret) |
|
|
|
LOGNOTICE("Select timed out in write_socket"); |
|
|
|
LOGNOTICE("Select timed out in write_socket"); |
|
|
@ -472,14 +466,14 @@ out: |
|
|
|
int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
size_t buflen = 0, bufofs = 0; |
|
|
|
size_t buflen = 0, bufofs = 0; |
|
|
|
|
|
|
|
int ret = -1, bufsiz; |
|
|
|
char *eom = NULL; |
|
|
|
char *eom = NULL; |
|
|
|
tv_t tv_timeout; |
|
|
|
tv_t tv_timeout; |
|
|
|
int ret, bufsiz; |
|
|
|
|
|
|
|
fd_set rd; |
|
|
|
fd_set rd; |
|
|
|
|
|
|
|
|
|
|
|
dealloc(cs->buf); |
|
|
|
dealloc(cs->buf); |
|
|
|
if (unlikely(cs->fd < 0)) |
|
|
|
if (unlikely(cs->fd < 0)) |
|
|
|
return -1; |
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
|
|
bufsiz = PAGESIZE; |
|
|
|
bufsiz = PAGESIZE; |
|
|
|
while (!eom) { |
|
|
|
while (!eom) { |
|
|
@ -491,8 +485,6 @@ int read_socket_line(connsock_t *cs, int timeout) |
|
|
|
tv_timeout.tv_sec = timeout; |
|
|
|
tv_timeout.tv_sec = timeout; |
|
|
|
tv_timeout.tv_usec = 0; |
|
|
|
tv_timeout.tv_usec = 0; |
|
|
|
ret = select(cs->fd + 1, &rd, NULL, NULL, &tv_timeout); |
|
|
|
ret = select(cs->fd + 1, &rd, NULL, NULL, &tv_timeout); |
|
|
|
if (ret < 0 && interrupted()) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
if (ret < 1) { |
|
|
|
if (ret < 1) { |
|
|
|
if (!ret) |
|
|
|
if (!ret) |
|
|
|
LOGDEBUG("Select timed out in read_socket_line"); |
|
|
|
LOGDEBUG("Select timed out in read_socket_line"); |
|
|
@ -545,8 +537,6 @@ void empty_socket(int fd) |
|
|
|
FD_ZERO(&rd); |
|
|
|
FD_ZERO(&rd); |
|
|
|
FD_SET(fd, &rd); |
|
|
|
FD_SET(fd, &rd); |
|
|
|
ret = select(fd + 1, &rd, NULL, NULL, &timeout); |
|
|
|
ret = select(fd + 1, &rd, NULL, NULL, &timeout); |
|
|
|
if (ret < 0 && interrupted()) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
if (ret > 0) { |
|
|
|
if (ret > 0) { |
|
|
|
ret = recv(fd, buf, PAGESIZE - 1, 0); |
|
|
|
ret = recv(fd, buf, PAGESIZE - 1, 0); |
|
|
|
buf[ret] = 0; |
|
|
|
buf[ret] = 0; |
|
|
|