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

mochiweb_http:start/1 effectively links #58

Closed
yrashk opened this issue Aug 30, 2011 · 7 comments
Closed

mochiweb_http:start/1 effectively links #58

yrashk opened this issue Aug 30, 2011 · 7 comments

Comments

@yrashk
Copy link

yrashk commented Aug 30, 2011

https://github.com/mochi/mochiweb/blob/master/src/mochiweb_socket_server.erl#L128

IMHO, start/* is expected not to link, if somebody wants to link, there should be a separate start_link/* function.

@etrepum
Copy link
Member

etrepum commented Aug 30, 2011

What's the use case for having start not link? Do you have a proposal to do this in a backwards compatible way?

@yrashk
Copy link
Author

yrashk commented Aug 30, 2011

My use case was when I need to try starting mochiweb, but if its returning {error, eaddrinuse}, do something else. start/1 tricked me into believing that it does not link to the current process. Since it did, it actually crashed my gen_server, so I had to resort to gen_tcp:listen to try port's availability first.

Besides, it's just breaking the convention that start doesn't link but start_link does. I don't think this adjustment can be done in a backwards compatible way.

One option that I see is to add {link, boolean()} option to disable linking when necessary. It will not solve the problem of figuring out that start does something it is not supposed to do, but at least it will provide a way to get around of that behaviour.

@etrepum
Copy link
Member

etrepum commented Aug 30, 2011

I agree that it would be ideal that start did not link, but backwards compatibility is a more important goal for us right now. The mistake was made several years ago, LOTS of code uses mochiweb (most of which we don't have any control over), and this is the first request to change that behavior to my knowledge.

Perhaps we could add a start_link, start/2, and add a deprecation message to start/1 or something like that. Definitely not something we could just fix very quickly.

@yrashk
Copy link
Author

yrashk commented Aug 30, 2011

start_link plus an option for using start in a way that it won't link ({link, false} option) will be great. Plus a documentation saying that until this is deprecated, start actually does link so people can have easier time figuring this out.

@etrepum
Copy link
Member

etrepum commented Aug 30, 2011

So I think I'm going to add a start_link/1 where appropriate and add a {link, false} option to start/1 with no deprecation warnings yet. I'll leave some comments in the code so that we know how to phase out the linked start/1 behavior carefully (will take a while to do it smoothly: add {link, false} and start_link/1, deprecation of start/1 without {link, false}, change default behavior, add deprecation warning for {link, false}, removal of {link, false}).

@etrepum
Copy link
Member

etrepum commented Aug 30, 2011

I think this should solve your request for now, with the expectation that we'll eventually phase out the current (stupid) default. Please re-open if you think something else needs to change.

fb4a292

@etrepum etrepum closed this as completed Aug 30, 2011
@yrashk
Copy link
Author

yrashk commented Aug 30, 2011

thanks a lot! that was really quick :)

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

No branches or pull requests

2 participants