> >+-- | Try an RPC until no errors occur and the result is true.
> >+runModifyRpc :: RpcClientMonad Bool -> IO ()
> >+runModifyRpc action = do
> >+  res <- runResultT $ do
> >+    wconfdClient <- liftIO $ getWConfdClient =<< Path.defaultWConfdSocket
> >+    runRpcClient action wconfdClient
> 
> Also here I'd suggest to close the client.


Interdiff

commit e56ff3868b717ea175f45cc2db7df7f10e506154
Author: Klaus Aehlig <[email protected]>
Date:   Thu Jul 16 11:33:42 2015 +0200

    Interdiff [PATCH master 14/16] Add a utility function to try an RPC until 
it returns True

diff --git a/src/Ganeti/WConfd/Client.hs b/src/Ganeti/WConfd/Client.hs
index 7f54888..1e0be49 100644
--- a/src/Ganeti/WConfd/Client.hs
+++ b/src/Ganeti/WConfd/Client.hs
@@ -43,7 +43,6 @@ import Control.Exception.Lifted (bracket)
 import Control.Monad (unless)
 import Control.Monad.Base
 import Control.Monad.Error (MonadError)
-import Control.Monad.IO.Class (liftIO)
 import Control.Monad.Trans.Control (MonadBaseControl)
 
 import Ganeti.BasicTypes (runResultT, GenericResult(..))
@@ -106,12 +105,12 @@ withLockedConfig c shared =
   bracket (waitLockConfig c shared) (const $ unlockConfig c)
 
 
+-- * Other functions
+
 -- | Try an RPC until no errors occur and the result is true.
 runModifyRpc :: RpcClientMonad Bool -> IO ()
 runModifyRpc action = do
-  res <- runResultT $ do
-    wconfdClient <- liftIO $ getWConfdClient =<< Path.defaultWConfdSocket
-    runRpcClient action wconfdClient
+  res <- runResultT $ runNewWConfdClient action
   unless (res == Ok True) $ do
     threadDelay 100000 -- sleep 0.1 seconds
     runModifyRpc action


-- 
Klaus Aehlig
Google Germany GmbH, Dienerstr. 12, 80331 Muenchen
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores

Reply via email to