Skip to content

Commit 47528e1

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 6250ee3 commit 47528e1

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
@@ -202,20 +202,16 @@ let rec _next_read_operation t =
202202
)
203203

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

221217
let next_read_operation t =
@@ -259,7 +255,12 @@ let rec _next_write_operation t =
259255
) else (
260256
let reqd = current_reqd_exn t in
261257
match Reqd.output_state reqd with
262-
| Waiting -> `Yield
258+
| Waiting ->
259+
(* XXX(dpatti): I don't think we should need to call this, but it is
260+
necessary in the case of a streaming, non-chunked body so that you can
261+
set the appropriate flag. *)
262+
Reqd.flush_response_body reqd;
263+
Writer.next t.writer
263264
| Ready ->
264265
Reqd.flush_response_body reqd;
265266
Writer.next t.writer

0 commit comments

Comments
 (0)