Transfered patch from HEAD changing the use of select() with poll() in order to glite-security-proxyrenewal_R_1_3_3 glite-security-proxyrenewal_R_1_3_3_1 merge2head_after
authorDaniel Kouřil <kouril@ics.muni.cz>
Mon, 15 May 2006 08:34:41 +0000 (08:34 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Mon, 15 May 2006 08:34:41 +0000 (08:34 +0000)
allow high fd numbers (bug #16506).

org.glite.security.proxyrenewal/project/version.properties
org.glite.security.proxyrenewal/src/api.c
org.glite.security.proxyrenewal/src/common.c
org.glite.security.proxyrenewal/src/renewal_locl.h

index 850aebf..a72d692 100644 (file)
@@ -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);
index 86cfa4a..206bc2f 100644 (file)
@@ -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;
index 9d0774d..256eb26 100644 (file)
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <sys/wait.h>
+#include <poll.h>
+#ifndef INFTIM
+#define INFTIM (-1)
+#endif
+
 #include <openssl/md5.h>
 #include <openssl/x509.h>
 #include <openssl/pem.h>