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

src/ranch_ssl.erl:137: ssl:ssl_accept/3: deprecated; use ssl:handshake/3 instead #195

Closed
getong opened this issue Jun 28, 2018 · 8 comments

Comments

@getong
Copy link
Contributor

getong commented Jun 28, 2018

There is a solution for this, but I don't know how to use it with erlang.mk

-ifdef(OTP_RELEASE).
-define(ssl_accept(ClientSocket, SSLOptions), ssl:handshake(ClientSocket, SSLOptions)).
-else.
-define(ssl_accept(ClientSocket, SSLOptions), ssl:ssl_accept(ClientSocket, SSLOptions)).
-endif.

copy from joedevivo/chatterbox#127

@essen
Copy link
Member

essen commented Jun 28, 2018

Please instead review #194 which is what we'll move toward while approaching Ranch 2.0. The warning in question can just be disabled.

Note that your solution is incorrect because ssl:handshake's return value is different.

@essen
Copy link
Member

essen commented Jun 28, 2018

I'm guessing you get an issue with rebar and warning_as_errors set in your project preventing compilation?

@getong
Copy link
Contributor Author

getong commented Jun 28, 2018

Same error:

$ git clone https://github.com/juhlig2/ranch juhlig2_ranch
$ cd juhlig2_ranch
$ git checkout handshake
$ make
DEPEND ranch.d
ERLC   ranch.erl ranch_acceptor.erl ranch_acceptors_sup.erl ranch_app.erl ranch_conns_sup.erl ranch_listener_sup.erl ranch_protocol.erl ranch_server.erl ranch_ssl.erl ranch_sup.erl ranch_tcp.erl ranch_transport.erl
compile: warnings being treated as errors
src/ranch_ssl.erl:137: ssl:ssl_accept/3: deprecated; use ssl:handshake/3 instead
erlang.mk:5227: recipe for target 'ebin/ranch.app' failed
make[1]: *** [ebin/ranch.app] Error 1
erlang.mk:4985: recipe for target 'app' failed
make: *** [app] Error 2

I compile ranch under erlang version 21, and this is the error msg.

@getong
Copy link
Contributor Author

getong commented Jun 28, 2018

Yes, these two functions return different results. The solution is wrong.

@essen
Copy link
Member

essen commented Jun 28, 2018

I know it doesn't compile by itself under 21 but Ranch is used as a dependency and Erlang.mk disables warning_as_errors for dependencies so this has little impact on users, it compiles for them.

I'm asking about rebar because to prevent future problems I can generate a rebar.config that will disable warning_as_errors for rebar too, and then we can separately ignore that warning.

@getong
Copy link
Contributor Author

getong commented Jun 28, 2018

How about this:

-ifdef(OTP_RELEASE).
ssl_accept(ClientSocket, SSLOptions) ->
    ssl:handshake(ClientSocket, SSLOptions).
-else.
ssl_accept(ClientSocket, SSLOptions) ->
  case ssl:ssl_accept(ClientSocket, SSLOptions) of
     ok ->
          {ok, ClientSocket};
     {error, Reason} ->
          {error, Reason}
  end.
-endif.

The function returns the same result now.

@essen
Copy link
Member

essen commented Jun 28, 2018

We've added the warning disabling to the PR I mentioned. It'll be merged when I'm less busy with other things.

@essen
Copy link
Member

essen commented Jul 2, 2018

Closing, thanks!

I also confirmed that it did NOT produce an error when used with rebar3 as a dependency, only a warning. If it was producing an error with an other tool, please let me know.

@essen essen closed this as completed Jul 2, 2018
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