Skip to content

gluten_lwt.ml / write_loop consumes 100% if remote side closes socket #85

@bewo001

Description

@bewo001

function write_loop in lwt/gluten_lwt.ml fails to check the writev result. If writev writes to a socket, the socket has been closed by the remote side, and SIGPIPE has been disabled, writev will always return `Closed and write_loop will neither exit or yield, locking up the program.
I've fixed the problem by adding a check, but I'm not familiar enough with the code to do a PR.

        match Runtime.next_write_operation t with
        | `Write io_vectors ->
          writev io_vectors >>= fun result ->
          Runtime.report_write_result t result;
          (* added check to exit loop on EPIPE  *)
          if result != `Closed then
              write_loop_step ()
          else
            Lwt.return_unit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions