[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [JDEV] Minor 'bug'let ?



Jeremie wrote:
> 
> On the FD_SETSIZE issue in io.c, I updated it to track the largest
> descriptor and use that value... attached is the diff I'm going to check
> in tonight, let me know if it's wrong or broken...

Looks ok at first glance.. but it does not seem to track the write_fds.
(Though
from code logic I would assume that you always do a read and sometimes a
right
so the max from the writes is <= the max from the reads.

Dw.

> 
>   ------------------------------------------------------------------------
> Index: io.c
> ===================================================================
> RCS file: /work/cvs/jap/common/io.c,v
> retrieving revision 1.9
> diff -u -r1.9 io.c
> --- io.c        1999/01/05 20:30:10     1.9
> +++ io.c        1999/01/08 03:25:58
> @@ -13,7 +13,7 @@
>  void collect_packets(conn *(*handle_packet)())
>  {
>         char buffer[MAXMSG];
> -       int new, nbytes, err, first = 1;
> +       int new, nbytes, err, maxfd = 0, first = 1;
>         fd_set active_fd_set, read_fd_set, write_fd_set;
>         struct sockaddr_in sa;
>         size_t size = sizeof(sa);
> @@ -37,7 +37,7 @@
>                 if(!first)
>                 {
>                         DBUG("IO: waiting ","")
> -                       h_err(select(FD_SETSIZE, &read_fd_set, &write_fd_set, NULL, NULL),"select");
> +                       h_err(select(maxfd + 1, &read_fd_set, &write_fd_set, NULL, NULL),"select");
> 
>                         FD_ZERO(&active_fd_set);
>                 }else{
> @@ -63,6 +63,8 @@
>                                         c = conn_add(c,new);
>                                         c->name = strdup(inet_ntoa(sa.sin_addr));
>                                         c->ver = strdup(c_count->name); /* express the parent socket that it was created from */
> +                                       if(new > maxfd)
> +                                               maxfd = new;
>                                         FD_SET(new, &active_fd_set);
>                                 }else{
>                                         DBUG("IO: reading data from ",c_count->name)
> @@ -86,6 +88,8 @@
>                                         }
>                                 }
>                         }
> +                       if(c_count->id > maxfd)
> +                               maxfd = c_count->id;
>                         FD_SET(c_count->id, &active_fd_set);
>                         c_count = c_count->next;
>                 }
begin:vcard 
n:van Gulik;Dirk-Willem
tel;fax:+39 0332 78 9185
tel;work:+39 0332 78 9549
x-mozilla-html:FALSE
url:http://me-www.jrc.it/~dirkx
org:Joint Research Center of the European Commission;Software Technology and Applications, Institute for Systems, Informatics and Security
version:2.1
email;internet:Dirk.vanGulik@jrc.it
title:Mr
adr;quoted-printable:;;TP 270 - ISIS/STA=0D=0AJoint Resarch Center;Ispra;VA;21020;Italy
x-mozilla-cpt:;0
fn:Dirk-Willem van Gulik
end:vcard