572a44
From 9dda034962ef7d339f07e5cdeae87f34db970431 Mon Sep 17 00:00:00 2001
572a44
From: Shawn Landden <shawn@churchofgit.com>
572a44
Date: Sat, 16 Nov 2013 13:18:13 -0800
572a44
Subject: [PATCH] core/socket: fix SO_REUSEPORT
572a44
572a44
---
572a44
 src/core/load-fragment-gperf.gperf.m4 | 1 +
572a44
 src/core/socket.c                     | 2 +-
572a44
 2 files changed, 2 insertions(+), 1 deletion(-)
572a44
572a44
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
572a44
index 31fb7bc..d65bcc1 100644
572a44
--- a/src/core/load-fragment-gperf.gperf.m4
572a44
+++ b/src/core/load-fragment-gperf.gperf.m4
572a44
@@ -211,6 +211,7 @@ Socket.Broadcast,                config_parse_bool,                  0,
572a44
 Socket.PassCredentials,          config_parse_bool,                  0,                             offsetof(Socket, pass_cred)
572a44
 Socket.PassSecurity,             config_parse_bool,                  0,                             offsetof(Socket, pass_sec)
572a44
 Socket.TCPCongestion,            config_parse_string,                0,                             offsetof(Socket, tcp_congestion)
572a44
+Socket.ReusePort,                config_parse_bool,                  0,                             offsetof(Socket, reuseport)
572a44
 Socket.MessageQueueMaxMessages,  config_parse_long,                  0,                             offsetof(Socket, mq_maxmsg)
572a44
 Socket.MessageQueueMessageSize,  config_parse_long,                  0,                             offsetof(Socket, mq_msgsize)
572a44
 Socket.Service,                  config_parse_socket_service,        0,                             0
572a44
diff --git a/src/core/socket.c b/src/core/socket.c
572a44
index d368f7e..e673f38 100644
572a44
--- a/src/core/socket.c
572a44
+++ b/src/core/socket.c
572a44
@@ -770,7 +770,7 @@ static void socket_apply_socket_options(Socket *s, int fd) {
572a44
 
572a44
         if (s->reuseport) {
572a44
                 int b = s->reuseport;
572a44
-                if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)))
572a44
+                if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)) < 0)
572a44
                         log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m");
572a44
         }
572a44