[haiku-3rdparty-dev] Re: port problems

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: "haiku-3rdparty-dev@xxxxxxxxxxxxx" <haiku-3rdparty-dev@xxxxxxxxxxxxx>
  • Date: Thu, 2 Jun 2016 07:54:32 -0400

Hi Sean,

On Wed, Jun 1, 2016 at 11:40 PM, Sean Healy <jalopeura@xxxxxxxxxxx> wrote:

Has anyone ever run into BLooper hanging during port_buffer_size_etc(), even
though there are messages in the port queue?

I can't say I've seen the described behavior here in any case. Do you
have a simplified testcase that reliably reproduces it? If so, it
would be interesting to analyze.

It's possible that it may be in that "while bufferSize == B_INTERRUPTED"
loop in ReadRawFromPort() that continually calls port_buffer_size_etc() -
every time I hit Run and then Debug again in the debugger, it's on a call to
port_buffer_size_etc(). But in that case what would be continually
interrupting that call to cause that loop?

Finding a looper thread there is more or less to be expected under
normal circumstances. MessageFromPort() by default specifies
B_INFINITE_TIMEOUT as its wait timeout. As such, until there is
something in the port, read_port_etc, and by extension
port_buffer_size_etc will wait indefinitely in the kernel until
there's something to return, unless of course something's going wrong
and the port subsystem never actually wakes up that thread. You could
try modifying http://cgit.haiku-os.org/haiku/tree/src/kits/app/Looper.cpp#n1120
to specify an explicit non-infinite timeout and see if 1) it does come
back, and 2) if the subsequent attempt to call MessageFromPort does
wind up picking up the message in question, which would imply there's
a race condition somewhere with regards to notifying an existing
waiter.

Regards,

Rene

Other related posts: