summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFacundo Domínguez <facundo.dominguez@tweag.io>2021-04-02 17:11:07 +0000
committerBen Gamari <ben@smart-cactus.org>2021-05-12 18:36:41 -0400
commita12239f43ab494078f80d410867d95e37238dc0d (patch)
tree87d3f9c3d3c0be88d32706dafc2035d56f31f301
parent9da4cf411f9f9b30ce912f9631895f3896e74b4e (diff)
downloadhaskell-a12239f43ab494078f80d410867d95e37238dc0d.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. (cherry picked from commit b39dec86df8106a2bb4770758941572073ad57a2)
-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"