From 0cb56eb14e4e7c9257b290a8e22331d90145105c Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Wed, 18 Nov 2020 18:49:00 +0000 Subject: StdinReader: Remove throttling on exception Introducing the throttling unfortunately has a negative side-effect: it delays all stdin processing, including EOF detection, which can cause confusion the previous commit tries to fix. The only benefit of the throttling is to prevent 100% CPU usage when a lot of garbage is provided on xmobar stdin. We still don't know where that garbage comes from in https://github.com/jaor/xmobar/issues/438, or rather why there's more than a handful of lines of such garbage. @psibi has since fixed his setup to not produce that garbage, and no one else ever reported such a problem, so it's probably safe to ignore it for now. Should anyone ever encounter that again, feel free to ping me, even in the middle of the night, to help debug this. Fixes: 7759df11f746 ("StdinReader: Improve exception handling") Fixes: b7a3d6745817 ("Avoid busy looping by not catching all exceptions") --- src/Xmobar/Plugins/StdinReader.hs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/Xmobar/Plugins') diff --git a/src/Xmobar/Plugins/StdinReader.hs b/src/Xmobar/Plugins/StdinReader.hs index 4d5c438..c1e2724 100644 --- a/src/Xmobar/Plugins/StdinReader.hs +++ b/src/Xmobar/Plugins/StdinReader.hs @@ -27,7 +27,6 @@ import System.IO import System.IO.Error (isEOFError) import Xmobar.Run.Exec import Xmobar.X11.Actions (stripActions) -import Control.Concurrent (threadDelay) import Control.Exception import Control.Monad (forever) @@ -45,15 +44,11 @@ instance Exec StdinReader where -- there'd be a pileup of xmobars handler (fromException -> Just e) | isEOFError e = exitImmediately ExitSuccess -- any other exception, like "invalid argument (invalid byte sequence)", - -- is logged to both stderr and the bar itself, throttled to avoid - -- excessive CPU usage whenever someone pipes garbage into xmobar, and - -- then discarded without terminating, so a single charset error doesn't - -- break the entire xmobar + -- is logged to both stderr and the bar itself handler e = do let errorMessage = "xmobar: Received exception " <> show e hPutStrLn stderr errorMessage cb $ stripActions errorMessage - threadDelay 1000000 escape :: StdinReader -> String -> String escape StdinReader = stripActions -- cgit v1.2.3