mirror of https://github.com/voidlizard/hbs2
fix 6yhqpH81tK address-in-use-after-restart-macos
This commit is contained in:
parent
4ca064bec9
commit
52dff69f74
|
@ -66,6 +66,8 @@ newMessagingUDP reuse saddr =
|
||||||
let a = addrAddress l
|
let a = addrAddress l
|
||||||
so <- liftIO $ socket (addrFamily l) (addrSocketType l) (addrProtocol l)
|
so <- liftIO $ socket (addrFamily l) (addrSocketType l) (addrProtocol l)
|
||||||
|
|
||||||
|
liftIO $ withFdSocket so setCloseOnExecIfNeeded
|
||||||
|
|
||||||
when reuse $ do
|
when reuse $ do
|
||||||
liftIO $ setSocketOption so ReuseAddr 1
|
liftIO $ setSocketOption so ReuseAddr 1
|
||||||
|
|
||||||
|
@ -102,7 +104,9 @@ runMessagingUDP MessagingUDP{..} = void $ flip runContT pure do
|
||||||
so <- liftIO (readTVarIO sock) >>= orThrowUser "UDP socket is not ready"
|
so <- liftIO (readTVarIO sock) >>= orThrowUser "UDP socket is not ready"
|
||||||
|
|
||||||
void $ ContT $ bracket (pure (Just so)) $ \case
|
void $ ContT $ bracket (pure (Just so)) $ \case
|
||||||
Just so -> liftIO (close so >> atomically (writeTVar sock Nothing))
|
Just so -> liftIO do
|
||||||
|
close so >> atomically (writeTVar sock Nothing)
|
||||||
|
|
||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
|
|
||||||
unless mcast $ do
|
unless mcast $ do
|
||||||
|
|
Loading…
Reference in New Issue