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

Send timeout #1953

Merged
merged 4 commits into from
Apr 20, 2020
Merged

Send timeout #1953

merged 4 commits into from
Apr 20, 2020

Conversation

karknu
Copy link
Contributor

@karknu karknu commented Apr 15, 2020

No description provided.

@karknu karknu marked this pull request as ready for review April 16, 2020 14:11
@karknu karknu requested review from dcoutts and coot April 16, 2020 14:11
@karknu
Copy link
Contributor Author

karknu commented Apr 16, 2020

Implements #1949

Copy link
Contributor

@coot coot left a comment

Choose a reason for hiding this comment

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

Nice; only minor code layout and some simplifications suggested.

network-mux/src/Network/Mux/Egress.hs Outdated Show resolved Hide resolved
traceWith muxTracer $ Mx.MuxTraceHandshakeClientError err (diffTime ts_end ts_start)
throwIO err
Right (Right app) -> do
Just (Right (Right app)) -> do
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simplify the Maybe (Either _ (Either _ r)) type?

Copy link
Contributor

Choose a reason for hiding this comment

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

what about this idea:

data HandshakeException a = 
    HandshakeProtocolLimit ProtocolLimitfailure
  | HandshakeProtocolError a
  | HanshakeTimeout
 
tryHandshake ::  m (Either a r) -> m (Either (HanshakeException a) r)
tryHandshaket = ... withTimeoutSerial ... try ... 

The a in tryHandshake would be different for client and server.

Copy link
Contributor Author

@karknu karknu Apr 17, 2020

Choose a reason for hiding this comment

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

A great idea!
The type signature for a tryHanshake usable by both initiator and responder will look far worse than the Maybe (Either _ (Either _ r)) it is replacing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Really? Even though HandshakeException a is polymorphic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried and failed to get around the need for a Maybe (Either _ (Either _ r)) case statement in tryHandshake which made things far worse.
The updated code works and is more like your initial suggestion.

Simplify mux timeout code by taking advantage of that negative timeouts
means no timeout.
Use an overall timeout of 10s which covers both send and recv time.
Copy link
Contributor

@coot coot left a comment

Choose a reason for hiding this comment

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

LGTM

@karknu
Copy link
Contributor Author

karknu commented Apr 20, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 20, 2020

@iohk-bors iohk-bors bot merged commit a5ca958 into master Apr 20, 2020
@iohk-bors iohk-bors bot deleted the karknu/send_timeout branch April 20, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants