From a8d5234c77634df9522727ff200cef4fcab49c22 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 9 Feb 2017 17:30:30 +0100 Subject: erts: Change return value for enif_select to negative int as error and positive as success. --- erts/doc/src/erl_nif.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index 9800a530f2..e8e7bd4a80 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -2583,7 +2583,7 @@ enif_map_iterator_destroy(env, &iter); - enum ErlNifSelectReturn + int enif_select(ErlNifEnv* env, ErlNifEvent event, enum ErlNifSelectFlags mode, void* obj, const ErlNifPid* pid, ERL_NIF_TERM ref) @@ -2626,36 +2626,36 @@ enif_map_iterator_destroy(env, &iter); the event object. This safe way of closing event objects must be used even if all notifications have been received and no further calls to enif_select have been made.

-

Returns an integer where different bits indicate the outcome of the call:

+

Returns a non-negative value on success where the following bits can be set:

- ERL_NIF_SELECT_ERROR - The master error bit. It will always be set if the call failed for - any reason. ERL_NIF_SELECT_STOP_CALLED The stop callback was called directly by enif_select. ERL_NIF_SELECT_STOP_SCHEDULED The stop callback was scheduled to run on some other thread or later by this thread. + +

Returns a negative value if the call failed where the follwing bits can be set:

+ ERL_NIF_SELECT_INVALID_EVENT Argument event is not a valid OS event object. ERL_NIF_SELECT_FAILED The system call failed to add the event object to the poll set. -

The return value from a successful call with mode as ERL_NIF_SELECT_STOP, - will contain either bit ERL_NIF_SELECT_STOP_CALLED or - ERL_NIF_SELECT_STOP_SCHEDULED.

-

Always use bitwise AND to test the return value. New significant bits - may be added in future releases to give more detailed information for both - failed and successful calls. Do NOT use equallity tests like ==, as - that may cause your application to stop working.

+

Use bitwise AND to test for specific bits in the return vaue. + New significant bits may be added in future releases to give more detailed + information for both failed and successful calls. Do NOT use equallity tests + like ==, as that may cause your application to stop working.

Example:

-retval = enif_select(env, fd, ERL_NIF_SELECT_READ, resource, ref); -if (retval & ERL_NIF_SELECT_ERROR) { +retval = enif_select(env, fd, ERL_NIF_SELECT_STOP, resource, ref); +if (retval < 0) { /* handle error */ } /* Success! */ +if (retval & ERL_NIF_SELECT_STOP_CALLED) { + /* ... */ +}
-- cgit v1.2.3