math bug in cm_select_or_poll() ?

Roland C. Dowdeswell elric at imrryr.org
Mon Jan 21 20:53:17 EST 2013


On Mon, Jan 21, 2013 at 07:27:25PM -0500, Richard Silverman wrote:
>

> In src/lib/krb5/os/sendto_kdc.c:cm_select_or_poll(), there is this code:
> 
>          timeout = (in->end_time.tv_sec - now.tv_sec) * 1000 +
>              (in->end_time.tv_usec - now.tv_usec) / 1000;
>      }
>      /* We don't need a separate copy of the selstate for poll, but use one
>       * anyone for consistency with the select wrapper. */
>      *out = *in;
>      *sret = poll(out->fds, out->nfds, timeout);
> 
> Since the poll(2) timeout is in milliseconds, the intent appears to be to
> compute the difference in milliseconds between end_time and now, by
> scaling the seconds portion of the difference up to match the milliseconds
> portion and adding them. Can someone explain what the "/ 1000" is for? It
> looks wrong to me; am I missing something?

tv_usec is microseconds, not milliseconds.  the ``u'' is used as
it is close to mu from the greek alphabet which is generally used
for micro.

--
    Roland Dowdeswell                      http://Imrryr.ORG/~elric/


More information about the krbdev mailing list