-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send
should check socket status and fail if the socket is closed
#169
Comments
Bump. Will you accept a PR fixing the code to match the documentations? Note that is will add one Alternatively will you accept a PR fixing the documentation to match the implementation? |
Please submit the PR and we can discuss the cost and benefit. Checking seems like the right thing to do. |
@eborden Thank you for your response! Which PR should I send? The one that fixes the code or that fixes documentation? I don't think Checking socket status without locking can help to make the issue more visible, though it will not really fix. I think that fixing documentation is the first step. |
Add a note that sending data to or receiving data from closed socket in unsafe. See haskell#169
I'd prefer the bug fix over a doc fix. A naive implementation using an mvar can get the ball rolling and we can refine from there. Likely the read/write lock is the final destination, but high level code can suss out some details first. Thanks for being persistent with this issue. |
It is unsafe to write or read to closed FD because OS is free to reuse it, so it may lead to writing to some other destination. See haskell#169
I discussed this with my friend.
What do you think, guys? |
It is definitely better then doing nothing. And the documentation for the old API should be updated to describe the issue and point to |
Add a note that sending data to or receiving data from closed socket in unsafe. See haskell#169
I'm working on a PR with a |
Add a note that sending data to or receiving data from closed socket in unsafe. See haskell#169
Add a note that sending data to or receiving data from closed socket in unsafe. See #169
I close this in favor of #212. |
The
Network.Socket.close
claims thatIt changes socket state to
Closed
and callsclose(2)
C function, so OS is free to reuse the FD.But
Network.Socket.send
and friends don't check socket status. When sending data to a closed socket usually an exception is thrown (close(2)
returnsEBADF
), but there is a chance that the FD is reused afterclose
but beforesend
, so the data will be silently sent to a wrong destination.One can argue that writing to a closed socket is a bad practice anyway, then please consider it as a documentation bug.
The text was updated successfully, but these errors were encountered: