-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3380: cardano-ping: Make sure that the connection is reset by using SO_LINGER r=karknu a=karknu The way the connection is torn down isn't ideal. Unless the 5s timeout triggers the connection termination is initiated by the server which can leave connections in TIME_WAIT. In the future `ouroboros-network` will use SO_LINGER to trigger a reset of the connection, but for now at least cardano-node can set it. Co-authored-by: Karl Knutsson <karl.knutsson@iohk.io>
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "HsNet.h" | ||
|
||
module Linger | ||
( StructLinger (..) | ||
) where | ||
|
||
import Foreign.C (CInt) | ||
import Foreign.Storable (Storable (..)) | ||
|
||
|
||
-- TODO: to be removed once a new version of `network` library is released. | ||
data StructLinger = StructLinger { | ||
-- | Set the linger option on. | ||
sl_onoff :: CInt, | ||
|
||
-- | Linger timeout. | ||
sl_linger :: CInt | ||
} | ||
deriving (Eq, Ord, Show) | ||
|
||
instance Storable StructLinger where | ||
sizeOf _ = (#const sizeof(struct linger)) | ||
alignment _ = alignment (0 :: CInt) | ||
|
||
peek p = do | ||
onoff <- (#peek struct linger, l_onoff) p | ||
linger <- (#peek struct linger, l_linger) p | ||
return $ StructLinger onoff linger | ||
|
||
poke p (StructLinger onoff linger) = do | ||
(#poke struct linger, l_onoff) p onoff | ||
(#poke struct linger, l_linger) p linger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters