From 25234d9fc9f281805ab9ab9d44338962213fb23e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 31 Jan 2016 14:14:07 +0000 Subject: Removed danger of crash due to corner case --- server/src/Thermoprint/Server/Printer.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'server/src') diff --git a/server/src/Thermoprint/Server/Printer.hs b/server/src/Thermoprint/Server/Printer.hs index 55bfabc..67180c4 100644 --- a/server/src/Thermoprint/Server/Printer.hs +++ b/server/src/Thermoprint/Server/Printer.hs @@ -89,7 +89,9 @@ runPrinter Printer{..} = forever $ do return jobId job <- runSqlPool (get jobId) =<< ask case job of - Nothing -> $(logWarn) "Nonexistent job id in printer queue" + Nothing -> do + atomically' $ modifyTVar' queue (\Queue{..} -> force $ Queue pending Nothing history) + $(logWarn) "Nonexistent job id in printer queue" Just job -> do $(logInfo) . T.pack $ "Printing " ++ show (unSqlBackendKey . unJobKey $ jobId) printReturn <- (unPM print) (jobContent job) -- We could, at this point, do some exception handling. It was decided that this would be undesirable, because we really don't have any idea what exceptions to catch -- cgit v1.2.3