From 4f8071d81aa0690caa3adc734d73a1cb004ad808 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 19 Sep 2016 14:34:57 +0200 Subject: erts: Remove deprecated nif 'reload' feature and instead let erlang:load_nif/2 return {error, {reload, _}} before even trying to load the library if a NIF library has already been successfully loaded for the calling module instance. --- erts/doc/src/erl_nif.xml | 46 +++++++++++++--------------------------------- erts/doc/src/erlang.xml | 6 +++++- 2 files changed, 18 insertions(+), 34 deletions(-) (limited to 'erts/doc/src') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index b5dc9037c4..5d55cc9121 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -296,8 +296,8 @@ return term; synchronization. This includes terms in process-independent environments that are shared between threads. Resource objects also require synchronization if you treat them as mutable.

-

The library initialization callbacks load, reload, and - upgrade are all thread-safe even for shared state data.

+

The library initialization callbacks load and + upgrade are thread-safe even for shared state data.

Version Management @@ -498,7 +498,7 @@ return term; Initialization ERL_NIF_INIT(MODULE, - ErlNifFunc funcs[], load, reload, upgrade, unload) + ErlNifFunc funcs[], load, NULL, upgrade, unload)

This is the magic macro to initialize a NIF library. It is to be evaluated in global file scope.

@@ -507,11 +507,14 @@ return term; the macro.

funcs is a static array of function descriptors for all the implemented NIFs in this library.

-

load, reload, upgrade and unload - are pointers to functions. One of load, reload, or +

load, upgrade and unload + are pointers to functions. One of load or upgrade is called to initialize the library. unload is called to release the library. All are described individually below.

+

The fourth argument NULL is ignored. It + was earlier used for the deprectated reload callback + which is no longer supported since OTP 20.

If compiling a NIF for static inclusion through --enable-static-nifs, you must define STATIC_ERLANG_NIF before the ERL_NIF_INIT declaration.

@@ -539,7 +542,7 @@ return term; and there is old code of this module with a loaded NIF library.

Works as load, except that *old_priv_data already contains the value set by the last call to load or - reload for the old module code. *priv_data is + upgrade for the old module code. *priv_data is initialized to NULL when upgrade is called. It is allowed to write to both *priv_data and *old_priv_data.

@@ -551,27 +554,7 @@ return term;

unload is called when the module code that the NIF library belongs to is purged as old. New code of the same - module may or may not exist. Notice that unload is not - called for a replaced library as a consequence of reload.

-
- int (*reload)(ErlNifEnv* env, void** - priv_data, ERL_NIF_TERM load_info) - - -

The reload mechanism is deprecated. It was only intended - as a development feature. Do not use it as an upgrade method for - live production systems. It can be removed in future releases. - Ensure to pass reload as NULL to - ERL_NIF_INIT - to disable it when not used.

-
-

reload is called when the NIF library is loaded and a - previously loaded library already exists for this module code.

-

Works as load, except that - *priv_data already contains the value set by the - previous call to load or reload.

-

The library fails to load if reload returns - anything other than 0 or if reload is NULL.

+ module may or may not exist.

@@ -2249,9 +2232,8 @@ enif_map_iterator_destroy(env, &iter); returns NULL and sets *tried to flags. It is allowed to set tried to NULL.

Notice that enif_open_resource_type is only allowed to be - called in the three callbacks - load, - reload, and + called in the two callbacks + load and upgrade.

@@ -2305,10 +2287,8 @@ enif_map_iterator_destroy(env, &iter); Get the private data of a NIF library.

Returns the pointer to the private data that was set by - load, - reload, or + load or upgrade.

-

Was previously named enif_get_data.

diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index f42c39db5f..d22d40ba8a 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -2598,9 +2598,13 @@ os_prompt% The library did not fulfill the requirements as a NIF library of the calling module. - load | reload | upgrade + load | upgrade The corresponding library callback was unsuccessful. + reload + A NIF library is already loaded for this module instance. + The previously deprecated reload feature was removed in OTP 20. + old_code The call to load_nif/2 was made from the old code of a module that has been upgraded; this is not -- cgit v1.2.3