#else
+-- | Connection timeout (when using non-file methods).
+connTimeout :: Long
+connTimeout = 15
+
+-- | The default timeout for queries (when using non-file methods).
+queryTimeout :: Long
+queryTimeout = 60
+
-- | The curl options we use.
curlOpts :: [CurlOption]
curlOpts = [ CurlSSLVerifyPeer False
, CurlSSLVerifyHost 0
- , CurlTimeout (fromIntegral queryTimeout)
- , CurlConnectTimeout (fromIntegral connTimeout)
+ , CurlTimeout queryTimeout
+ , CurlConnectTimeout connTimeout
]
getUrl url = do
, FailStats
, OpResult(..)
, opToResult
- , connTimeout
- , queryTimeout
, EvacMode(..)
, ISpec(..)
, IPolicy(..)
-- | A list of command elements.
type JobSet = [MoveJob]
--- | Connection timeout (when using non-file methods).
-connTimeout :: Int
-connTimeout = 15
-
--- | The default timeout for queries (when using non-file methods).
-queryTimeout :: Int
-queryTimeout = 60
-
-- | Default max disk usage ratio.
defReservedDiskRatio :: Double
defReservedDiskRatio = 0
import System.Timeout
import qualified Network.Socket as S
+import Ganeti.BasicTypes
import Ganeti.JSON
-import Ganeti.HTools.Types
import Ganeti.Utils
import Ganeti.Constants
getClient :: String -> IO Client
getClient path = do
s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
- withTimeout connTimeout "creating luxi connection" $
+ withTimeout luxiDefCtmo "creating luxi connection" $
S.connect s (S.SockAddrUnix path)
rf <- newIORef B.empty
h <- S.socketToHandle s ReadWriteMode
-- | Sends a message over a luxi transport.
sendMsg :: Client -> String -> IO ()
-sendMsg s buf = withTimeout queryTimeout "sending luxi message" $ do
+sendMsg s buf = withTimeout luxiDefRwto "sending luxi message" $ do
let encoded = UTF8.fromString buf
handle = socket s
B.hPut handle encoded
-- message and the leftover buffer contents.
recvUpdate :: Handle -> B.ByteString -> IO (B.ByteString, B.ByteString)
recvUpdate handle obuf = do
- nbuf <- withTimeout queryTimeout "reading luxi response" $ do
+ nbuf <- withTimeout luxiDefRwto "reading luxi response" $ do
_ <- hWaitForInput handle (-1)
B.hGetNonBlocking handle 4096
let (msg, remaining) = B.break (eOM ==) nbuf