Skip to content

fix(Network.Gopher): give client time to close client socket; refactor haskell-socket utilities - #44

Merged
sternenseemann merged 3 commits into
masterfrom
issue-42
Mar 15, 2021
Merged

sternenseemann merged 3 commits into
masterfrom
issue-42

Conversation

@sternenseemann

Copy link
Copy Markdown
Owner

No description provided.

Move file descriptor conversion into top level bindings, throw
IOExceptions on errors and document them.

SystemdException no longer contains the invalid file descriptor
exception.
Mimic the behavior of 'close' in toFd: replace the old file descriptor
with (-1). This ensures that further calls on the 'Socket' are “safe” in
a sense as they won't block indefinetely. Instead they will throw an
exception as if close was called on the Socket.
After sending the response, we now send TCP FIN by calling shutdown(2)
on the socket. We then wait up to 1 second for the client to finish
reading and closing the socket on their end before finally closing the
socket on our side. This prevents read broken pipes for clients like
curl which would occasionally happen.

Resolves #42.
@sternenseemann
sternenseemann merged commit 7e704eb into master Mar 15, 2021
@sternenseemann
sternenseemann deleted the issue-42 branch March 15, 2021 00:47
@sternenseemann
sternenseemann restored the issue-42 branch March 15, 2021 12:40
@sternenseemann
sternenseemann deleted the issue-42 branch March 15, 2021 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant