Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 May 2007 17:25:36 +0200
From:      des@des.no (Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?=)
To:        MQ <antinvidia@gmail.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: A problem with the select(2) interface
Message-ID:  <86odknqvf3.fsf@dwp.des.no>
In-Reply-To: <be0088ce0705140729m4c24f2cbr21f6f050aac75c89@mail.gmail.com> (antinvidia@gmail.com's message of "Mon\, 14 May 2007 22\:29\:15 %2B0800")
References:  <be0088ce0705140729m4c24f2cbr21f6f050aac75c89@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
MQ <antinvidia@gmail.com> writes:
> I'm writing a network application these days, for compatibility, I choose
> the select(2) interface to do event polling. When using it, I'm curious
> about the fact that the type of the final parameter is `struct timeval *'=
. I
> skimmed through the codes in /sys/kern/sys_generic.c, there is nothing
> written to this address. So, I think if we can use `const struct timeval =
*'
> instead? This type can inform the users explicitly that we do NOT modify =
the
> timeval struct. But I'm not sure if this modification will conflict with =
the
> POSIX standard. Will you please tell me your considerations? Any suggesti=
ons
> will be appreciated.

According to POSIX, the struct timeval may be updated to reflect the
amount of time left if select() returns early (so you can call select()
again with the same struct timeval and hit your original deadline).  In
reality, there is so much old code around that depends on it *not* being
updated that this has never been implemented.

This is often mentioned as an example of why blindly implementing a
standard is not a good idea.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86odknqvf3.fsf>