Use tvtohz() to convert a socket buffer timeout to a tick value rather
than using a home-rolled version. The home-rolled version could result in shorter-than-requested sleeps. Reported by: Vitja Makarov <vitja.makarov@gmail.com> MFC after: 2 weeks
This commit is contained in:
parent
b32840d048
commit
e77c507d60
@ -2699,21 +2699,16 @@ sosetopt(struct socket *so, struct sockopt *sopt)
|
||||
if (error)
|
||||
goto bad;
|
||||
|
||||
/* assert(hz > 0); */
|
||||
if (tv.tv_sec < 0 || tv.tv_sec > INT_MAX / hz ||
|
||||
tv.tv_usec < 0 || tv.tv_usec >= 1000000) {
|
||||
error = EDOM;
|
||||
goto bad;
|
||||
}
|
||||
/* assert(tick > 0); */
|
||||
/* assert(ULONG_MAX - INT_MAX >= 1000000); */
|
||||
val = (u_long)(tv.tv_sec * hz) + tv.tv_usec / tick;
|
||||
if (val > INT_MAX) {
|
||||
val = tvtohz(&tv);
|
||||
if (val == INT_MAX) {
|
||||
error = EDOM;
|
||||
goto bad;
|
||||
}
|
||||
if (val == 0 && tv.tv_usec != 0)
|
||||
val = 1;
|
||||
|
||||
switch (sopt->sopt_name) {
|
||||
case SO_SNDTIMEO:
|
||||
|
Loading…
x
Reference in New Issue
Block a user