Skip to content

SERVER-107969 Fix socket option update exceeding max value #1618

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mongo/util/net/socket_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ void setSocketKeepAliveParams(int sock,
}
#elif defined(__APPLE__) || defined(__linux__)
const auto updateSockOpt = [&](int level, int optnum, Seconds maxVal, StringData optname) {
Seconds optVal{1};
unsigned int rawOptVal = durationCount<Seconds>(optVal);
unsigned int rawOptVal = 1;
socklen_t optValLen = sizeof(rawOptVal);

if (getsockopt(sock, level, optnum, reinterpret_cast<char*>(&rawOptVal), &optValLen)) {
Expand All @@ -176,6 +175,7 @@ void setSocketKeepAliveParams(int sock,
"error"_attr = errorMessage(ec));
}

Seconds optVal = Seconds{rawOptVal};
if (optVal > maxVal) {
unsigned int rawMaxVal = durationCount<Seconds>(maxVal);
socklen_t maxValLen = sizeof(rawMaxVal);
Expand Down