Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

calling threadWaitWrite only when errnor is eAGAIN

  • Loading branch information...
commit 2b09a9b1cad92460fef0b5a1ee8137590669ac23 1 parent 8771596
@kazu-yamamoto authored
Showing with 9 additions and 3 deletions.
  1. +6 −2 Network/Sendfile/BSD.hsc
  2. +3 −1 Network/Sendfile/Linux.hsc
View
8 Network/Sendfile/BSD.hsc
@@ -74,7 +74,9 @@ sendloop dst src off len sentp hook = do
if errno `elem` [eAGAIN, eINTR] then do
sent <- peek sentp
hook
- threadWaitWrite dst
+ -- Parallel IO manager use edge-trigger mode.
+ -- So, calling threadWaitWrite only when errnor is eAGAIN.
+ when (errno == eAGAIN) $ threadWaitWrite dst
let newoff = off + sent
newlen = if len == entire then entire else len - sent
sendloop dst src newoff newlen sentp hook
@@ -163,7 +165,9 @@ sendloopHeader dst src off len sentp hdr hlen = do
else
return $ Just (newoff, len - sent)
else do
- threadWaitWrite dst
+ -- Parallel IO manager use edge-trigger mode.
+ -- So, calling threadWaitWrite only when errnor is eAGAIN.
+ when (errno == eAGAIN) $ threadWaitWrite dst
let newlen = if len == entire then entire else len - sent
newhdr = remainingChunks (fromIntegral sent) hdr
newhlen = hlen - sent
View
4 Network/Sendfile/Linux.hsc
@@ -102,7 +102,9 @@ sendloop dst src offp len hook = do
loop 0 = return ()
loop left = do
hook
- threadWaitWrite dst
+ -- Parallel IO manager use edge-trigger mode.
+ -- So, calling threadWaitWrite only when errnor is eAGAIN.
+ when (errno == eAGAIN) $ threadWaitWrite dst
sendloop dst src offp left hook
-- Dst Src in order. take care
Please sign in to comment.
Something went wrong with that request. Please try again.