Skip to content

Conversation

@bytting
Copy link
Contributor

@bytting bytting commented Jul 18, 2017

Rationale:

Readability, SetSocketNonBlocking does what it says on the tin.

Consistency, More consistent with the rest of the API in this unit.

Reusability, SetSocketNonBlocking can also be used by clients that may not want to close the socket on failure.

This also moves the responsibility of closing the socket back to the caller that opened it, which in general should know better how and when to close it.

Copy link
Member

@theuni theuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Can you please squash these together?

@bytting
Copy link
Contributor Author

bytting commented Jul 20, 2017

@theuni, I assume you mean squashing while merging, so nothing for me to do here?

@theuni
Copy link
Member

theuni commented Jul 20, 2017

@corebob No, I mean combining the two commits into a single one, and force-pushing the result. Otherwise the first commit would technically be a regression.

src/netbase.cpp Outdated
Copy link
Member

@laanwj laanwj Jul 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the argument (to SetSocketNonBlocking) can be just SOCKET , or even const SOCKET now that it's no longer changed?

@bytting
Copy link
Contributor Author

bytting commented Jul 20, 2017

I think I got the squashing right, thanks for the assistance 😃

As far as I can see, SOCKET is defined as an unsigned int on both platforms, so passing it by value seems reasonable.

It seems to me that both SetSocketNoDelay, InterrupibleRecv and IsSelectableSocket could benefit from const arguments as well.

PS. I just realized I updated the patch with more code after approval. Maybe that was a bad idea.

@bytting
Copy link
Contributor Author

bytting commented Jul 22, 2017

@theuni
I made an update to this patch. It should now move CloseSocket out of SetSocketNonBlocking and pass sockets as const reference to some utility functions.

Please comment if you have any issues with this.

@bytting bytting changed the title Move CloseSocket out of SetSocketNonBlocking in netbase.cpp Move CloseSocket out of SetSocketNonBlocking and pass socket as const reference Jul 22, 2017
@theuni
Copy link
Member

theuni commented Jul 22, 2017

This makes it more clear what's happening, looks good to me. utACK 05e023f

@laanwj laanwj merged commit 05e023f into bitcoin:master Jul 24, 2017
laanwj added a commit that referenced this pull request Jul 24, 2017
…ocket as const reference

05e023f Move CloseSocket out of SetSocketNonBlocking and pass SOCKET by const reference in SetSocket* functions (Dag Robole)

Pull request description:

  Rationale:

  Readability, SetSocketNonBlocking does what it says on the tin.

  Consistency, More consistent with the rest of the API in this unit.

  Reusability, SetSocketNonBlocking can also be used by clients that may not want to close the socket on failure.

  This also moves the responsibility of closing the socket back to the caller that opened it, which in general should know better how and when to close it.

Tree-SHA512: 85027137f1b626e2b636549ee38cc757a587adcf464c84be6e65ca16e3b75d7ed1a1b21dd70dbe34c7c5d599af39e53b89932dfe3c74f91a22341ff3af5ea80a
@laanwj
Copy link
Member

laanwj commented Jul 25, 2017

ACK

@TheBlueMatt
Copy link
Contributor

Postumous utACK

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
… pass socket as const reference

05e023f Move CloseSocket out of SetSocketNonBlocking and pass SOCKET by const reference in SetSocket* functions (Dag Robole)

Pull request description:

  Rationale:

  Readability, SetSocketNonBlocking does what it says on the tin.

  Consistency, More consistent with the rest of the API in this unit.

  Reusability, SetSocketNonBlocking can also be used by clients that may not want to close the socket on failure.

  This also moves the responsibility of closing the socket back to the caller that opened it, which in general should know better how and when to close it.

Tree-SHA512: 85027137f1b626e2b636549ee38cc757a587adcf464c84be6e65ca16e3b75d7ed1a1b21dd70dbe34c7c5d599af39e53b89932dfe3c74f91a22341ff3af5ea80a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants