X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2Fselect_echod.c;h=7687310de7cdd4e19fe27fb04119483fb085a900;hp=d06b14ea503d7a5b0ada8077284c8af060826780;hb=fbaf3a4f4f6fe16f6f2233f7165bbfa77557e32e;hpb=de137402ded9a730854f908315767d73c5308d9d diff --git a/listati/select_echod.c b/listati/select_echod.c index d06b14e..7687310 100644 --- a/listati/select_echod.c +++ b/listati/select_echod.c @@ -2,12 +2,10 @@ memset(fd_open, 0, FD_SETSIZE); /* clear array of open files */ max_fd = list_fd; /* maximum now is listening socket */ fd_open[max_fd] = 1; - /* main loop, wait for connection and data inside a select */ - while (1) { - FD_ZERO(&fset); /* clear fd_set */ - for (i = list_fd; i <= max_fd; i++) { /* initialize fd_set */ + while (1) { /* main loop, wait for connection and data inside a select */ + FD_ZERO(&fset); /* clear fd_set */ + for (i = list_fd; i <= max_fd; i++) /* initialize fd_set */ if (fd_open[i] != 0) FD_SET(i, &fset); - } while ( ((n = select(max_fd + 1, &fset, NULL, NULL, NULL)) < 0) && (errno == EINTR)); /* wait for data or connection */ if (n < 0) { /* on real error exit */ @@ -24,10 +22,9 @@ fd_open[fd] = 1; /* set new connection socket */ if (max_fd < fd) max_fd = fd; /* if needed set new maximum */ } - /* loop on open connections */ - i = list_fd; /* first socket to look */ - while (n != 0) { /* loop until active */ - i++; /* start after listening socket */ + i = list_fd; /* first socket to look */ + while (n != 0) { /* loop on open connections */ + i++; /* start after listening socket */ if (fd_open[i] == 0) continue; /* closed, go next */ if (FD_ISSET(i, &fset)) { /* if active process it*/ n--; /* decrease active */