File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import System.IO.Error (catchIOError)
11
11
#endif
12
12
13
13
#if defined(mingw32_HOST_OS)
14
+ import Control.Exception (bracket )
14
15
import Foreign (FunPtr )
15
16
import GHC.Conc (asyncDoProc )
16
17
#else
@@ -202,13 +203,12 @@ accept listing_sock = withNewSocketAddress $ \new_sa sz ->
202
203
throwSocketErrorIfMinus1Retry " Network.Socket.accept" $
203
204
c_accept_safe fd sa ptr_len
204
205
| otherwise = do
205
- paramData <- c_newAcceptParams fd (fromIntegral sz) sa
206
- rc <- asyncDoProc c_acceptDoProc paramData
207
- new_fd <- c_acceptNewSock paramData
208
- c_free paramData
209
- when (rc /= 0 ) $
210
- throwSocketErrorCode " Network.Socket.accept" (fromIntegral rc)
211
- return new_fd
206
+ bracket (c_newAcceptParams fd (fromIntegral sz) sa) c_free $ \ paramData -> do
207
+ rc <- asyncDoProc c_acceptDoProc paramData
208
+ new_fd <- c_acceptNewSock paramData
209
+ when (rc /= 0 ) $
210
+ throwSocketErrorCode " Network.Socket.accept" (fromIntegral rc)
211
+ return new_fd
212
212
#else
213
213
callAccept fd sa sz = with (fromIntegral sz) $ \ ptr_len -> do
214
214
# ifdef HAVE_ADVANCED_SOCKET_FLAGS
You can’t perform that action at this time.
0 commit comments