[master] dec92d3 Change my mind a bit:

Poul-Henning Kamp phk at FreeBSD.org
Mon Feb 16 10:30:16 CET 2015


commit dec92d3e2213ea9fc4d97cb69fd267d3ddce7c38
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 16 09:26:49 2015 +0000

    Change my mind a bit:
    
    When no -j argument is specified, walk the list to get the most
    capable jail technology which can run in the given circumstances.

diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index f74678e..d045349 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -77,7 +77,7 @@ enum jail_master_e {
 	JAIL_MASTER_HIGH,
 };
 
-typedef void jail_init_f(char **);
+typedef int jail_init_f(char **);
 typedef void jail_master_f(enum jail_master_e);
 typedef void jail_subproc_f(enum jail_subproc_e);
 
diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c
index ddd4670..4be41fc 100644
--- a/bin/varnishd/mgt/mgt_jail.c
+++ b/bin/varnishd/mgt/mgt_jail.c
@@ -44,11 +44,12 @@
  * A "none" jail implementation which doesn't do anything.
  */
 
-static void __match_proto__(jail_init_f)
+static int __match_proto__(jail_init_f)
 vjn_init(char **args)
 {
 	if (*args != NULL)
 		ARGV_ERR("-Jnone takes no arguments.\n");
+	return (0);
 }
 
 static void __match_proto__(jail_master_f)
@@ -84,6 +85,7 @@ void
 VJ_Init(const char *j_arg)
 {
 	char **av;
+	int i;
 
 	if (j_arg != NULL) {
 		av = VAV_Parse(j_arg, NULL, ARGV_COMMA);
@@ -97,10 +99,17 @@ VJ_Init(const char *j_arg)
 		vjt->init(av + 2);
 		VAV_Free(av);
 	} else {
+		/*
+		 * Go through list of jail technologies until one
+		 * succeeds, falling back to "none".
+		 */
 		av = VAV_Parse("", NULL, ARGV_COMMA);
-		vjt = vj_choice[0].ptr;
-		CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
-		vjt->init(av + 1);
+		for (i = 0; vj_choice[i].name != NULL; i++) {
+			vjt = vj_choice[i].ptr;
+			CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
+			if (!vjt->init(av + 1))
+				break;
+		}
 		VAV_Free(av);
 	}
 }



More information about the varnish-commit mailing list