From 96bfcbcef149b8af16a255a4fb4d6d9708eb1ffe Mon Sep 17 00:00:00 2001 From: Doug Patti Date: Sat, 16 May 2020 15:11:13 -0400 Subject: [PATCH] refactor-request-queue: read loop no longer needs to wake writer This is because the writer is always woken by the appropriate calls that push chunks onto the body or writer or calls that close the body. Had to import an additional line from a recent band-aid fix regarding setting the flag on non-chunked streaming responses. It feels like we should find an alternative means of maintaining this piece of information. --- lib/server_connection.ml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/server_connection.ml b/lib/server_connection.ml index 959d542d..db6f08ef 100644 --- a/lib/server_connection.ml +++ b/lib/server_connection.ml @@ -202,20 +202,16 @@ let rec _next_read_operation t = ) and _final_read_operation_for t reqd = - let next = - if not (Reqd.persistent_connection reqd) then ( - shutdown_reader t; - Reader.next t.reader; - ) else ( - match Reqd.output_state reqd with - | Waiting | Ready -> `Yield - | Complete -> - advance_request_queue t; - _next_read_operation t; - ) - in - wakeup_writer t; - next + if not (Reqd.persistent_connection reqd) then ( + shutdown_reader t; + Reader.next t.reader; + ) else ( + match Reqd.output_state reqd with + | Waiting | Ready -> `Yield + | Complete -> + advance_request_queue t; + _next_read_operation t; + ) ;; let next_read_operation t = @@ -259,7 +255,12 @@ let rec _next_write_operation t = ) else ( let reqd = current_reqd_exn t in match Reqd.output_state reqd with - | Waiting -> `Yield + | Waiting -> + (* XXX(dpatti): I don't think we should need to call this, but it is + necessary in the case of a streaming, non-chunked body so that you can + set the appropriate flag. *) + Reqd.flush_response_body reqd; + Writer.next t.writer | Ready -> Reqd.flush_response_body reqd; Writer.next t.writer