Skip to content

Commit 94db517

Browse files
committed
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.
1 parent 39d8c7b commit 94db517

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

lib/server_connection.ml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,16 @@ let rec _next_read_operation t =
201201
)
202202

203203
and _final_read_operation_for t reqd =
204-
let next =
205-
if not (Reqd.persistent_connection reqd) then (
206-
shutdown_reader t;
207-
Reader.next t.reader;
208-
) else (
209-
match Reqd.output_state reqd with
210-
| Waiting | Ready -> `Yield
211-
| Complete ->
212-
advance_request_queue t;
213-
_next_read_operation t;
214-
)
215-
in
216-
wakeup_writer t;
217-
next
204+
if not (Reqd.persistent_connection reqd) then (
205+
shutdown_reader t;
206+
Reader.next t.reader;
207+
) else (
208+
match Reqd.output_state reqd with
209+
| Waiting | Ready -> `Yield
210+
| Complete ->
211+
advance_request_queue t;
212+
_next_read_operation t;
213+
)
218214
;;
219215

220216
let next_read_operation t =
@@ -251,7 +247,12 @@ let rec _next_write_operation t =
251247
) else (
252248
let reqd = current_reqd_exn t in
253249
match Reqd.output_state reqd with
254-
| Waiting -> `Yield
250+
| Waiting ->
251+
(* XXX(dpatti): I don't think we should need to call this, but it is
252+
necessary in the case of a streaming, non-chunked body so that you can
253+
set the appropriate flag. *)
254+
Reqd.flush_response_body reqd;
255+
Writer.next t.writer
255256
| Ready ->
256257
Reqd.flush_response_body reqd;
257258
Writer.next t.writer

0 commit comments

Comments
 (0)