Revision 2cdaf225 htools/Ganeti/Confd/Server.hs

b/htools/Ganeti/Confd/Server.hs
31 31

  
32 32
import Control.Concurrent
33 33
import Control.Exception
34
import Control.Monad (forever, liftM)
34
import Control.Monad (forever, liftM, when)
35 35
import qualified Data.ByteString as B
36 36
import Data.IORef
37 37
import Data.List
38 38
import qualified Data.Map as M
39
import Data.Maybe (fromMaybe)
39 40
import qualified Network.Socket as S
40 41
import Prelude hiding (catch)
41 42
import System.Posix.Files
......
217 218
buildResponse cdata (ConfdRequest { confdRqType = ReqNodePipByInstPip
218 219
                                  , confdRqQuery = DictQuery query}) =
219 220
  let (cfg, linkipmap) = cdata
220
      link = maybe (getDefaultNicLink cfg) id (confdReqQLink query)
221
      link = fromMaybe (getDefaultNicLink cfg) (confdReqQLink query)
221 222
  in case confdReqQIp query of
222 223
       Just ip -> return $ getNodePipByInstanceIp cfg linkipmap link ip
223 224
       Nothing -> return (ReplyStatusOk,
......
333 334
-- | Wrapper over 'buildFileStatus'. This reads the data from the
334 335
-- filesystem and then builds our cache structure.
335 336
getFStat :: FilePath -> IO FStat
336
getFStat p = getFileStatus p >>= (return . buildFileStatus)
337
getFStat p = liftM buildFileStatus (getFileStatus p)
337 338

  
338 339
-- | Check if the file needs reloading
339 340
needsReload :: FStat -> FilePath -> IO (Maybe FStat)
......
389 390
onReloadTimer :: IO Bool -> FilePath -> CRef -> MVar ServerState -> IO ()
390 391
onReloadTimer inotiaction path cref state = do
391 392
  continue <- modifyMVar state (onReloadInner inotiaction path cref)
392
  if continue
393
    then do
394
      threadDelay configReloadRatelimit
395
      onReloadTimer inotiaction path cref state
396
    else -- the inotify watch has been re-established, we can exit
397
      return ()
393
  when continue $
394
    do threadDelay configReloadRatelimit
395
       onReloadTimer inotiaction path cref state
396
  -- the inotify watch has been re-established, we can exit
398 397

  
399 398
-- | Inner onReload handler.
400 399
--
......
425 424
                   _            -> True
426 425
  return (state' { reloadModel = newmode }, continue)
427 426

  
427
-- the following hint is because hlint doesn't understand our const
428
-- (return False) is so that we can give a signature to 'e'
429
{-# ANN addNotifier "HLint: ignore Evaluate" #-}
428 430
-- | Setup inotify watcher.
429 431
--
430 432
-- This tries to setup the watch descriptor; in case of any IO errors,

Also available in: Unified diff