Skip to content
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

Set SO_REUSEPORT for the libevent driver on BSD/macOS, too. #1972

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion core/vibe/core/drivers/libevent2.d
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ final class Libevent2Driver : EventDriver {
int tmp_reuse = 1;
socketEnforce(() @trusted { return setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &tmp_reuse, tmp_reuse.sizeof); } () == 0,
"Error enabling socket address reuse on listening socket");
version (linux) {
static if (is(typeof(SO_REUSEPORT))) {
if (options & TCPListenOptions.reusePort) {
if (() @trusted { return setsockopt(listenfd, SOL_SOCKET, SO_REUSEPORT, &tmp_reuse, tmp_reuse.sizeof); } ()) {
if (errno != EINVAL && errno != ENOPROTOOPT) {
Expand Down
9 changes: 4 additions & 5 deletions core/vibe/core/drivers/utils.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ version (Windows) {
alias SystemSocketException = WSAErrorException;
} else alias SystemSocketException = ErrnoException;

version (linux) {
import core.sys.posix.sys.socket;
static if (!is(typeof(SO_REUSEPORT))) {
enum { SO_REUSEPORT = 15 }
}
import core.sys.posix.sys.socket;
static if (!is(typeof(SO_REUSEPORT))) {
version (linux) enum SO_REUSEPORT = 15;
else enum SO_REUSEPORT = 0x200;
}

T socketEnforce(T)(T value, lazy string msg = null, string file = __FILE__, size_t line = __LINE__)
Expand Down