Skip to content

Commit

Permalink
fixed early increment bug in (-@<) causing segfaults o__O
Browse files Browse the repository at this point in the history
  • Loading branch information
Cetin Sert committed May 31, 2012
1 parent 6240eba commit 9ddf668
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Main.hs
Expand Up @@ -195,12 +195,12 @@ main :: IO ()
main = withSocketsDo $ tryWith (const . print $ LS "INVALID SYNTAX") $ do
mapM_ B.putStrLn [ "\n", name, copyright, "", build, "\n" ]
tasks <- parse <$> getArgs
when (null tasks) $! mapM_ B.putStrLn [ " Documentation: http://fusion.corsis.eu", "",""]
unless (null tasks) $! do
when zeroCopy $ print (LS "zeroCopy" , zeroCopy )
when (numCapabilities > 1) $ print (LS "numCapabilities", numCapabilities)
mapM_ (forkIO . run) tasks
void Prelude.getChar
when (null tasks) $! mapM_ B.putStrLn [ " Documentation: http://fusion.corsis.eu", "",""]


parse :: [String] -> [Task]
Expand Down Expand Up @@ -231,9 +231,8 @@ initPortVectors = do
let i = fromIntegral p
withMVar portVectors $ \(c,s) -> do
cv <- SVM.read c i
SVM.write c i $ cv + 1

This comment has been minimized.

Copy link
@CetinSert

CetinSert Jun 10, 2012

Member

this was removed but

if cv > 0 then SVM.read s i >>= deRefStablePtr
else do l <- (ap @<); SVM.write s i =<< newStablePtr l; return l
if cv > 0 then do SVM.read s i >>= deRefStablePtr

This comment has been minimized.

Copy link
@CetinSert

CetinSert Jun 10, 2012

Member

but not added here probably causing issue 4

else do l <-(ap @<); SVM.write s i =<< newStablePtr l; SVM.write c i $! cv+1; return l

(-✖) :: AddrPort -> IO ()
(-✖) ap@(_ :@: p) = do
Expand Down Expand Up @@ -297,10 +296,11 @@ run ((:><:) fp) = do
initPortVectors
r <- (rp -@<)
o -✖- rp |<>| \t -> do
c <- (r !<@)
killThread =<< takeMVar t
l `sendAll` "+"
o >-< c $ (rp -✖)
let f = killThread =<< takeMVar t
tryWith (const f) $! do
c <- (r !<@); f
l `sendAll` "+"
o >-< c $ (rp -✖)

(->-) :: Peer -> Host -> Port -> IO ()
(o ->- rh) rp = do
Expand Down

0 comments on commit 9ddf668

Please sign in to comment.