Skip to content
Snippets Groups Projects

daemon: handle IO error when processing wire buffer

Merged Tomas Krizek requested to merge wirebuf-ioerror into master
  1. Sep 23, 2020
    • Tomas Krizek's avatar
      daemon/worker: fix connection teardown in tls_hs_cb() · f705d23c
      Tomas Krizek authored
      Ensure both tasklist and waitinglist is always cleared when tearing down
      connection (otherwise the session close will fail on assert).
      
      The previous assert could be triggered when the while loop in the code
      above would successfuly perform qr_task_send() for one of the
      tasks in waitinglist and then fail on a subsequent one.
      Verified
      f705d23c
    • Tomas Krizek's avatar
      daemon: handle IO error when processing wire buffer · 8ad2db6e
      Tomas Krizek authored
      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:
      1. We're using a stateful protocol.
      2. Enough data arrive in a single tcp_recv() call to put at least
         two queries into the session's wire buffer.
      3. session_wirebuf_process() calls worker_submit() which calls
         qr_task_step().
      4. In the qr_task_step() the query state changes to KR_STATE_DONE,
         then qr_task_finalize() is called.
      5. qr_task_send() is called, but it fails. This is where
         qr_task_finalize() closes the session, but used to return no error.
      6. When the next query is processed in session_wirebuf_process(),
         steps 3 and 4 are followed and qr_task_finalize() is called.
      7. Since the session is already closed, the assert is triggered.
      
      Debugging this was a lot of fun... All hail the rr debugger!
      Verified
      8ad2db6e
Loading