Skip to content

Commit

Permalink
Check /tmp/was_rectimer_wakeup under a lock. We've seen two threads a…
Browse files Browse the repository at this point in the history
…rrive "together". Both see the file as existing, but only one can delete it... (OpenViX#576)
  • Loading branch information
original-birdman authored and Tony Whalley committed Oct 1, 2020
1 parent f7cb7f3 commit 2eeefbf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions RecordTimer.py
Expand Up @@ -32,10 +32,12 @@
# event data (ONLY for time adjustments etc.)


# We need to handle concurrency when updating timers.xml
# We need to handle concurrency when updating timers.xml and
# when checking was_rectimer_wakeup
#
import threading
write_lock = threading.Lock()
wasrec_lock = threading.Lock()

# Parses an event, and returns a (begin, end, name, duration, eit)-tuple.
# begin and end include padding (if set in config)
Expand Down Expand Up @@ -556,9 +558,15 @@ def activate(self):

elif next_state == self.StateRunning:
global wasRecTimerWakeup
if os.path.exists("/tmp/was_rectimer_wakeup") and not wasRecTimerWakeup:
wasRecTimerWakeup = int(open("/tmp/was_rectimer_wakeup", "r").read()) and True or False
os.remove("/tmp/was_rectimer_wakeup")

# Run this under a lock.
# We've seen two threads arrive here "together".
# Both see the file as existing, but only one can delete it...
#
with wasrec_lock:
if os.path.exists("/tmp/was_rectimer_wakeup") and not wasRecTimerWakeup:
wasRecTimerWakeup = int(open("/tmp/was_rectimer_wakeup", "r").read()) and True or False
os.remove("/tmp/was_rectimer_wakeup")

self.autostate = Screens.Standby.inStandby

Expand Down

0 comments on commit 2eeefbf

Please sign in to comment.