Skip to content

Change queue item's state in the proper thread

Krzesimir Nowak requested to merge krnowak/libsoup:hang into master

This is to ensure that the state of the item from the session's message queue is modified in the thread that is an owner of the item's async context. Otherwise a race may happen which results in an item that has the async_pending flag set to true, but no GSource is scheduled to process the item. It goes like this:

thread A

  • attaches the gsource to the item's async context in the kick queue function
  • gets preempted

thread B (owner of the item's async context)

  • executes the processing of the item, which does nothing for async item's with the RUNNING state

thread A

  • sets the pending flag to true, but the gsource was already dispatched

This situation may happen when the input stream received from the soup_session_send_finish function is closed in a different thread.

This is related to #100 (closed).

Merge request reports