[lxc-devel] [lxcfs/master] Address feedback from Markus Elfring

hallyn on Github lxc-bot at linuxcontainers.org
Mon Mar 21 07:43:36 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 348 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160321/38a33dff/attachment.bin>
-------------- next part --------------
From 8fad16cdd1e4ab07be0d3847d5be537e85e40552 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Sun, 20 Mar 2016 23:49:21 -0700
Subject: [PATCH 1/3] handle error in signal(2)

Closes #96

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 lxcfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lxcfs.c b/lxcfs.c
index a63f36a..5232790 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -914,7 +914,10 @@ int main(int argc, char *argv[])
 		usage(argv[0]);
 
 	do_reload();
-	signal(SIGUSR1, reload_handler);
+	if (signal(SIGUSR1, reload_handler) == SIG_ERR) {
+		fprintf(stderr, "Error loading USR1 signal handler: %m\n");
+		exit(1);
+	}
 
 	newargv[cnt++] = argv[0];
 	newargv[cnt++] = "-f";

From caa80fc316f7142ddcf495ee41ad0ef9d7869e12 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Mon, 21 Mar 2016 00:03:04 -0700
Subject: [PATCH 2/3] configure.ac: drop second call to AM_INIT_AUTOMAKE

Closes #95

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 configure.ac | 2 --
 1 file changed, 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index cb373eb..0eae3c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,8 +22,6 @@ AC_CONFIG_FILES([
 	share/lxc.reboot.hook
 	tests/Makefile ])
 
-AM_INIT_AUTOMAKE
-
 LT_INIT
 AC_PROG_CC
 

From 81d17d8f7e7cfba303b3555ef479226a0b67f2c7 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Mon, 21 Mar 2016 00:25:16 -0700
Subject: [PATCH 3/3] lxcfs reload: only call async-safe functions

So don't call fprintf, don't take a lock we don't need, just set
an atomic volatile int to 1 when called.

Closes #94

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 lxcfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lxcfs.c b/lxcfs.c
index 5232790..fe1dddd 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -67,7 +67,7 @@ static void users_unlock(void)
 	unlock_mutex(&user_count_mutex);
 }
 
-static int need_reload;
+static volatile sig_atomic_t need_reload;
 
 /* do_reload - reload the dynamic library.  Done under
  * lock and when we know the user_count was 0 */
@@ -111,10 +111,7 @@ static void down_users(void)
 
 static void reload_handler(int sig)
 {
-	fprintf(stderr, "lxcfs: caught a SIGUSR1.  Reloading\n");
-	users_lock();
 	need_reload = 1;
-	users_unlock();
 }
 
 /* Functions to run the library methods */


More information about the lxc-devel mailing list