From patchwork Sat Oct 26 16:32:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "L. Hanisch" X-Patchwork-Id: 20474 Received: from localhost ([127.0.0.1] helo=www.linuxtv.org) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Va6nP-0002Me-ID; Sat, 26 Oct 2013 18:33:03 +0200 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Va6nM-0002MD-Rs for vdr@linuxtv.org; Sat, 26 Oct 2013 18:33:01 +0200 X-tubIT-Incoming-IP: 62.214.96.174 Received: from mxweb03do.versatel-west.de ([62.214.96.174]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with smtp for id 1Va6nK-0003pb-4M; Sat, 26 Oct 2013 18:33:00 +0200 Received: (qmail 31479 invoked from network); 26 Oct 2013 16:32:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on spamkill19do.versatel-west.de X-Spam-Status: No, score=0.0 Received: from mxwebdo.versatel.de (62.214.96.205) by mxweb03do.versatel-west.de with SMTP; 26 Oct 2013 16:32:55 -0000 Received: from ens28fl.versatel.de [82.140.32.10] (helo=ens28fl.versatel.de) by mxwebdo.versatel.de (62.214.96.205) with id r9QGWt7v032315; Sat, 26 Oct 2013 18:32:55 +0200 Received: from server.gitarren.lan (i577A1745.versanet.de [87.122.23.69]) (dvb@flensrocker.de authenticated bits=0) by ens28fl.versatel.de (8.12.11.20060308/8.12.11) with ESMTP id r9QGWtvG008923 for ; Sat, 26 Oct 2013 18:32:55 +0200 Received: from [192.168.23.2] (cheri.gitarren.lan [192.168.23.2]) by server.gitarren.lan (Postfix) with ESMTP id 0C8974200D8 for ; Sat, 26 Oct 2013 18:32:35 +0200 (CEST) Message-ID: <526BEEB8.7010900@flensrocker.de> Date: Sat, 26 Oct 2013 18:32:56 +0200 From: Lars Hanisch User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: VDR Mailing List X-Virus-Scanned: ClamAV version 0.92, clamav-milter version 0.92 on 82.140.32.176 X-Virus-Status: Clean X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.10.26.162415 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1700_1799 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_FOUND 0, __BAT_BOUNDARY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HAS_FROM 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __USER_AGENT 0' X-LSpam-Score: -1.1 (-) X-LSpam-Report: No, score=-1.1 required=5.0 tests=BAYES_00=-1.9, RDNS_NONE=0.793 autolearn=no Subject: [vdr] [Patch] reconnect to lirc socket even if it doesn't exist on startup X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: vdr-bounces@linuxtv.org Errors-To: vdr-bounces@linuxtv.org Hi, The reconnect loop of cLircRemote will not be started if the socket does not exist at the time, vdr starts. In "fast boot" environments this may be true. The attached patch fixes this. Regards, Lars. diff --git a/lirc.c b/lirc.c index b88bd73..09905d0 100644 --- a/lirc.c +++ b/lirc.c @@ -21,11 +21,9 @@ cLircRemote::cLircRemote(const char *DeviceName) { addr.sun_family = AF_UNIX; strcpy(addr.sun_path, DeviceName); - if (Connect()) { - Start(); - return; - } - f = -1; + if (!Connect()) + f = -1; + Start(); } cLircRemote::~cLircRemote() @@ -67,14 +65,15 @@ void cLircRemote::Action(void) bool repeat = false; int timeout = -1; - while (Running() && f >= 0) { + while (Running()) { - bool ready = cFile::FileReady(f, timeout); + bool ready = f >= 0 ? cFile::FileReady(f, timeout) : false; int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1; - if (ready && ret <= 0 ) { + if ((f < 0) || (ready && (ret <= 0))) { esyslog("ERROR: lircd connection broken, trying to reconnect every %.1f seconds", float(RECONNECTDELAY) / 1000); - close(f); + if (f >= 0) + close(f); f = -1; while (Running() && f < 0) { cCondWait::SleepMs(RECONNECTDELAY);