fix socket error
This commit is contained in:
parent
d76447400d
commit
acc0e12f1d
3 changed files with 5 additions and 4 deletions
|
@ -5,4 +5,4 @@ setSpawnerProbability : 0.01
|
||||||
setFPS : 30
|
setFPS : 30
|
||||||
setClientMaxTimeout : 5
|
setClientMaxTimeout : 5
|
||||||
setFramesPerPing : 120
|
setFramesPerPing : 120
|
||||||
setLogLevel : Verbose
|
setLogLevel : Info
|
||||||
|
|
|
@ -122,7 +122,7 @@ processRequests = do
|
||||||
receiverThreadId <- liftIO $ do
|
receiverThreadId <- liftIO $ do
|
||||||
t <- forkIO $ do
|
t <- forkIO $ do
|
||||||
threadDelay $ 10 ^ 6
|
threadDelay $ 10 ^ 6
|
||||||
forever $ receiveMessage curLevel socketList queueList mainSocket serverQueue
|
forever $ receiveMessage curLevel socketList queueList sockContainer serverQueue
|
||||||
logPrintIO curLevel Verbose "enabled listener thread"
|
logPrintIO curLevel Verbose "enabled listener thread"
|
||||||
pure t
|
pure t
|
||||||
senderThreadId <- liftIO $ do
|
senderThreadId <- liftIO $ do
|
||||||
|
|
|
@ -33,13 +33,14 @@ receiveMessage
|
||||||
:: LogLevel
|
:: LogLevel
|
||||||
-> STM.TMVar [ClientSocket]
|
-> STM.TMVar [ClientSocket]
|
||||||
-> STM.TMVar [ClientQueue]
|
-> STM.TMVar [ClientQueue]
|
||||||
-> Socket
|
-> STM.TMVar Socket
|
||||||
-> STM.TQueue ClientMessage
|
-> STM.TQueue ClientMessage
|
||||||
-> IO ()
|
-> IO ()
|
||||||
receiveMessage curLevel socketList queueList sock queue = do
|
receiveMessage curLevel socketList queueList sockContainer queue = do
|
||||||
randSleep <- randomRIO (1, 1000)
|
randSleep <- randomRIO (1, 1000)
|
||||||
threadDelay randSleep
|
threadDelay randSleep
|
||||||
let maxBufferLength = 4096
|
let maxBufferLength = 4096
|
||||||
|
sock <- STM.atomically $ STM.readTMVar sockContainer
|
||||||
logPrintIO curLevel Verbose "read socket container for receiving"
|
logPrintIO curLevel Verbose "read socket container for receiving"
|
||||||
ptr <- mallocArray maxBufferLength
|
ptr <- mallocArray maxBufferLength
|
||||||
logPrintIO curLevel Verbose "receiving data"
|
logPrintIO curLevel Verbose "receiving data"
|
||||||
|
|
Loading…
Reference in a new issue