Browse Source

Use the retry on EINTR only on unix sockets

master
Con Kolivas 11 years ago
parent
commit
a3a586ee6e
  1. 6
      src/connector.c
  2. 14
      src/libckpool.c

6
src/connector.c

@ -93,11 +93,8 @@ void *acceptor(void *arg)
retry:
client = ckzalloc(sizeof(client_instance_t));
client->address_len = sizeof(client->address);
reaccept:
fd = accept(ci->serverfd, &client->address, &client->address_len);
if (unlikely(fd < 0)) {
if (interrupted())
goto reaccept;
LOGERR("Failed to accept on socket %d in acceptor", ci->serverfd);
dealloc(client);
goto out;
@ -258,11 +255,8 @@ retry:
cksleep_ms(100);
goto retry;
}
repoll:
ret = poll(fds, nfds, 1000);
if (ret < 0) {
if (interrupted())
goto repoll;
LOGERR("Failed to poll in receiver");
goto out;
}

14
src/libckpool.c

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

Loading…
Cancel
Save