File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,10 @@ module Network.Socket.Shutdown (
8
8
, gracefulClose
9
9
) where
10
10
11
- import Control.Concurrent (threadDelay , yield )
11
+ import Control.Concurrent (yield )
12
12
import qualified Control.Exception as E
13
13
import Foreign.Marshal.Alloc (mallocBytes , free )
14
+ import System.Timeout
14
15
15
16
#if !defined(mingw32_HOST_OS)
16
17
import Control.Concurrent.STM
@@ -83,18 +84,7 @@ bufSize :: Int
83
84
bufSize = 1024
84
85
85
86
recvEOFloop :: Socket -> Int -> Ptr Word8 -> IO ()
86
- recvEOFloop s tmout0 buf = loop 1 0
87
- where
88
- loop delay tmout = do
89
- -- We don't check the (positive) length.
90
- -- In normal case, it's 0. That is, only FIN is received.
91
- -- In error cases, data is available. But there is no
92
- -- application which can read it. So, let's stop receiving
93
- -- to prevent attacks.
94
- r <- recvBufNoWait s buf bufSize
95
- when (r == - 1 && tmout < tmout0) $ do
96
- threadDelay (delay * 1000 )
97
- loop (delay * 2 ) (tmout + delay)
87
+ recvEOFloop s tmout0 buf = void $ timeout tmout0 $ recvBuf s buf bufSize
98
88
99
89
#if !defined(mingw32_HOST_OS)
100
90
data Wait = MoreData | TimeoutTripped
You can’t perform that action at this time.
0 commit comments