-
Notifications
You must be signed in to change notification settings - Fork 36.9k
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
net: convert standalone IsSelectableSocket() and SetSocketNonBlocking() to Sock methods #25421
net: convert standalone IsSelectableSocket() and SetSocketNonBlocking() to Sock methods #25421
Conversation
Concept ACK. These methods clearly belong to the |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Looks like this is the last one to go for #21878? Needs rebase, though. |
e7b846a
to
0c4516b
Compare
There is more! :) will be two more PRs:
|
This could be easier to review if you did a MOVEONLY commit before/after the changes |
0c4516b
to
e99a11e
Compare
Cumulative diff is identical before and after this forced push: before:
Better now? |
Concept ACK |
To be converted to a method of the `Sock` class.
This makes the callers mockable.
To be converted to a method of the `Sock` class.
This further encapsulates syscalls inside the `Sock` class. Co-authored-by: practicalswift <[email protected]>
e99a11e
to
b527b54
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK b527b54 review/debug build/unit tests at each commit, cross-referenced the changes with man select
and man errno
, ran a signet node on the last commit with ip4/ip6//tor/i2p/cjdns and network connections were nominal
One global nit, this pull uses the doxygen format for classes on methods and variables that have a different doxygen format, per our developer notes.
That is for consistency with surrounding code and because I assume (assumed) any doxygen-compatible comment is acceptable since the doxygen generated docs are identical either way. If it is desirable I could change all of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK b527b54
} | ||
#else | ||
const int flags{fcntl(m_socket, F_GETFL, 0)}; | ||
if (flags == SOCKET_ERROR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were previously not checking for an error on this fcntl
call. Is that really necessary or would the next fcntl
call fail when being passed SOCKET_ERROR | O_NONBLOCK
?
(Not against adding the error check, just wanted to note that i noticed the addition)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if the next fcntl()
call would fail. The doc is a bit unclear what happens when passed unknown/invalid flags to fcntl()
. Also, given that SOCKET_ERROR
is -1
and O_NONBLOCK
is 0x0004
, then what is -1 | 0x0004
? It is -1
actually, but is definitely something we don't want to do.
… SetSocketNonBlocking() to Sock methods b527b54 net: convert standalone SetSocketNonBlocking() to Sock::SetNonBlocking() (Vasil Dimov) 29f66f7 moveonly: move SetSocketNonBlocking() from netbase to util/sock (Vasil Dimov) b4bac55 net: convert standalone IsSelectableSocket() to Sock::IsSelectable() (Vasil Dimov) 5db7d2c moveonly: move IsSelectableSocket() from compat.h to sock.{h,cpp} (Vasil Dimov) Pull request description: _This is a piece of bitcoin#21878, chopped off to ease review._ * convert standalone `IsSelectableSocket()` to `Sock::IsSelectable()` * convert standalone `SetSocketNonBlocking()` to `Sock::SetNonBlocking()` This further encapsulates syscalls inside the `Sock` class and makes the callers mockable. ACKs for top commit: jonatack: ACK b527b54 review/debug build/unit tests at each commit, cross-referenced the changes with `man select` and `man errno`, ran a signet node on the last commit with ip4/ip6//tor/i2p/cjdns and network connections were nominal dergoegge: Code review ACK b527b54 Tree-SHA512: af783ce558c7a89e173f7ab323fb3517103d765c19b5d14de29f64706b4e1fea3653492e8ea73ae972699986aaddf2ae72c7cfaa7dad7614254283083b7d2632
This is a piece of #21878, chopped off to ease review.
IsSelectableSocket()
toSock::IsSelectable()
SetSocketNonBlocking()
toSock::SetNonBlocking()
This further encapsulates syscalls inside the
Sock
class and makes the callers mockable.