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

add option to disable SIGPIPE on BSD-like systems #111

Merged
merged 4 commits into from
Mar 30, 2017
Merged

Conversation

mmaxim
Copy link

@mmaxim mmaxim commented Mar 30, 2017

The point of this patch is to address the iOS app force closing when foregrounded after being in the background for awhile. See more info here:

golang/go#17393

We add an option to disable SIGPIPE on Darwin builds on new connections using the transports provided by this library (note only the TLS transport really matters in production). Since Linux and Windows don't have this option, it is off for those builds.

@mmaxim mmaxim requested review from maxtaco and strib March 30, 2017 01:57
@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

cc @chrisnojima @MarcoPolo

@chrisnojima
Copy link

Is it worth this much change vs the one liner suggested in that ticket. Timeouts gone etc

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

That didn't work, I tried it.

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

I'm not sure that guy tried it either. It doesn't sound like the first guy did either, he just stuck with his solution which is essentially what I did here

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

Also apparently that one liner breaks things on Android, which is why his patch got reverted out of Go 1.8.

@chrisnojima
Copy link

K. Well as long as we can find a minimal change. Maybe @maxtaco should review

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

Yeah I tagged him and Jeremy.

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

Also this change is not that large, it just looks a little large because in order to be able to set the option on a TLS connection I just needed to change things a little in a mostly superficial way.

@chrisnojima
Copy link

Cool. With the keep alive back it seems close

@mmaxim
Copy link
Author

mmaxim commented Mar 30, 2017

Yeah I put it back, but I don't think it actually does anything, AWS ELB doesn't count that as a connection actually being alive. Both Gregor and MD server have their own keep alive mechanisms to actually solve the problem, so I contemplated just removing it. But in the interest of making the minimal change, I think it is fine to keep it, it doesn't hurt anything.

@@ -75,6 +76,14 @@ func (t *connTransport) Dial(context.Context) (Transporter, error) {
if err != nil {
return nil, err
}

// If the client has requested to disable SIGPIPE, then do so now
Copy link

Choose a reason for hiding this comment

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

Very minor but I think all the other comments in this file end in punctuation, so would be nice to keep that up here and below.

Copy link
Author

Choose a reason for hiding this comment

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

I'll fix.

import "net"

func DisableSigPipe(c net.Conn) error {
return nil
Copy link

Choose a reason for hiding this comment

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

Should this panic or return an "unsupported" error instead? We shouldn't just ignore an option the user passed in and let them believe we're honoring it, right?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, how about something like:

return errors.New("DisableSigPipe not supported")

Copy link
Author

Choose a reason for hiding this comment

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

Although this makes it so that we need to detect whether this is supported on the clients of this library, which makes that code a lot more verbose. With this just doing nothing all that is simpler.

Copy link

Choose a reason for hiding this comment

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

Works for me, thanks!

Copy link
Author

Choose a reason for hiding this comment

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

How about I just add a better comment on DisableSigPipe that explains it is only available on Darwin?

Copy link
Author

Choose a reason for hiding this comment

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

Just thought it was the more flexible option, since there might be other use cases of the library other than the client and KBFS at some point.

Copy link

Choose a reason for hiding this comment

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

If you really want an option for future-proofing, maybe you can invert it to something like EnableDarwinSigPipe, which would be false by default, in case we ever have a situation where the caller needs to ensure it's enabled?

Copy link
Author

Choose a reason for hiding this comment

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

I can just nuke the option though, I think that is a good suggestion.

Copy link
Author

Choose a reason for hiding this comment

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

I just put up a new commit that ditches the option, let me know what you think.

Copy link

Choose a reason for hiding this comment

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

Thanks, definitely seems better to me.

@mmaxim mmaxim merged commit ed07556 into master Mar 30, 2017
@mmaxim mmaxim deleted the mike/sigpipe branch March 30, 2017 19:15
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.

4 participants