Re: [PATCH v2] compat: Add another rudimentary poll() emulation
- From
- Albert Dvornik <dvornik+git@gmail.com>
- Date
- May 31, 2010, 12:12 UTC
- Message-ID
- <AANLkTinNHDZD-9uQjWr8N97tgP1SP9angXlXMUUc673x@mail.gmail.com>
- In-Reply-To
- <20100530003718.GA27024@progeny.tock>
On Sat, May 29, 2010 at 8:37 PM, Jonathan Nieder <jrnieder@gmail.com> wrote: [,,,]
Show 7 quoted lines
> +static int msleep(int timeout)
> +{
> + struct timeval tv;
> + tv.tv_sec = 0;
> + tv.tv_usec = 1000 * timeout;
> + return select(0, NULL, NULL, NULL, &tv);
> +}This code will do the right thing only when timeout is < 1000. (This
is probably true for us in practice, so this is likely just
nitpicking.) For the general case, you'd want
tv.tv_sec = timeout / 1000;
tv.tv_usec = 1000 * (timeout % 1000);--bert