Re: Question about socket timeouts

看板FB_current作者時間12年前 (2013/08/22 05:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/9 (看更多)
On Monday, August 19, 2013 11:13:02 pm Daniel Eischen wrote: > On Mon, 19 Aug 2013, Adrian Chadd wrote: > > > Yes! Please file a PR! > > This sorta implies that both are acceptable (although, > the Linux behavior seems more desirable). > > http://austingroupbugs.net/view.php?id=369 No, that says "round up", so it does mean that the requested timeout should be the minimum amount slept. tvtohz() does this. Really odd that the socket code is using its own version of this rather than tvtohz(). Oh, I bet this just predates tvtohz(). Interesting that it keeps getting bug fixes in its history that simply using tvtohz() would have solved. Try this: Index: uipc_socket.c =================================================================== --- uipc_socket.c (revision 254570) +++ uipc_socket.c (working copy) @@ -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: -- John Baldwin _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1I5J7IN4 (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1I5J7IN4 (FB_current)