summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFacundo Domínguez <facundo.dominguez@tweag.io>2021-04-02 17:11:07 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-10 05:32:28 -0400
commitb39dec86df8106a2bb4770758941572073ad57a2 (patch)
tree5192f051aa12855519a4b4c0aca615f2c77a9b75
parentc363108e13f4b198b77cea870cb8d9e76c8a7e55 (diff)
downloadhaskell-b39dec86df8106a2bb4770758941572073ad57a2.tar.gz
Report actual port in libiserv:Remote.Slave.startSlave
This allows to start iserv by passing port 0 to startSlave, which in turns allows to get an available port when no port is known to be free a priori.
-rw-r--r--libraries/libiserv/src/Remote/Slave.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/libraries/libiserv/src/Remote/Slave.hs b/libraries/libiserv/src/Remote/Slave.hs
index 577161f35f..4c150becfa 100644
--- a/libraries/libiserv/src/Remote/Slave.hs
+++ b/libraries/libiserv/src/Remote/Slave.hs
@@ -62,11 +62,12 @@ startSlave' verbose base_path port = do
hSetBuffering stdout LineBuffering
sock <- openSocket port
+ actualPort <- socketPort sock
+ putStrLn $ "Listening on port " ++ show actualPort
forever $ do
when verbose $ trace "Opening socket"
pipe <- acceptSocket sock >>= socketToPipe
- putStrLn $ "Listening on port " ++ show port
when verbose $ trace "Starting serv"
uninterruptibleMask $ serv verbose (hook verbose base_path pipe) pipe
when verbose $ trace "serv ended"