[JDEV] Minor 'bug'let ?

Dirk-Willem van Gulik dirk.vangulik at jrc.it
Fri Jan 8 03:16:13 CST 1999


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;
>                 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Dirk.VanGulik.vcf
Type: text/x-vcard
Size: 477 bytes
Desc: Card for Dirk-Willem van Gulik
URL: <http://mail.jabber.org/pipermail/jdev/attachments/19990108/805a12c5/attachment-0002.vcf>


More information about the JDev mailing list