On 12/12/2023 8:39 PM, 'Geoff Lankow' via [email protected] wrote:
Hi all, I'm fighting with a race condition. I'm calling output.write
and transport.close but the call to close sometimes happens on the
main thread before the socket thread completes the write:
[Parent 4048037: Main Thread]: D/nsSocketTransport nsSocketTransport::Close
7fc2ecb6f000 reason=0
[Parent 4048037: Main Thread]: D/nsSocketTransport
nsSocketInputStream::CloseWithStatus [this=7fc2ecb6f290 reason=80470002]
[Parent 4048037: Main Thread]: D/nsSocketTransport
nsSocketOutputStream::CloseWithStatus [this=7fc2ecb6f2c8 reason=80470002]
[Parent 4048037: Socket Thread]: D/nsSocketTransport
nsSocketOutputStream::Write [this=7fc2ecb6f2c8 count=52]
When this happens the receiving end doesn't get all of the data and my
tests fail.
How can I be sure the output stream is ready before closing it? There
doesn't appear to be any checks in the code. Is this expected
behaviour or a bug?
So nsSocketOutputStream::CloseWithStatus() with a non-zero reason will
call transport->OnOutputClosed(). If that's called off the socket
thread, it sends a MSG_OUTPUT_CLOSED to the socket thread, so this
should be processed on the socket thread after your write. This should
cause a SOCKET_LOG((" MSG_OUTPUT_CLOSED")) and then a
nsSocketTransport::OnMsgOutputClosed log. Do these happen before or
after the ::Write on Socket Thread?
To help more we'd need more details/code/complete logs. Can you join
us in #necko on matrix?
Thanks!
Randell Jesup, Mozilla Network team
--
You received this message because you are subscribed to the Google Groups
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/de787ada-3f7a-46d8-adb5-031bc464adbf%40mozilla.com.