Skip to contentSkip to conversation

tabled: use "auto" keyword

PATCH Applied Pete Zaitcev 2 participants 2 messages Sep 29, 2009 – Sep 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 tabled: use "auto" keyword

The current implementation of automatic listening ports was configured implicitly by adding <PortFile> clause. This turned out to be a silly idea. A special keyword for <Port> is more convenient.

This should be built after both CLD and Chunk implement "auto" keyword.

server/config.c +4 -8
index 505524c..c7a994f 100644
@@ -75,13 +75,8 @@ static void cfg_elm_end_listen(struct config_context *cc)
 		return;
 	}
 
-	if (cc->tmp_listen.port && cc->tmp_listen.port_file) {
-		applog(LOG_ERR, "cfgfile: Listen with both Port and PortFile");
-		goto err;
-	}
-
-	if (!cc->tmp_listen.port && !cc->tmp_listen.port_file) {
-		applog(LOG_ERR, "cfgfile: Listen with no Port or PortFile");
+	if (!cc->tmp_listen.port) {
+		applog(LOG_ERR, "cfgfile: Listen with no Port");
 		goto err;
 	}
 
@@ -270,7 +265,8 @@ static void cfg_elm_end (GMarkupParseContext *context,
 
 		if (cc->in_listen) {
 			n = strtol(cc->text, NULL, 10);
-			if (n > 0 && n < 65536) {
+			if ((n > 0 && n < 65536) ||
+			    !strcmp(cc->text, "auto")) {
 				free(cc->tmp_listen.port);
 				cc->tmp_listen.port = cc->text;
 			} else {
server/server.c +37 -17

86 lines not on this page · raw message

test/chunkd-test.conf +1 -1
index 3785eb5..00cf024 100644
@@ -1,6 +1,6 @@
 
 <Listen>
-  <PortFile>/dev/null</PortFile>
+  <Port>auto</Port>
 </Listen>
 <PID>chunkd.pid</PID>
 <Path>data/chunk</Path>
test/start-daemon +1 -1
index 589bfe5..2761d55 100755
@@ -17,7 +17,7 @@ then
 fi
 
 # May be different on Solaris... like /usr/libexec or such.
-cld -d data/cld -P cld.pid --port-file=cld.port -E
+cld -d data/cld -P cld.pid -p auto --port-file=cld.port -E
 chunkd -C $top_srcdir/test/chunkd-test.conf -E
 ../server/tabled -C $top_srcdir/test/tabled-test.conf -E -D
 
test/tabled-test.conf +4 -1
index 2de599c..068ed00 100644
@@ -1,7 +1,10 @@
 
 <PID>tabled.pid</PID>
 <ForceHost>localhost.localdomain</ForceHost>
-<Listen><PortFile>tabled.acc</PortFile></Listen>
+<Listen>
+  <Port>auto</Port>
+  <PortFile>tabled.acc</PortFile>
+</Listen>
 <TDB>data/tdb</TDB>
 <TDBRepPort>18083</TDBRepPort>
 
Applied
#1 lore raw
Quoted 7 lines · Pete Zaitcev

The current implementation of automatic listening ports was configured implicitly by adding<PortFile> clause. This turned out to be a silly idea. A special keyword for<Port> is more convenient.

This should be built after both CLD and Chunk implement "auto" keyword.

applied