Skip to content

Commit

Permalink
Catch errors in update_value to release lock
Browse files Browse the repository at this point in the history
If an error happens in update_value, reg.lock is never released,
thus resulting in a deadlock.
  • Loading branch information
cpiber committed May 4, 2022
1 parent 830d624 commit 0916327
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Beniamin Kalinowski <beniamin.kalinowski@gmail.com>
-- Copyright (C) 2018,2020 Nguyễn Gia Phong <mcsinyx@disroot.org>
-- Copyright (C) 2022 Constantin Piber <cp.piber@gmail.com>
--
-- This file is part of Vicious.
--
Expand Down Expand Up @@ -38,6 +39,14 @@ local table = {
remove = table.remove
}
local helpers = require("vicious.helpers")
local dstatus, debug = pcall(require, "gears.debug")
local stderr = io.stderr
local warn
if dstatus then
warn = debug.print_warning
else
warn = function (msg) stderr:write("Warning (vicious): ", msg, "\n") end
end

-- Vicious: widgets for the awesome window manager
local vicious = {}
Expand Down Expand Up @@ -132,7 +141,8 @@ local function update(widget, reg, disablecache)
reg.warg,
function(data)
update_cache(data, update_time, c)
update_value(data)
local status, res = pcall(update_value, data)
if not status then warn(res) end
reg.lock=false
end)
end
Expand Down

0 comments on commit 0916327

Please sign in to comment.