Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a race condition in demuxing (IO) #1730

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions network-mux/test/Test/Mux.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ smallMiniProtocolLimit = 16*1024

activeTracer :: forall m a. (MonadSay m, Show a) => Tracer m a
activeTracer = nullTracer
--activeTracer = showTracing sayTracer
--activeTracer = showTracing _sayTracer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change this line ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but it is changed to match the current name of the debug function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I don't like this upstream change: _names are reserved for not used identifiers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is called _sayTracer and it is unused since active tracer is commented out.
But ifdefs is another alternative...


_sayTracer :: MonadSay m => Tracer m String
_sayTracer = Tracer say
Expand Down Expand Up @@ -835,7 +835,10 @@ prop_demux_sdu a = do

setup state client_w
atomically $ writeTBQueue client_w $ BL.take (isRealLength badSdu) $ encodeInvalidMuxSDU badSdu
atomically $ putTMVar stopVar $ BL.replicate (fromIntegral $ isLength badSdu) 0xa
-- Incase this is an SDU with a payload of 0 byte, we still ask the responder to wait for
-- one byte so that we fail with an exception while parsing the header instead of risk
-- having the responder succed after reading 0 bytes.
atomically $ putTMVar stopVar $ BL.replicate (max (fromIntegral $ isLength badSdu) 1) 0xa

res <- wait said
case res of
Expand Down