Skip to content

Lwt_io.establish_server (TCP servers): expose client socket to connection-handling callback#586

Merged
aantron merged 4 commits into
masterfrom
establish-server-fd
Jun 20, 2018
Merged

Lwt_io.establish_server (TCP servers): expose client socket to connection-handling callback#586
aantron merged 4 commits into
masterfrom
establish-server-fd

Conversation

@aantron
Copy link
Copy Markdown
Collaborator

@aantron aantron commented Apr 29, 2018

This is a follow-on to #323/#346 (cc @rgrinberg). It adds a function like:

val establish_server_with_client_socket :
  Unix.sockaddr ->
  (Unix.sockaddr -> Lwt_unix.file_descr -> (input_channel * output_channel) -> unit Lwt.t) ->
    server Lwt.t

...whereas existing versions of this function didn't pass the Lwt_unix.file_descr to the client-handling function, and only passed the sockaddr and the two channels.

I'm still not sure if this is the right API, but starting with this.

The PR also includes a pretty thorough cleanup of the existing code, so it should be easier to keep working on.

aantron added 4 commits April 29, 2018 00:35
This commit consists of whitespace edits and alpha-renaming.
- Avoid Lwt.wakeup (synchronous control flow transfer). Use
  Lwt.wakeup_later.
- Use Lwt.async instead of Lwt.ignore_result. This has the side effect
  that exceptions during server startup (bind, listen) now go into
  rejecting the promise that Lwt_io.establish_server returns. Before,
  they were raised up the stack. This behavior was not specified,
  however. Most users can be expected to be ready for both behaviors,
  and the old behavior was a bug.
@aantron
Copy link
Copy Markdown
Collaborator Author

aantron commented Jun 20, 2018

This was motivated by inhabitedtype/httpaf#54. inhabitedtype/httpaf#53 also anticipated the type signature of establish_server_with_client_socket, so merging.

@aantron aantron merged commit 2d604f9 into master Jun 20, 2018
@aantron aantron deleted the establish-server-fd branch June 27, 2018 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant