Skip to content

Commit

Permalink
refactor-request-queue: read loop no longer needs to wake writer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpatti authored and seliopou committed May 19, 2020
1 parent 5a3a572 commit e8386ff
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lib/server_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -252,7 +248,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
Expand Down

0 comments on commit e8386ff

Please sign in to comment.