diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-12-05 17:24:49 -0800 |
---|---|---|
committer | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-12-19 18:35:38 -0800 |
commit | 13abc6adfb9f6a53618ca7d533d31b6a5d26dcec (patch) | |
tree | c926fad94aa23bf3bec5af81b975efa0771338da /src/node_binding.h | |
parent | 622e348d8f70a4ec006ee1ce9207a6a5bc3fc325 (diff) | |
download | android-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.tar.gz android-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.tar.bz2 android-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.zip |
src: unload addons when environment quits
This is an alternative to https://github.com/nodejs/node/pull/23319
which attaches the loaded addons to the environment and closes them
when the environment is destroyed.
PR-URL: https://github.com/nodejs/node/pull/24861
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_binding.h')
-rw-r--r-- | src/node_binding.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/node_binding.h b/src/node_binding.h index 743c82accd..7d79dae80d 100644 --- a/src/node_binding.h +++ b/src/node_binding.h @@ -3,8 +3,14 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +#if defined(__POSIX__) +#include <dlfcn.h> +#endif + #include "node.h" +#define NAPI_EXPERIMENTAL #include "node_api.h" +#include "util.h" #include "uv.h" #include "v8.h" @@ -46,6 +52,32 @@ extern bool node_is_initialized; namespace binding { +class DLib { + public: +#ifdef __POSIX__ + static const int kDefaultFlags = RTLD_LAZY; +#else + static const int kDefaultFlags = 0; +#endif + + DLib(const char* filename, int flags); + + bool Open(); + void Close(); + void* GetSymbolAddress(const char* name); + + const std::string filename_; + const int flags_; + std::string errmsg_; + void* handle_; +#ifndef __POSIX__ + uv_lib_t lib_; +#endif + + private: + DISALLOW_COPY_AND_ASSIGN(DLib); +}; + // Call _register<module_name> functions for all of // the built-in modules. Because built-in modules don't // use the __attribute__((constructor)). Need to @@ -60,5 +92,7 @@ void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args); } // namespace node +#include "node_binding.h" + #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_NODE_BINDING_H_ |