From 640ace4a8de907994a1b95f6d368c3e6a8fcf60f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 22 May 2014 16:56:21 +0900
Subject: [PATCH] socket: properly handle if our service vanished during
 runtime

---
 src/core/socket.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git src/core/socket.c src/core/socket.c
index 05af8fe..aca20fd 100644
--- src/core/socket.c
+++ src/core/socket.c
@@ -1503,6 +1503,12 @@ static void socket_enter_running(Socket *s, int cfd) {
                         }
 
                 if (!pending) {
+                        if (!UNIT_ISSET(s->service)) {
+                                log_error_unit(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id);
+                                r = -ENOENT;
+                                goto fail;
+                        }
+
                         r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL);
                         if (r < 0)
                                 goto fail;
-- 
1.7.9.2

