Are NIF resources meant to be destroyed immediately on GC?
Stanislaw Klekot
erlang.org@REDACTED
Wed Nov 25 18:20:27 CET 2020
On Wed, Nov 25, 2020 at 11:35:43AM +0100, Sean Hinde wrote:
> I agree. My use case for this was building a nif for the oracle oci bindings.
>
> In the happy path users should call the provided db_close function which would flush outstanding transactions and close everything down in the dirty nif.
>
> The problematic case is where the user's process holding the connection crashes. In that case we need the finaliser as the "secondary" resource reclamation path. If that path cannot safely close the db handle for fear of screwing up the emulator it's a problem.
>
> The solution today is to have an interim process to fault isolate the nif holding process from the user process. Which adds overhead.
Uhm... But this is exactly what ports are supposed to handle and it's
exactly how they work. Why shoehorning NIFs here?
--
Stanislaw Klekot
More information about the erlang-questions
mailing list