Correzioni rimaste indietro ed espansione funzioni del resolver.
[gapil.git] / listati / poll_echod.c
index e2e2a9612211c061ddb7aee75f2316b2901e8e55..87eeb9f084ed65040a9c77fd186f41206aa4d74b 100644 (file)
@@ -1,15 +1,13 @@
-    /* initialize all needed variables */
+...
     poll_set = (struct pollfd *) malloc(n * sizeof(struct pollfd));
     max_fd = list_fd;                 /* maximum now is listening socket */
     poll_set = (struct pollfd *) malloc(n * sizeof(struct pollfd));
     max_fd = list_fd;                 /* maximum now is listening socket */
-    for (i=0; i<n; i++) {
+    for (i=0; i<n; i++) {             /* initialize poll set */
        poll_set[i].fd = -1;
        poll_set[i].events = POLLRDNORM;
     }
        poll_set[i].fd = -1;
        poll_set[i].events = POLLRDNORM;
     }
-    poll_set[max_fd].fd = list_fd;
-    /* main loop, wait for connection and data inside a select */
-    while (1) {    
-       while ( ((n = poll(poll_set, max_fd + 1, -1)) < 0) 
-               && (errno == EINTR));         /* wait for data or connection */
+    poll_set[max_fd].fd = list_fd;    
+    while (1) {   /* main loop, wait for connection and data inside a poll */
+       while ( ((n=poll(poll_set, max_fd + 1, -1)) < 0) && (errno == EINTR));
        if (n < 0) {                          /* on real error exit */
            PrintErr("poll error");
            exit(1);
        if (n < 0) {                          /* on real error exit */
            PrintErr("poll error");
            exit(1);
@@ -53,4 +51,4 @@
            }
        }
     }
            }
        }
     }
-    exit(0);     /* normal exit, never reached */
+...