From: Daniel KouĊ™il Date: Mon, 15 May 2006 08:34:41 +0000 (+0000) Subject: Transfered patch from HEAD changing the use of select() with poll() in order to X-Git-Tag: glite-security-proxyrenewal_R_1_3_3 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=8c3fb270555db6e9792995ded1a088f792c1b200;p=jra1mw.git Transfered patch from HEAD changing the use of select() with poll() in order to allow high fd numbers (bug #16506). --- diff --git a/org.glite.security.proxyrenewal/project/version.properties b/org.glite.security.proxyrenewal/project/version.properties index b8eba67..1d2109a 100644 --- a/org.glite.security.proxyrenewal/project/version.properties +++ b/org.glite.security.proxyrenewal/project/version.properties @@ -1,2 +1,2 @@ -module.version=1.3.2 +module.version=1.3.3 module.age=1 diff --git a/org.glite.security.proxyrenewal/src/api.c b/org.glite.security.proxyrenewal/src/api.c index 850aebf..a72d692 100644 --- a/org.glite.security.proxyrenewal/src/api.c +++ b/org.glite.security.proxyrenewal/src/api.c @@ -210,7 +210,7 @@ do_connect(char *socket_name, struct timeval *timeout, int *sock) struct sockaddr_un my_addr; int s; int ret; - struct timeval before,after,to; + struct timeval before,after; int sock_err; socklen_t err_len; @@ -234,13 +234,13 @@ do_connect(char *socket_name, struct timeval *timeout, int *sock) ret = connect(s, (struct sockaddr *) &my_addr, sizeof(my_addr)); if (ret == -1) { if (errno == EINPROGRESS) { - fd_set fds; + struct pollfd pollfds[1]; - FD_ZERO(&fds); - FD_SET(s, &fds); - memcpy(&to, timeout, sizeof(to)); + pollfds[0].fd = s; + pollfds[0].events = POLLOUT; + gettimeofday(&before,NULL); - switch (select(s+1, NULL, &fds, NULL, &to)) { + switch (poll(pollfds, 1, timeout->tv_sec*1000+timeout->tv_usec/1000)) { case -1: close(s); return errno; case 0: close(s); diff --git a/org.glite.security.proxyrenewal/src/common.c b/org.glite.security.proxyrenewal/src/common.c index 86cfa4a..206bc2f 100644 --- a/org.glite.security.proxyrenewal/src/common.c +++ b/org.glite.security.proxyrenewal/src/common.c @@ -9,19 +9,18 @@ nread(int sock, struct timeval *to, char *buf, size_t buf_len, size_t *read_len) int count; size_t remain = buf_len; char *cbuf = buf; - fd_set fds; - struct timeval timeout,before,after; + struct pollfd pollfds[1]; + struct timeval before,after; int ret; if (to) { - memcpy(&timeout,to,sizeof(timeout)); gettimeofday(&before,NULL); } while (remain > 0) { - FD_ZERO(&fds); - FD_SET(sock,&fds); - switch (select(sock+1, &fds, NULL, NULL, to ? &timeout : NULL)) { + pollfds[0].fd = sock; + pollfds[0].events = POLLIN; + switch (poll(pollfds, 1, to ? (to->tv_sec*1000+to->tv_usec/1000) : INFTIM)) { case 0: ret = EDG_WLPR_ERROR_TIMEOUT; goto end; @@ -68,19 +67,18 @@ nwrite(int sock, struct timeval *to, const char *buf, size_t buf_len) const char *cbuf = buf; int count; size_t remain = buf_len; - fd_set fds; - struct timeval timeout,before,after; + struct pollfd pollfds[1]; + struct timeval before,after; int ret; if (to) { - memcpy(&timeout,to,sizeof(timeout)); gettimeofday(&before,NULL); } while (remain > 0) { - FD_ZERO(&fds); - FD_SET(sock,&fds); - switch (select(sock+1, NULL, &fds, NULL, to ? &timeout : NULL)) { + pollfds[0].fd = sock; + pollfds[0].events = POLLOUT; + switch (poll(pollfds, 1, to ? (to->tv_sec*1000+to->tv_usec/1000) : INFTIM)) { case 0: ret = EDG_WLPR_ERROR_TIMEOUT; goto end; case -1: ret = EDG_WLPR_ERROR_ERRNO; diff --git a/org.glite.security.proxyrenewal/src/renewal_locl.h b/org.glite.security.proxyrenewal/src/renewal_locl.h index 9d0774d..256eb26 100644 --- a/org.glite.security.proxyrenewal/src/renewal_locl.h +++ b/org.glite.security.proxyrenewal/src/renewal_locl.h @@ -22,6 +22,11 @@ #include #include #include +#include +#ifndef INFTIM +#define INFTIM (-1) +#endif + #include #include #include