From patchwork Thu Jun 15 11:54:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9788711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2E13602CB for ; Thu, 15 Jun 2017 11:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E27D826E4E for ; Thu, 15 Jun 2017 11:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D73AC285BE; Thu, 15 Jun 2017 11:57:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B4BD22849E for ; Thu, 15 Jun 2017 11:57:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLTMk-0004sR-K5; Thu, 15 Jun 2017 11:55:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLTMi-0004s7-NU for xen-devel@lists.xenproject.org; Thu, 15 Jun 2017 11:55:08 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 0F/C9-01752-B9572495; Thu, 15 Jun 2017 11:55:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrrBXnd2qVO kwa81Ehbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aC2TNYCpZwV6xc8p6tgfEDRxcjJ4eEgL/E vmPf2EFsNgFdiaYtf9m6GDk4RARUJG7vNQAJMwskS/S+ncoGYgsLOEvcXTKXBcRmEVCV+HJhJ xOIzSvgKdH58DsrxEg5ifPHfzKD2JwCXhIHL74FqxcCqlm25TwLyHghATWJuevjIVoFJU7OfM ICsUpC4uCLF8wTGHlnIUnNQpJawMi0ilG9OLWoLLVI11wvqSgzPaMkNzEzR9fQwFQvN7W4ODE 9NScxqVgvOT93EyMwbBiAYAfjscnOhxglOZiURHn55ZwihfiS8lMqMxKLM+KLSnNSiw8xynBw KEnwfikBygkWpaanVqRl5gADGCYtwcGjJML7OwsozVtckJhbnJkOkTrFqMuxYfX6L0xCLHn5e alS4rzrQGYIgBRllObBjYBF0yVGWSlhXkago4R4ClKLcjNLUOVfMYpzMCoJ834EmcKTmVcCt+ kV0BFMQEcEXXAAOaIkESEl1cBY5K3X0rTgx7s3Vlvn85syNe+8vNF/HqdLetTsygU3DO9xHji u96TkF0MuS/hE003szrOuX1uzWfz2dz67b+JCB6Qjp0iXfo5d9Oes7Q2FSt+cj02X/NdsrC9P CMk5dELspryA13untGupfrWSLzjXOLh7TikPnHSSszpmL5/Yye6QyLOCqfOVWIozEg21mIuKE wECKxdmoQIAAA== X-Env-Sender: prvs=33261d418=Ian.Jackson@citrix.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1497527705!89539348!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33317 invoked from network); 15 Jun 2017 11:55:07 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 15 Jun 2017 11:55:07 -0000 X-IronPort-AV: E=Sophos;i="5.39,343,1493683200"; d="scan'208";a="436510248" From: Ian Jackson To: Date: Thu, 15 Jun 2017 12:54:42 +0100 Message-ID: <1497527684-21433-2-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497527684-21433-1-git-send-email-ian.jackson@eu.citrix.com> References: <1497527684-21433-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Cc: Ian Jackson , osstest service user Subject: [Xen-devel] [OSSTEST PATCH 2/4] tcl/daemonlib: tolerate no $c(...Host) X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: osstest service user 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 --- 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 }