Socket: adds closeOnDestruction flag to ctor arguments#11041
Closed
denizzzka wants to merge 1 commit into
Closed
Conversation
3 tasks
Contributor
|
When I said flag I meant: https://dlang.org/phobos/std_typecons.html#Flag I'll leave it to others to decide if this is a requirement or not. |
ebee0ae to
f72a486
Compare
f72a486 to
c4a3809
Compare
Contributor
Author
|
A workaround for this problem was devised: #11040 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
There is a case that is not covered by the
std.socket.Socket:When we get a ready-made socket_t from somewhere (from a 3rd-party library, for example), using it idiomatically in the D style, and after it we should just leave the socket "as is", because all other handling of this socket_t is performed by 3rd-party code.
Currently, if we want to do it this way, we have to duplicate the socket:
https://github.com/denizzzka/dpq2/blob/master/src/dpq2/connection.d#L227
and then
Socketwill close duplicate in desctructor without side-effects.Solution
closeOnDestructionflag added into ctor arguments, it allows not close underlying system socket in the destructor ofSocketPre-review checklist
I think this case doesn't need testing.