Skip to content

Commit 8642cfe

Browse files
author
Diego Diverio
committed
Basic fix for avoiding blocking of the consumer thread.
1 parent 17157e0 commit 8642cfe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/Core.hs

+6-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ runCommandLoop core = go
171171
postUpdate :: Path -> Core -> IO ()
172172
postUpdate path core = atomically $ do
173173
value <- Persistence.getValue (coreCurrentValue core)
174-
writeTBQueue (coreUpdates core) (Just $ Updated path value)
174+
full <- isFullTBQueue (coreUpdates core)
175+
-- In order not to block the reader thread, and subsequently stop processing coreQueue,
176+
-- we don't send new updates to subscribers if coreUpdates is full.
177+
if full then
178+
return ()
179+
else writeTBQueue (coreUpdates core) (Just $ Updated path value)
175180

176181
-- | Periodically send a 'Sync' command to the 'Core' if enabled in the core
177182
-- configuration.

0 commit comments

Comments
 (0)