[systemd-commits] 4 commits - src/cgroup.c src/service.c src/socket.c

Lennart Poettering lennart at kemper.freedesktop.org
Thu May 20 11:46:34 PDT 2010


 src/cgroup.c  |    5 ++++-
 src/service.c |    1 +
 src/socket.c  |   48 +++++++++++++++++++++++++++++++++++-------------
 3 files changed, 40 insertions(+), 14 deletions(-)

New commits:
commit b6dbbe1c9860d1e1a7ca7e4be170959277f9e04d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 20 20:46:17 2010 +0200

    socket: fix error handling

diff --git a/src/socket.c b/src/socket.c
index 03d322b..f9da353 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -896,7 +896,7 @@ static void socket_enter_running(Socket *s, int cfd) {
                 Unit *u;
                 char *prefix, *instance, *name;
 
-                if ((r = instance_from_socket(cfd, s->n_accepted++, &instance)))
+                if ((r = instance_from_socket(cfd, s->n_accepted++, &instance)) < 0)
                         goto fail;
 
                 if (!(prefix = unit_name_to_prefix(UNIT(s)->meta.id))) {
@@ -909,8 +909,10 @@ static void socket_enter_running(Socket *s, int cfd) {
                 free(prefix);
                 free(instance);
 
-                if (!name)
+                if (!name) {
                         r = -ENOMEM;
+                        goto fail;
+                }
 
                 r = manager_load_unit(UNIT(s)->meta.manager, name, NULL, &u);
                 free(name);
@@ -918,7 +920,7 @@ static void socket_enter_running(Socket *s, int cfd) {
                 if (r < 0)
                         goto fail;
 
-                if ((r = service_set_socket_fd(SERVICE(u), cfd) < 0))
+                if ((r = service_set_socket_fd(SERVICE(u), cfd)) < 0)
                         goto fail;
 
                 cfd = -1;
commit 2b061f5a4b4e8927c7c1077e494455a189e34d59
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 20 20:46:06 2010 +0200

    socket: format IPv4-in-IPv6 addresses as IPv4 addresses for instance name

diff --git a/src/socket.c b/src/socket.c
index 259f273..03d322b 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -386,16 +386,36 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
         }
 
         case AF_INET6: {
-                char a[INET6_ADDRSTRLEN], b[INET6_ADDRSTRLEN];
-
-                if (asprintf(&r,
-                             "%u-%s:%u-%s:%u",
-                             nr,
-                             inet_ntop(AF_INET6, &local.in6.sin6_addr, a, sizeof(a)),
-                             ntohs(local.in6.sin6_port),
-                             inet_ntop(AF_INET6, &remote.in6.sin6_addr, b, sizeof(b)),
-                             ntohs(remote.in6.sin6_port)) < 0)
-                        return -ENOMEM;
+                static const char ipv4_prefix[] = {
+                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF
+                };
+
+                if (memcmp(&local.in6.sin6_addr, ipv4_prefix, sizeof(ipv4_prefix)) == 0 &&
+                    memcmp(&remote.in6.sin6_addr, ipv4_prefix, sizeof(ipv4_prefix)) == 0) {
+                        const uint8_t
+                                *a = local.in6.sin6_addr.s6_addr+12,
+                                *b = remote.in6.sin6_addr.s6_addr+12;
+
+                        if (asprintf(&r,
+                                     "%u-%u.%u.%u.%u:%u-%u.%u.%u.%u:%u",
+                                     nr,
+                                     a[0], a[1], a[2], a[3],
+                                     ntohs(local.in6.sin6_port),
+                                     b[0], b[1], b[2], b[3],
+                                     ntohs(remote.in6.sin6_port)) < 0)
+                                return -ENOMEM;
+                } else {
+                        char a[INET6_ADDRSTRLEN], b[INET6_ADDRSTRLEN];
+
+                        if (asprintf(&r,
+                                     "%u-%s:%u-%s:%u",
+                                     nr,
+                                     inet_ntop(AF_INET6, &local.in6.sin6_addr, a, sizeof(a)),
+                                     ntohs(local.in6.sin6_port),
+                                     inet_ntop(AF_INET6, &remote.in6.sin6_addr, b, sizeof(b)),
+                                     ntohs(remote.in6.sin6_port)) < 0)
+                                return -ENOMEM;
+                }
 
                 break;
         }
commit 8e47d742a84967431333248dc819687e5aae39ee
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 20 20:45:20 2010 +0200

    service: when start is repeated too often, consider that failure

diff --git a/src/service.c b/src/service.c
index 2f699cd..07b6e4e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1708,6 +1708,7 @@ static int service_start(Unit *u) {
         /* Make sure we don't enter a busy loop of some kind. */
         if (!ratelimit_test(&s->ratelimit)) {
                 log_warning("%s start request repeated too quickly, refusing to start.", u->meta.id);
+                service_enter_dead(s, false, true);
                 return -ECANCELED;
         }
 
commit 7c64bbc3875930c045d53f09e244dff8607370e6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 20 20:45:00 2010 +0200

    cgroup: consider not-realized cgroups empty when killing all processes in them

diff --git a/src/cgroup.c b/src/cgroup.c
index 56529eb..fb4047f 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -194,7 +194,10 @@ int cgroup_bonding_kill(CGroupBonding *b, int sig) {
                                 r = 0;
                                 goto kill_done;
                         } else {
-                                r = translate_error(r, errno);
+                                if (r == ECGOTHER && errno == ENOENT)
+                                        r = ESRCH;
+                                else
+                                        r = translate_error(r, errno);
                                 break;
                         }
                 }


More information about the systemd-commits mailing list