Revision 0d1d2d22

b/src/Ganeti/WConfd/ConfigState.hs
36 36
data ConfigState = ConfigState
37 37
  { csConfigData :: ConfigData
38 38
  }
39
  deriving (Eq, Show)
39 40

  
40 41
-- | Creates a new configuration state.
41 42
-- This method will expand as more fields are added to 'ConfigState'.
b/src/Ganeti/WConfd/Monad.hs
160 160
modifyConfigState f = do
161 161
  dh <- daemonHandle
162 162
  -- TODO: Use lenses to modify the daemons state here
163
  let mf ds = let (cs', r) = f (dsConfigState ds)
164
              in (ds { dsConfigState = cs' }, r)
165
  r <- atomicModifyIORef (dhDaemonState dh) mf
166
  -- trigger the config. saving worker and wait for it
167
  logDebug "Triggering config write"
168
  liftBase . triggerAndWait . dhSaveConfigWorker $ dh
169
  logDebug "Config write finished"
170
  -- trigger the config. distribution worker asynchronously
171
  -- TODO
163
  let mf ds = let cs = dsConfigState ds
164
                  (cs', r) = f cs
165
              in (ds { dsConfigState = cs' }, (r, cs /= cs'))
166
  (r, modified) <- atomicModifyIORef (dhDaemonState dh) mf
167
  when modified $ do
168
    -- trigger the config. saving worker and wait for it
169
    logDebug "Triggering config write"
170
    liftBase . triggerAndWait . dhSaveConfigWorker $ dh
171
    logDebug "Config write finished"
172
    -- trigger the config. distribution worker asynchronously
173
    -- TODO
172 174
  return r
173 175

  
174 176
-- | Atomically modifies the lock allocation state in WConfdMonad.

Also available in: Unified diff