math bug in cm_select_or_poll() ?

Richard Silverman res at
Mon Jan 21 19:27:25 EST 2013


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?

(Also, unrelated typo: "anyone" should be "anyway," I assume.)



More information about the krbdev mailing list