[systemd-commits] 2 commits - src/core

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sun Nov 17 14:42:58 PST 2013


 src/core/load-fragment-gperf.gperf.m4 |    1 +
 src/core/socket.c                     |   12 +++---------
 2 files changed, 4 insertions(+), 9 deletions(-)

New commits:
commit f0511bd7e3d591383485a36ddcb764abe74b1939
Author: Shawn Landden <shawn at churchofgit.com>
Date:   Sat Nov 16 13:18:13 2013 -0800

    core/socket: fix SO_REUSEPORT

diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index e3025d2..b64fdc9 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -210,6 +210,7 @@ Socket.Broadcast,                config_parse_bool,                  0,
 Socket.PassCredentials,          config_parse_bool,                  0,                             offsetof(Socket, pass_cred)
 Socket.PassSecurity,             config_parse_bool,                  0,                             offsetof(Socket, pass_sec)
 Socket.TCPCongestion,            config_parse_string,                0,                             offsetof(Socket, tcp_congestion)
+Socket.ReusePort,                config_parse_bool,                  0,                             offsetof(Socket, reuseport)
 Socket.MessageQueueMaxMessages,  config_parse_long,                  0,                             offsetof(Socket, mq_maxmsg)
 Socket.MessageQueueMessageSize,  config_parse_long,                  0,                             offsetof(Socket, mq_msgsize)
 Socket.Service,                  config_parse_socket_service,        0,                             0
diff --git a/src/core/socket.c b/src/core/socket.c
index f505e4f..751f20b 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -771,7 +771,7 @@ static void socket_apply_socket_options(Socket *s, int fd) {
 
         if (s->reuseport) {
                 int b = s->reuseport;
-                if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)))
+                if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)) < 0)
                         log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m");
         }
 

commit e55001ebba6f6ad7d63db249f7bf93f25be12acd
Author: Shawn Landden <shawn at churchofgit.com>
Date:   Sat Nov 16 13:18:12 2013 -0800

    core/socket: use _cleanup_free_

diff --git a/src/core/socket.c b/src/core/socket.c
index 03b8f92..f505e4f 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1475,7 +1475,7 @@ static void socket_enter_running(Socket *s, int cfd) {
 
                 socket_set_state(s, SOCKET_RUNNING);
         } else {
-                char *prefix, *instance = NULL, *name;
+                _cleanup_free_ char *prefix = NULL, *instance = NULL, *name = NULL;
                 Service *service;
 
                 if (s->n_connections >= s->max_connections) {
@@ -1503,14 +1503,11 @@ static void socket_enter_running(Socket *s, int cfd) {
 
                 prefix = unit_name_to_prefix(UNIT(s)->id);
                 if (!prefix) {
-                        free(instance);
                         r = -ENOMEM;
                         goto fail;
                 }
 
                 name = unit_name_build(prefix, instance, ".service");
-                free(prefix);
-                free(instance);
 
                 if (!name) {
                         r = -ENOMEM;
@@ -1518,10 +1515,8 @@ static void socket_enter_running(Socket *s, int cfd) {
                 }
 
                 r = unit_add_name(UNIT_DEREF(s->service), name);
-                if (r < 0) {
-                        free(name);
+                if (r < 0)
                         goto fail;
-                }
 
                 service = SERVICE(UNIT_DEREF(s->service));
                 unit_ref_unset(&s->service);
@@ -1530,7 +1525,6 @@ static void socket_enter_running(Socket *s, int cfd) {
                 UNIT(service)->no_gc = false;
 
                 unit_choose_id(UNIT(service), name);
-                free(name);
 
                 r = service_set_socket_fd(service, cfd, s);
                 if (r < 0)



More information about the systemd-commits mailing list