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

Enable SO_REUSE{ADDR,PORT} for renderd TCP/IP server sockets #460

Merged
merged 1 commit into from
Jul 11, 2024
Merged
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
14 changes: 14 additions & 0 deletions src/renderd.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ int server_socket_init(renderd_config *sConfig)
int fd;

if (sConfig->ipport > 0) {
const int enable = 1;

g_logger(G_LOG_LEVEL_INFO, "Initialising TCP/IP server socket on %s:%i",
sConfig->iphostname, sConfig->ipport);
fd = socket(PF_INET6, SOCK_STREAM, 0);
Expand All @@ -503,6 +505,18 @@ int server_socket_init(renderd_config *sConfig)
exit(2);
}

if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < 0) {
g_logger(G_LOG_LEVEL_CRITICAL, "setsockopt SO_REUSEADDR failed for: %s:%i",
sConfig->iphostname, sConfig->ipport);
exit(3);
}

if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable)) < 0) {
g_logger(G_LOG_LEVEL_CRITICAL, "setsockopt SO_REUSEPORT failed for: %s:%i",
sConfig->iphostname, sConfig->ipport);
exit(3);
}

bzero(&addrI, sizeof(addrI));
addrI.sin6_family = AF_INET6;
addrI.sin6_addr = in6addr_any;
Expand Down
Loading