apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Molteni <mmolt...@cisco.com>
Subject [PATCH] bug in kqueue implementation of apr_pollset_poll (wrong conversion from usec)
Date Fri, 18 Aug 2006 16:40:00 GMT
Hi,

first of all, thanks for providing APR :-)

I think I've found a bug in the kqueue implementation of apr_pollset_poll().
I am using FreeBSD -current with apr-1.2.7, but the SVN trunk
version of kqueue.c has the same bug:


    232  APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
    233                                             apr_interval_time_t timeout,
    234                                             apr_int32_t *num,
    235                                             const apr_pollfd_t **descriptors)
    236  {
    237      int ret, i;
    238      struct timespec tv, *tvptr;
    239      apr_status_t rv = APR_SUCCESS;
    240  
    241      if (timeout < 0) {
    242          tvptr = NULL;
    243      }
    244      else {
    245          tv.tv_sec = (long) apr_time_sec(timeout);
    246          tv.tv_nsec = (long) apr_time_msec(timeout);
    247          tvptr = &tv;
    248      }


lines 245,246 convert from timeout (usec) to struct timespec, but line 246
assigns milliseconds to nanoseconds, with a wrong magnitude of 10^6.

Net effect is that a timeout of say 999 msec becomes a timeout of 999 nsec.

Please find attached a proposed patch and a test program to expose the bug.

thanks
marco



Mime
View raw message