Revision 7e7fa841 src/Ganeti/Confd/Server.hs

b/src/Ganeti/Confd/Server.hs
84 84
-- | Server state data type.
85 85
data ServerState = ServerState
86 86
  { reloadModel  :: ReloadModel
87
  , reloadTime   :: Integer
87
  , reloadTime   :: Integer      -- ^ Reload time (epoch) in microseconds
88 88
  , reloadFStat  :: FStat
89 89
  }
90 90

  
......
98 98

  
99 99
-- | Ratelimit timeout in microseconds.
100 100
configReloadRatelimit :: Int
101
configReloadRatelimit = C.confdConfigReloadRatelimit * 1000000
101
configReloadRatelimit = C.confdConfigReloadRatelimit
102 102

  
103
-- | Ratelimit timeout in seconds, as an 'Integer'.
104
reloadRatelimitSec :: Integer
105
reloadRatelimitSec = fromIntegral C.confdConfigReloadRatelimit
103
-- | Ratelimit timeout in microseconds, as an 'Integer'.
104
reloadRatelimit :: Integer
105
reloadRatelimit = fromIntegral C.confdConfigReloadRatelimit
106 106

  
107 107
-- | Initial poll round.
108 108
initialPoll :: ReloadModel
......
351 351
onTimeoutTimer :: IO Bool -> FilePath -> CRef -> MVar ServerState -> IO ()
352 352
onTimeoutTimer inotiaction path cref state = do
353 353
  threadDelay configReloadTimeout
354
  logDebug "Watcher timer fired"
354 355
  modifyMVar_ state (onTimeoutInner path cref)
355 356
  _ <- inotiaction
356 357
  onTimeoutTimer inotiaction path cref state
......
372 373
-- notification.
373 374
onReloadTimer :: IO Bool -> FilePath -> CRef -> MVar ServerState -> IO ()
374 375
onReloadTimer inotiaction path cref state = do
376
  logDebug "Reload timer fired"
375 377
  continue <- modifyMVar state (onReloadInner inotiaction path cref)
376 378
  when continue $
377 379
    do threadDelay configReloadRatelimit
......
440 442
  modifyMVar_ mstate $ \state ->
441 443
    if reloadModel state == ReloadNotify
442 444
       then do
443
         ctime <- getCurrentTime
445
         ctime <- getCurrentTimeUSec
444 446
         (newfstat, _) <- safeUpdateConfig path (reloadFStat state) cref
445 447
         let state' = state { reloadFStat = newfstat, reloadTime = ctime }
446
         if abs (reloadTime state - ctime) < reloadRatelimitSec
448
         if abs (reloadTime state - ctime) < reloadRatelimit
447 449
           then do
448 450
             mode <- moveToPolling "too many reloads" inotify path cref mstate
449 451
             return state' { reloadModel = mode }

Also available in: Unified diff