Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ghc-time-manager for 
openSUSE:Factory checked in at 2024-12-26 12:24:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-time-manager (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-time-manager.new.1881 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-time-manager"

Thu Dec 26 12:24:05 2024 rev:9 rq:1233305 version:0.2.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-time-manager/ghc-time-manager.changes        
2024-12-20 23:11:57.887798021 +0100
+++ 
/work/SRC/openSUSE:Factory/.ghc-time-manager.new.1881/ghc-time-manager.changes  
    2024-12-26 12:24:12.135274390 +0100
@@ -1,0 +2,10 @@
+Wed Dec 18 04:18:36 UTC 2024 - Peter Simons <[email protected]>
+
+- Update time-manager to version 0.2.2.
+  ## 0.2.2
+
+  * `initialize` with non positive integer creates a time manager
+    which does not maintain timeout.
+    [#1017](https://github.com/yesodweb/wai/pull/1017)
+
+-------------------------------------------------------------------

Old:
----
  time-manager-0.2.1.tar.gz

New:
----
  time-manager-0.2.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-time-manager.spec ++++++
--- /var/tmp/diff_new_pack.ONm3lg/_old  2024-12-26 12:24:12.899305695 +0100
+++ /var/tmp/diff_new_pack.ONm3lg/_new  2024-12-26 12:24:12.899305695 +0100
@@ -19,7 +19,7 @@
 %global pkg_name time-manager
 %global pkgver %{pkg_name}-%{version}
 Name:           ghc-%{pkg_name}
-Version:        0.2.1
+Version:        0.2.2
 Release:        0
 Summary:        Scalable timer
 License:        MIT

++++++ time-manager-0.2.1.tar.gz -> time-manager-0.2.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/time-manager-0.2.1/ChangeLog.md 
new/time-manager-0.2.2/ChangeLog.md
--- old/time-manager-0.2.1/ChangeLog.md 2001-09-09 03:46:40.000000000 +0200
+++ new/time-manager-0.2.2/ChangeLog.md 2001-09-09 03:46:40.000000000 +0200
@@ -1,5 +1,11 @@
 # ChangeLog for time-manager
 
+## 0.2.2
+
+* `initialize` with non positive integer creates a time manager
+  which does not maintain timeout.
+  [#1017](https://github.com/yesodweb/wai/pull/1017)
+
 ## 0.2.1
 
 * Export KilledByThreadManager exception
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/time-manager-0.2.1/System/TimeManager.hs 
new/time-manager-0.2.2/System/TimeManager.hs
--- old/time-manager-0.2.1/System/TimeManager.hs        2001-09-09 
03:46:40.000000000 +0200
+++ new/time-manager-0.2.2/System/TimeManager.hs        2001-09-09 
03:46:40.000000000 +0200
@@ -35,16 +35,18 @@
 
 import Control.Concurrent (mkWeakThreadId, myThreadId)
 import qualified Control.Exception as E
+import Control.Monad (void)
 import Control.Reaper
 import Data.IORef (IORef)
 import qualified Data.IORef as I
 import Data.Typeable (Typeable)
+import System.IO.Unsafe
 import System.Mem.Weak (deRefWeak)
 
 ----------------------------------------------------------------
 
 -- | A timeout manager
-type Manager = Reaper [Handle] Handle
+data Manager = Manager (Reaper [Handle] Handle) | NoManager
 
 -- | An action to be performed on timeout.
 type TimeoutAction = IO ()
@@ -56,6 +58,20 @@
     , handleStateRef :: IORef State
     }
 
+emptyAction :: IORef TimeoutAction
+emptyAction = unsafePerformIO $ I.newIORef (return ())
+
+emptyState :: IORef State
+emptyState = unsafePerformIO $ I.newIORef Inactive
+
+emptyHandle :: Handle
+emptyHandle =
+    Handle
+        { handleManager = NoManager
+        , handleActionRef = emptyAction
+        , handleStateRef = emptyState
+        }
+
 data State
     = Active -- Manager turns it to Inactive.
     | Inactive -- Manager removes it with timeout action.
@@ -66,15 +82,18 @@
 -- | Creating timeout manager which works every N micro seconds
 --   where N is the first argument.
 initialize :: Int -> IO Manager
+initialize timeout
+    | timeout <= 0 = return NoManager
 initialize timeout =
-    mkReaper
-        defaultReaperSettings
-            { -- Data.Set cannot be used since 'partition' cannot be used
-              -- with 'readIORef`. So, let's just use a list.
-              reaperAction = mkListAction prune
-            , reaperDelay = timeout
-            , reaperThreadName = "WAI timeout manager (Reaper)"
-            }
+    Manager
+        <$> mkReaper
+            defaultReaperSettings
+                { -- Data.Set cannot be used since 'partition' cannot be used
+                  -- with 'readIORef`. So, let's just use a list.
+                  reaperAction = mkListAction prune
+                , reaperDelay = timeout
+                , reaperThreadName = "WAI timeout manager (Reaper)"
+                }
   where
     prune m@Handle{..} = do
         state <- I.atomicModifyIORef' handleStateRef (\x -> (inactivate x, x))
@@ -92,7 +111,8 @@
 
 -- | Stopping timeout manager with onTimeout fired.
 stopManager :: Manager -> IO ()
-stopManager mgr = E.mask_ (reaperStop mgr >>= mapM_ fire)
+stopManager NoManager = return ()
+stopManager (Manager mgr) = E.mask_ (reaperStop mgr >>= mapM_ fire)
   where
     fire Handle{..} = do
         onTimeout <- I.readIORef handleActionRef
@@ -100,7 +120,8 @@
 
 -- | Killing timeout manager immediately without firing onTimeout.
 killManager :: Manager -> IO ()
-killManager = reaperKill
+killManager NoManager = return ()
+killManager (Manager mgr) = reaperKill mgr
 
 ----------------------------------------------------------------
 
@@ -126,12 +147,13 @@
 
 -- | Registering a timeout action.
 register :: Manager -> TimeoutAction -> IO Handle
-register mgr !onTimeout = do
+register NoManager _ = return emptyHandle
+register m@(Manager mgr) !onTimeout = do
     actionRef <- I.newIORef onTimeout
     stateRef <- I.newIORef Active
     let h =
             Handle
-                { handleManager = mgr
+                { handleManager = m
                 , handleActionRef = actionRef
                 , handleStateRef = stateRef
                 }
@@ -140,9 +162,9 @@
 
 -- | Removing the 'Handle' from the 'Manager' immediately.
 cancel :: Handle -> IO ()
-cancel Handle{..} = do
-    _ <- reaperModify handleManager filt
-    return ()
+cancel Handle{..} = case handleManager of
+    NoManager -> return ()
+    Manager mgr -> void $ reaperModify mgr filt
   where
     -- It's very important that this function forces the whole workload so we
     -- don't retain old handles, otherwise disasterous leaks occur.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/time-manager-0.2.1/time-manager.cabal 
new/time-manager-0.2.2/time-manager.cabal
--- old/time-manager-0.2.1/time-manager.cabal   2001-09-09 03:46:40.000000000 
+0200
+++ new/time-manager-0.2.2/time-manager.cabal   2001-09-09 03:46:40.000000000 
+0200
@@ -1,5 +1,5 @@
 Name:                time-manager
-Version:             0.2.1
+Version:             0.2.2
 Synopsis:            Scalable timer
 License:             MIT
 License-file:        LICENSE

Reply via email to