Skip to content

Commit

Permalink
Merge #3660
Browse files Browse the repository at this point in the history
3660: Platform independent TCPInfo trace r=coot a=coot

- network-mux: platform independent TCP info trace
- Added interface-CHANGELOG.md file


Co-authored-by: Marcin Szamotulski <coot@coot.me>
  • Loading branch information
iohk-bors[bot] and coot authored Mar 9, 2022
2 parents 1bdce8b + 976d0d5 commit 44278e5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
16 changes: 16 additions & 0 deletions docs/interface-CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Interface Change Log

This change log file is written for the benefit of Cardano Node development
team. See [consensus
CHANGELOG](../ouroboros-consensus/docs/interface-CHANGELOG.md) file for how
this changelog is supposed to be used.


## Circa 2022-03-08


### Added

- on Linux when `network-mux` is compiled with `tracetcpinfo` cabal flag, mux
will log `MuxTraceTCPInfo`. For performance reasons this is disabled by
default.
3 changes: 2 additions & 1 deletion network-mux/network-mux.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ library
Network.Mux.DeltaQ.TraceStatsSupport
Network.Mux.DeltaQ.TraceTransformer
Network.Mux.DeltaQ.TraceTypes
Network.Mux.TCPInfo
Control.Concurrent.JobPool

if os(linux)
other-modules: Network.Mux.TCPInfo
other-modules: Network.Mux.TCPInfo.Linux

if os(windows)
exposed-modules:
Expand Down
16 changes: 16 additions & 0 deletions network-mux/src/Network/Mux/TCPInfo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{-# LANGUAGE CPP #-}

module Network.Mux.TCPInfo
( StructTCPInfo (..)
#if os_HOST_linux
, SocketOption (TCPInfoSocketOption)
#endif
) where

#if os_HOST_linux
import Network.Mux.TCPInfo.Linux
#else
data StructTCPInfo = TCPInfoUnavailable
deriving (Eq, Ord, Show)
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

#include "HsNet.h"

module Network.Mux.TCPInfo
module Network.Mux.TCPInfo.Linux
( StructTCPInfo (..)
, SocketOption(TCPInfoSocketOption)
, SocketOption (TCPInfoSocketOption)
) where

import Foreign.C
Expand Down
10 changes: 2 additions & 8 deletions network-mux/src/Network/Mux/Trace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import GHC.Generics (Generic (..))
import Quiet (Quiet (..))

import Network.Mux.Types
#ifdef linux_HOST_OS
import Network.Mux.TCPInfo
#endif


--
Expand Down Expand Up @@ -152,11 +150,7 @@ data MuxTrace =
| MuxTraceStartedOnDemand MiniProtocolNum MiniProtocolDir
| MuxTraceTerminating MiniProtocolNum MiniProtocolDir
| MuxTraceShutdown
#ifdef linux_HOST_OS
| MuxTraceTCPInfo StructTCPInfo Word16
#else
| MuxTraceTCPInfo Word16
#endif

instance Show MuxTrace where
show MuxTraceRecvHeaderStart = printf "Bearer Receive Header Start"
Expand Down Expand Up @@ -194,7 +188,7 @@ instance Show MuxTrace where
show (MuxTraceStartedOnDemand mid dir) = printf "Started on demand (%s) in %s" (show mid) (show dir)
show (MuxTraceTerminating mid dir) = printf "Terminating (%s) in %s" (show mid) (show dir)
show MuxTraceShutdown = "Mux shutdown"
#ifdef linux_HOST_OS
#ifdef os_HOST_linux
show (MuxTraceTCPInfo StructTCPInfo
{ tcpi_snd_mss, tcpi_rcv_mss, tcpi_lost, tcpi_retrans
, tcpi_rtt, tcpi_rttvar, tcpi_snd_cwnd }
Expand All @@ -207,6 +201,6 @@ instance Show MuxTrace where
(fromIntegral tcpi_retrans :: Word)
len
#else
show (MuxTraceTCPInfo len) = printf "TCPInfo len %d" len
show (MuxTraceTCPInfo _ len) = printf "TCPInfo len %d" len
#endif

0 comments on commit 44278e5

Please sign in to comment.