Skip to content

Commit

Permalink
Merge pull request haskell#592 from arybczak/async-exception-safe-free
Browse files Browse the repository at this point in the history
Make call to c_free async exception safe
  • Loading branch information
kazu-yamamoto authored Nov 25, 2024
2 parents 74ae9b7 + ed5d588 commit 25b6814
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Network/Socket/Syscall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import System.IO.Error (catchIOError)
#endif

#if defined(mingw32_HOST_OS)
import Control.Exception (bracket)
import Foreign (FunPtr)

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.6)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.6)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.6)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.8)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.8)

The import of ‘Foreign’ is redundant

Check warning on line 15 in Network/Socket/Syscall.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.8)

The import of ‘Foreign’ is redundant
import GHC.Conc (asyncDoProc)
#else
Expand Down Expand Up @@ -202,13 +203,12 @@ accept listing_sock = withNewSocketAddress $ \new_sa sz ->
throwSocketErrorIfMinus1Retry "Network.Socket.accept" $
c_accept_safe fd sa ptr_len
| otherwise = do
paramData <- c_newAcceptParams fd (fromIntegral sz) sa
rc <- asyncDoProc c_acceptDoProc paramData
new_fd <- c_acceptNewSock paramData
c_free paramData
when (rc /= 0) $
throwSocketErrorCode "Network.Socket.accept" (fromIntegral rc)
return new_fd
bracket (c_newAcceptParams fd (fromIntegral sz) sa) c_free $ \paramData -> do
rc <- asyncDoProc c_acceptDoProc paramData
new_fd <- c_acceptNewSock paramData
when (rc /= 0) $
throwSocketErrorCode "Network.Socket.accept" (fromIntegral rc)
return new_fd
#else
callAccept fd sa sz = with (fromIntegral sz) $ \ ptr_len -> do
# ifdef HAVE_ADVANCED_SOCKET_FLAGS
Expand Down

0 comments on commit 25b6814

Please sign in to comment.