Socket timeout bug (?).
Sergei Organov
osv at javad.ru
Mon Sep 16 14:47:45 UTC 2002
This time it seems to be correct.
BR,
Sergei.
Joel Sherrill <joel.sherrill at OARcorp.com> writes:
> Sergei Organov wrote:
> >
> > "Joel Sherrill <joel at OARcorp.com>" <joel.sherrill at OARcorp.com> writes:
> > [...]
> > > I did a search for similar code in the stack and only came up
> > > with rtems/rtems_select.c (select()) which already had a similar
> > > piece of code. It could be doing the same thing a different way
> > > though. Anyway, I am committing this which I believe fixes this
> > > one:
> > >
> > > Index: kern/uipc_socket.c
> > > ===================================================================
> > > RCS file: /usr1/CVS/rtems/cpukit/libnetworking/kern/uipc_socket.c,v
> > > retrieving revision 1.4
> > > diff -u -r1.4 uipc_socket.c
> > > --- kern/uipc_socket.c 11 Jun 1999 14:11:41 -0000 1.4
> > > +++ kern/uipc_socket.c 14 Sep 2002 18:27:39 -0000
> > > @@ -961,6 +961,8 @@
> > > goto bad;
> > > }
> > > val = tv->tv_sec * hz + tv->tv_usec / tick;
> > > + if (val == 0)
> > > + val = 1;
> >
> > I worry if the case when timeout is set to exact 0 goes through this path? If
> > so, the patch wold break "wait forever" behavior of timeout 0.
>
> How about this version then? It is pretty explicit about asking for
> timeout 0.
>
> @@ -960,7 +960,13 @@
> error = EDOM;
> goto bad;
> }
> - val = tv->tv_sec * hz + tv->tv_usec / tick;
> +
> + if ( tv->tv_sec || tv->tv_usec ) {
> + val = tv->tv_sec * hz + tv->tv_usec /
> tick;
> + if (val == 0)
> + val = 1;
> + } else
> + val = 0;
>
> > BR,
> > Sergei.
>
> --
> Joel Sherrill, Ph.D. Director of Research & Development
> joel at OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
More information about the users
mailing list