[haiku-bugs] Re: [Haiku] #9734: Receiving from a nonblocking socket causes "Operation timed out" error

  • From: "bonefish" <trac@xxxxxxxxxxxx>
  • Date: Fri, 03 May 2013 12:10:49 -0000

#9734: Receiving from a nonblocking socket causes "Operation timed out" error
--------------------------------------+----------------------------
   Reporter:  markh                   |      Owner:  zooey
       Type:  bug                     |     Status:  new
   Priority:  normal                  |  Milestone:  R1
  Component:  Network & Internet/UDP  |    Version:  R1/Development
 Resolution:                          |   Keywords:
 Blocked By:                          |   Blocking:
Has a Patch:  0                       |   Platform:  All
--------------------------------------+----------------------------

Comment (by bonefish):

 Replying to [comment:2 phoudoin]:
 > I wonder why absolute timeout is used instead of relative one anyway?

 Usually it is necessary to convert relative timeouts to absolute ones, so
 that syscall aren't restarted with the full timeout each time. That might
 not be relevant here. Another reason (actually the same, just generalized)
 to convert to absolute is, if there are potentially multiple waits ahead.

 I think the best way to do the timeout conversion is to always pass on a
 `(bigtime_t, uint32)` pair (make it a helper class, if you want something
 more handy to pass around). In the zero timeout case the conversion result
 would then be `(0, B_RELATIVE_TIMEOUT)` and the correct return code would
 be generated automatically. I would handle a 0 absolute timeout specially
 only if BeOS does. I don't have a BeOS installation at hand ATM, though.

 An alternative for your case might be to check the return code and, if it
 is `B_TIMED_OUT` convert to `B_WOULD_BLOCK`, if the timeout is 0. Not that
 elegant, but IIRC other code does it the same way.

--
Ticket URL: <http://dev.haiku-os.org/ticket/9734#comment:3>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: