From 91e20e2c73bf62dca0583feded9c310bfbd53c66 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kou=C5=99il?= Date: Mon, 15 May 2006 08:30:03 +0000 Subject: [PATCH] Transfered patch from HEAD changing the use of select() with poll() in order to allow high fd numbers (bug #16506). --- .../project/version.properties | 2 +- org.glite.security.proxyrenewal/src/api.c | 12 ++++++------ org.glite.security.proxyrenewal/src/common.c | 22 ++++++++++------------ org.glite.security.proxyrenewal/src/renewal_locl.h | 5 +++++ 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/org.glite.security.proxyrenewal/project/version.properties b/org.glite.security.proxyrenewal/project/version.properties index 1d894ad..16a9777 100644 --- a/org.glite.security.proxyrenewal/project/version.properties +++ b/org.glite.security.proxyrenewal/project/version.properties @@ -1,4 +1,4 @@ -module.version = 1.0.18 +module.version = 1.0.19 module.age = 1 diff --git a/org.glite.security.proxyrenewal/src/api.c b/org.glite.security.proxyrenewal/src/api.c index 922931b..6ee0fdc 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 -- 1.8.2.3