diff options
author | Zhidao HONG <z.hong@f5.com> | 2023-01-30 11:16:01 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2023-01-30 11:16:01 +0800 |
commit | 789762ff3d88a1c006babc7a8e7037e0976ad70f (patch) | |
tree | 4988386a1644bbbe9f8f3c98c29430fdd71f74d9 /src/nxt_js.c | |
parent | cbc01907fef6a028f02d9051b909def920c49f24 (diff) | |
download | unit-789762ff3d88a1c006babc7a8e7037e0976ad70f.tar.gz unit-789762ff3d88a1c006babc7a8e7037e0976ad70f.tar.bz2 |
NJS: adding the missing vm destruction.
This commit fixed the njs memory leak happened in the config validation, updating and http requests.
Diffstat (limited to 'src/nxt_js.c')
-rw-r--r-- | src/nxt_js.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nxt_js.c b/src/nxt_js.c index aa3c4af5..4327e848 100644 --- a/src/nxt_js.c +++ b/src/nxt_js.c @@ -46,6 +46,7 @@ nxt_js_conf_new(nxt_mp_t *mp) jcf->funcs = nxt_array_create(mp, 4, sizeof(nxt_str_t)); if (nxt_slow_path(jcf->funcs == NULL)) { + njs_vm_destroy(jcf->vm); return NULL; } @@ -54,6 +55,13 @@ nxt_js_conf_new(nxt_mp_t *mp) void +nxt_js_conf_release(nxt_js_conf_t *jcf) +{ + njs_vm_destroy(jcf->vm); +} + + +void nxt_js_set_proto(nxt_js_conf_t *jcf, njs_external_t *proto, njs_uint_t n) { jcf->protos = n; @@ -297,3 +305,12 @@ nxt_js_call(nxt_task_t *task, nxt_js_cache_t *cache, nxt_js_t *js, return NXT_OK; } + + +void +nxt_js_release(nxt_js_cache_t *cache) +{ + if (cache->vm != NULL) { + njs_vm_destroy(cache->vm); + } +} |