Commit a03b2e1c authored by Iustin Pop's avatar Iustin Pop
Browse files

Simplify the Luxi client-server test



Since now we have the recvMsgExt, we can remove the handleEOF
function.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent a23643ee
......@@ -1895,21 +1895,13 @@ getTempFileName = do
removeFile fpath
return fpath
-- | Helper to execute recvMsg but return Nothing if we reach EOF.
handleEOF :: (IO a) -> IO (Maybe a)
handleEOF action =
catchJust
(\e -> if isEOFErrorType (ioeGetErrorType e) then Just () else Nothing)
(liftM Just action)
(\_ -> return Nothing)
-- | Server ping-pong helper.
luxiServerPong :: Luxi.Client -> IO ()
luxiServerPong c = do
msg <- handleEOF (Luxi.recvMsg c)
msg <- Luxi.recvMsgExt c
case msg of
Nothing -> return ()
Just m -> Luxi.sendMsg c m >> luxiServerPong c
Luxi.RecvOk m -> Luxi.sendMsg c m >> luxiServerPong c
_ -> return ()
-- | Client ping-pong helper.
luxiClientPong :: Luxi.Client -> [String] -> IO [String]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment