@@ -351,6 +351,7 @@ setSocketCloseOnExec socket =
351351
352352gracefulShutdown :: Counter -> IO ()
353353gracefulShutdown counter = do
354+ -- To avoid race condition, we just use threadDelay, not MVar.
354355 threadDelay 10000000
355356 noConnections <- isZero counter
356357 unless noConnections $ gracefulShutdown counter