diff options
author | Kazu Yamamoto <kazu@iij.ad.jp> | 2012-12-28 12:51:32 +0900 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2013-02-11 21:38:06 -0800 |
commit | a691b2d846f34dfc580d5de36d644c190833ad08 (patch) | |
tree | cf985651a6bcfdc7e77adcb7967b31882b0a8dbe /libraries/base/GHC/Event | |
parent | 65309d8c642e7a80285b5b989f567e3537beffb3 (diff) | |
download | haskell-a691b2d846f34dfc580d5de36d644c190833ad08.tar.gz |
minor refactoring.
Diffstat (limited to 'libraries/base/GHC/Event')
-rw-r--r-- | libraries/base/GHC/Event/EPoll.hsc | 5 | ||||
-rw-r--r-- | libraries/base/GHC/Event/KQueue.hsc | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/libraries/base/GHC/Event/EPoll.hsc b/libraries/base/GHC/Event/EPoll.hsc index 1f6e2e78b3..c7a766239d 100644 --- a/libraries/base/GHC/Event/EPoll.hsc +++ b/libraries/base/GHC/Event/EPoll.hsc @@ -115,12 +115,13 @@ poll :: EPoll -- ^ state -> IO Int poll ep mtimeout f = do let events = epollEvents ep + fd = epollFd ep -- Will return zero if the system call was interupted, in which case -- we just return (and try again later.) n <- A.unsafeLoad events $ \es cap -> case mtimeout of - Just timeout -> epollWait (epollFd ep) es cap $ fromTimeout timeout - Nothing -> epollWaitNonBlock (epollFd ep) es cap + Just timeout -> epollWait fd es cap $ fromTimeout timeout + Nothing -> epollWaitNonBlock fd es cap when (n > 0) $ do A.forM_ events $ \e -> f (eventFd e) (toEvent (eventTypes e)) diff --git a/libraries/base/GHC/Event/KQueue.hsc b/libraries/base/GHC/Event/KQueue.hsc index 09e70841fd..2d37546842 100644 --- a/libraries/base/GHC/Event/KQueue.hsc +++ b/libraries/base/GHC/Event/KQueue.hsc @@ -116,10 +116,11 @@ poll :: KQueue -> IO Int poll kq mtimeout f = do let events = kqueueEvents kq + fd = kqueueFd kq n <- A.unsafeLoad events $ \es cap -> case mtimeout of - Just timeout -> kqueueWait (kqueueFd kq) es cap $ fromTimeout timeout - Nothing -> kqueueWaitNonBlock (kqueueFd kq) es cap + Just timeout -> kqueueWait fd es cap $ fromTimeout timeout + Nothing -> kqueueWaitNonBlock fd es cap when (n > 0) $ do A.forM_ events $ \e -> f (fromIntegral (ident e)) (toEvent (filter e)) |