HtPipe prevents the entire Elixir from terminating abnormaly by NIFs.
mix new abort_nif --supcd abort_nif- edit the following files.
mix.exslib/abort_nif/application.exlib/abort_nif.exMakefilelibnif.c
mix deps.getiex --name main_node --cookie cookie -S mix
AbortNif has push/1 and pop/0 functions:
iex(main_node@yourhost.local)1> AbortNif.pop()
:empty
iex(main_node@yourhost.local)2> AbortNif.push(1)
:ok
iex(main_node@yourhost.local)3> AbortNif.push(2)
:ok
iex(main_node@yourhost.local)4> AbortNif.pop()
2
iex(main_node@yourhost.local)5> AbortNif.pop()
1
iex(main_node@yourhost.local)6> AbortNif.pop()
:emptyAbortNif aborts by abort_soft/0 and restart soon by the supervisor.
The state will be empty by restarting:
iex(main_node@yourhost.local)1> AbortNif.push(1)
:ok
iex(main_node@yourhost.local)2> AbortNif.push(2)
:ok
iex(main_node@yourhost.local)3> AbortNif.abort_soft()
:ok
iex(main_node@yourhost.local)4> AbortNif.pop()
:emptyAbortNif aborts by abort_hard/0 by NIF and restart soon by the supervisor of HtPipe, with some error message from Logger.
The state will be empty by restarting
iex(main_node@yourhost.local)1> AbortNif.push(1)
:ok
iex(main_node@yourhost.local)2> AbortNif.push(2)
:ok
iex(main_node@yourhost.local)3> AbortNif.abort_hard()
:ok
iex(main_node@yourhost.local)4>
05:28:26.650 [error] Process #PID<20680.102.0> on node :"htp_worker_main_node@zackym2air01.local" raised an exception
** (UndefinedFunctionError) function HtPipe.worker/3 is undefined or private
(ht_pipe 0.1.0-dev) HtPipe.worker(#PID<0.220.0>, 5000, #Function<0.51034852/0 in AbortNif.handle_cast/2>)
05:28:31.759 [error] GenServer AbortNif terminating
** (stop) bad return value: nil
Last message: {:"$gen_cast", :abort_hard}
State: [2, 1]
AbortNif.pop
:empty