networking - Haskell is getting deadlocked in a situation it (in theory) shouldn't be -


After a

after a stalemate error message yields ( * exception: thread in an MVAr operation indefinitely Blocked for). I have taken step by step, and I have not been seen on this issue.

  • On the main thread, an MVR has been created, and given to the creator, running on a new thread <
  • To get some thread MVar Waiting for wait, main thread is also running in loop and blocks
  • Once the manufacturer has a connection, it is continuing in the loop, and after receiving something from the socket, the MVAr < / Li> Says

meaning (as far as I understand it), it should end the manufacturer's Student put some MVR, and are waiting to mainly get some.

If it gets trapped because listenOn does not connect immediately, how can I get it? MVAr needs to be made in the main, and before the manufacturer is prickly, then it can be passed in.

Import code. . - & gt; IO string getSockInfo s = information and lieutenant; - GetPeerName Return $ Case Info (SockAddrInet Port Ender) - & gt; "Eder / Port:" ++ (Show Eder) ++ "/" ++ (Show Port) (SockAddrInet6 Port Flow Adder Area) - & gt; ++ (show extension) ++ (show extension) ++ "/" ++ (show port) ++ "flow / region:" ++ (show flow) ++ "/" ++ (show Scope of Manufacturer:: MVR String -> IO (Manufacturer) Meter = s & lt; - ListenOn (portnumber 5555) putStrLn "listening ..." information & lt; - getSockInfo has putStrLn $ "Connect to" ++ information <- socketToHandle s ReadMode loop HM where loop hm = message do & lt; hGetLine h putMVar meter message loop hm main :: IO (main) = do with $ Sets Meter & lt; - newEmptyMVar prod & Lt; - forkIO $ manufacturer meter loop meter where loop meter = do n & lt; - takeMVar M print n loop M

Listen returns immediately but does not give you a connected socket, so it has been attempted to use or it is unsuccessful to read. I'm not sure That's why you do not see an error message to indicate, because when I run your code it does The front. In any case, the thread is probably the point that MVAr can write, the main thread is dying on stagnant leaves as nothing. After listenOn accept code> should wait for a remote connection to fix it.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -