From patchwork Tue Nov 14 18:26:57 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Udo Richter X-Patchwork-Id: 12405 Received: from mail.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.50) id 1Gk30T-0004Hy-HY for vdr@linuxtv.org; Tue, 14 Nov 2006 19:27:37 +0100 Received: (qmail invoked by alias); 14 Nov 2006 18:27:06 -0000 Received: from p57A8BE37.dip0.t-ipconnect.de (EHLO localhost) [87.168.190.55] by mail.gmx.net (mp009) with SMTP; 14 Nov 2006 19:27:06 +0100 X-Authenticated: #1417946 Message-ID: <455A0A71.4030805@gmx.de> Date: Tue, 14 Nov 2006 19:26:57 +0100 From: Udo Richter User-Agent: Thunderbird 2.0b1pre (Windows/20061113) MIME-Version: 1.0 To: vdr-ml@jwendel.de, VDR Mailing List Subject: Re: [vdr] vdr shutdown handling / streamdev plugin References: <200611141003.07963.vdr-ml@jwendel.de> In-Reply-To: <200611141003.07963.vdr-ml@jwendel.de> X-Y-GMX-Trusted: 0 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 18:27:37 -0000 Status: O X-Status: X-Keywords: X-UID: 11234 Jörg Wendel wrote: > a question about the 'new' vdr shutdown handling implemented a few versions ago. > [..] > But why vdr call this so often, isn't it only required if the vdr is going to shutdown? > Even without the log message, at first view it looks like unnecessary load? VDR calls this function together with several other activity checks in its main loop, and not just when no user activity was detected for the configured time. This call is done on each cycle of the main loop (typically once a second, sometimes more often) unless there's an open OSD, a recording, or a cutting in progress. If this call is used as a simple boolean check, the load is very small. Translating a string on each call is more serious. And dumping to syslog should definitely be avoided. For plugin developers, I suggest to keep it simple in there. Its probably a good idea to tr() the string just once and cache it afterwards. For VDR, the two if's in the inactivity shutdown should be swappable with no serious side effects, see attached diff. All the calls do noting important, except the cCutter::Active() call, and this one is called often enough in other situations. But even with this patch, an non-interactive idle VDR waiting for shutdown will call this very frequently. Cheers, Udo --- vdr.c.bak 2006-11-14 19:17:37.342544928 +0100 +++ vdr.c 2006-11-14 19:16:50.045735136 +0100 @@ -1149,9 +1149,9 @@ Skins.Message(mtInfo, tr("Editing process finished")); } } - if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) { - time_t Now = time(NULL); - if (Now - LastActivity > ACTIVITYTIMEOUT) { + time_t Now = time(NULL); + if (Now - LastActivity > ACTIVITYTIMEOUT) { + if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) { // Shutdown: if (Shutdown && (Setup.MinUserInactivity || LastActivity == 1) && Now - LastActivity > Setup.MinUserInactivity * 60) { cTimer *timer = Timers.GetNextActiveTimer();