daemon: handle IO error when processing wire buffer
This fixes the following assert:
daemon/worker.c:1157: qr_task_finalize: Assertion '!session_flags(source_session)->closing' failed.
Scenario which leads to the above error:
- We're using a stateful protocol.
- Enough data arrive in a single
tcp_recv()
call to put at least two queries into the session's wire buffer. -
session_wirebuf_process()
callsworker_submit()
which callsqr_task_step()
. - In the
qr_task_step()
the query state changes toKR_STATE_DONE
, thenqr_task_finalize()
is called. -
qr_task_send()
is called, but it fails. This is whereqr_task_finalize()
closes the session, but used to return no error. - When the next query is processed in
session_wirebuf_process()
, steps 3 and 4 are followed andqr_task_finalize()
is called. - Since the session is already closed, the assert is triggered.
Debugging this was a lot of fun... All hail the rr debugger!
Edited by Tomas Krizek