Age | Commit message (Collapse) | Author |
|
* sverker/master/enif_whereis_pid-dirty-dtor:
erts: Add test of enif_whereis* from resource destructor
erts: Simplify nif_SUITE:nif_whereis* tests
erts: Schedule resource destructors always
|
|
into sverker/master/enif_whereis_pid-dirty-dtor
|
|
|
|
to run user NIF code in a more known execution context.
Fixes problems like user calling enif_whereis_pid() in destructor
which may need to release process main lock in order to lock reg_tab.
|
|
Wait for resource-holding processes to garbage collect before
exiting to know destructors have been called.
|
|
This helps avoid long sequences of enif_is_xxx in code that
serializes terms (such as JSON encoders) by letting the user
switch on the type.
|
|
as a macro wrappper around enif_compare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* sverker/enif-cancel-select/OTP-15095:
erts: Add ERL_NIF_SELECT_CANCEL flag for enif_select
|
|
A lot of erts internal messages used behind APIs to create
non-blocking calls, e.g. port_command, would cause the seq_trace
token to be cleared from the caller when it should not.
This commit fixes that and adds asserts that makes sure
that all messages sent have to correct token set.
Fixes: ERL-602
|
|
to deselect read and/or writes without stop callback.
|
|
|
|
Fix bug in enif_binary_to_term for immediates
|
|
Symptom: Heap corruption
Expanded test case to provoke this bug
and test some more term types.
|
|
* lukas/erts/poll-thread/OTP-14346:
erts: nif resource stop from poll-thread is a indirect call
|
|
|
|
|
|
|
|
|
|
Add syntax in try/catch to retrieve the stacktrace directly
|
|
This introduces a way to retrieve erlang terms from NIF IO queues
without having to resort to copying.
OTP-14797
|
|
|
|
|
|
|
|
|
|
|
|
|
|
that could cause heap corruption if
whereis lookup conflicts with other register updater
AND other thread sends on-heap message while main lock is released.
Also improved enif_whereis from dirty nifs by passing c_p as NULL.
|
|
Add enif_whereis_pid() and enif_whereis_port() functions
OTP-14453
|
|
and base allowed hash deviation on nr of standard deviations
to make it easier to fiddle with the work load.
|
|
Pass number of expected messages in order to
wait longer for messages (for slow machines)
while not wasting test time waiting for nothing.
|
|
which is scheduled on non-smp VM.
|
|
#### Why do we need this new feature?
There are cases when a NIF needs to send a message, using `enif_send()`, to a long-lived process with a registered name.
A common use-case is logging, where asynchronous fire-and-forget messages are the norm.
There can also be cases where a yielding or dirty NIF or background thread may request a callback from a service with additional information it needs to complete its operation, yielding or waiting (with suitable timeouts, etc) until its state has been updated through the NIF module's API.
NIFs can only send messages to pids, and the lack of name resolution leaves a complicated dance between separate monitoring processes and the NIF as the only way to keep a NIF informed of the whereabouts of such long-lived processes.
Providing a reliable, built-in facility for NIFs to resolve process (or port) names simplifies these use cases considerably.
#### Risks or uncertain artifacts?
Testing has not exposed any significant risk.
The implementation behaves as expected on regular and dirty scheduler threads as well as non-scheduler threads.
By constraining the `enif_whereis_...()` functions to their minimal scopes and using patterns consistent with related functions, the implementation, testing, and maintenance burden is low.
The API and behavior of existing functions is unchanged.
#### How did you solve it?
While extending `enif_send()` to operate on a pid or an atom (as `erlang:send/2` does) was attractive, it would have entailed changing the type of its `to_pid` parameter and thereby breaking backward compatibility.
The same consideration applies to `enif_port_command()`.
That leaves a choice between 1, 2, or 3 new functions:
1. `enif_whereis()`
2. `enif_whereis_pid()` and `enif_whereis_port()`
3. All of the above.
While option (1), directly mimicking the behavior of `erlang:whereis/1`, is appealing, it poses potential problems if `pid()` or `port()` are subsequently implemented as non-integral types that must be bound to an owning `ErlNifEnv` instance.
Therefore, option (2) has been chosen to use `ErlNifPid`/`ErlNifPort` structures in the API to maintain proper term ownership semantics.
|
|
|
|
|
|
|
|
|
|
A more generic hashing function which can also hash terms based on
`make_internal_hash'.
|
|
|
|
|
|
These allow one to hash VM terms from NIF code.
|
|
with pipe capacity equal to PIPE_BUF
meaning pipe must be empty to be writable.
|
|
for now...
|
|
|
|
to provoke resource revival race.
|