[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 2/4] tcl/daemonlib: tolerate no $c(...Host)



From: osstest service user <osstest@xxxxxxxxxxxxxxxxxxxxxx>

We are going to want a daemon that bins to * rather than to a known
address.

We achieve this by simply tolerating the lack of the FooHost config
setting; and, in that case, not passing -myaddr to Tcl's socket
command (and adjusting messages accordingly).

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 tcl/daemonlib.tcl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tcl/daemonlib.tcl b/tcl/daemonlib.tcl
index 1e86d5f..b23caea 100644
--- a/tcl/daemonlib.tcl
+++ b/tcl/daemonlib.tcl
@@ -195,7 +195,7 @@ proc newconn {chan addr port} {
 proc main-daemon {which setup} {
     global c argv
 
-    set host $c(${which}DaemonHost)
+    catch { set host $c(${which}DaemonHost) }
     set port $c(${which}DaemonPort)
 
     foreach arg $argv {
@@ -210,12 +210,21 @@ proc main-daemon {which setup} {
     fconfigure stdout -buffering line
     fconfigure stderr -buffering none
 
-    log "starting $host:$port"
+    set desc $port
+
+    set sockcmd {socket -server newconn}
+    if {[info exists host]} {
+        set desc "$host:$port"
+        lappend sockcmd [list -myaddr $host]
+    }
+    lappend sockcmd $port
+
+    log "starting $desc"
 
     uplevel 1 $setup
 
-    socket -server newconn -myaddr $host $port
-    log "listening $host:$port"
+    eval $sockcmd
+    log "listening $desc"
 
     vwait forever
 }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.