processone / fast_tls

TLS / SSL OpenSSL-based native driver for Erlang / Elixir
https://www.ejabberd.im
Other
83 stars 37 forks source link

From a gen_server init to the on_load directive #43

Closed NelsonVides closed 4 years ago

NelsonVides commented 4 years ago

As described in the commit:

Before OTP 19.0, if the on_load directive fails, any previously loaded
code would become old, essentially leaving the system without any
working and reachable instance of the module. This is not true anymore
since OTP 19.0, so loading the nifs within the on_load directive is
today the cleanest and best code pattern.

It seems indeed very convoluted to have an entire application and
supervision tree with a worker gen_server just to load the nifs. Also,
one of the `handle_info` heads of the gen_server is even a remnant of
the times when `fast_tls` was implemented as a port driver instead of as
nifs, which is a high sign this needed some modernisation.

I'm not sure if you have any backwards-compatibility related reason to keep this whole app-supervisor-gen_server logic, but it seems convoluted, overly verbose, and quite redundant to me, so I'd argue very much in favour of this more modern way 🙂

prefiks commented 4 years ago

Yes this was leftover from -on_load causing problem on some older versions. But i think this is we should be good to use it now.