diff options
author | cjihrig <cjihrig@gmail.com> | 2018-01-19 15:33:43 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-01-23 20:34:39 -0500 |
commit | a083786c7733b5828102661a04a86884c934950a (patch) | |
tree | a45536a61b50e7b5fa68a77d6f594de730c4a346 /deps/uv/src/unix/netbsd.c | |
parent | 63f78f5ddc8ac50ea19839827682c51ff3363ac2 (diff) | |
download | android-node-v8-a083786c7733b5828102661a04a86884c934950a.tar.gz android-node-v8-a083786c7733b5828102661a04a86884c934950a.tar.bz2 android-node-v8-a083786c7733b5828102661a04a86884c934950a.zip |
deps: upgrade libuv to 1.19.1
PR-URL: https://github.com/nodejs/node/pull/18260
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/netbsd.c')
-rw-r--r-- | deps/uv/src/unix/netbsd.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c index d9066349c1..7425072331 100644 --- a/deps/uv/src/unix/netbsd.c +++ b/deps/uv/src/unix/netbsd.c @@ -40,9 +40,16 @@ #include <unistd.h> #include <time.h> +static uv_mutex_t process_title_mutex; +static uv_once_t process_title_mutex_once = UV_ONCE_INIT; static char *process_title; +static void init_process_title_mutex_once(void) { + uv_mutex_init(&process_title_mutex); +} + + int uv__platform_loop_init(uv_loop_t* loop) { return uv__kqueue_init(loop); } @@ -137,12 +144,21 @@ int uv_set_process_title(const char* title) { char* new_title; new_title = uv__strdup(title); - if (process_title == NULL) + + uv_once(&process_title_mutex_once, init_process_title_mutex_once); + uv_mutex_lock(&process_title_mutex); + + if (process_title == NULL) { + uv_mutex_unlock(&process_title_mutex); return -ENOMEM; + } + uv__free(process_title); process_title = new_title; setproctitle("%s", title); + uv_mutex_unlock(&process_title_mutex); + return 0; } @@ -153,17 +169,24 @@ int uv_get_process_title(char* buffer, size_t size) { if (buffer == NULL || size == 0) return -EINVAL; + uv_once(&process_title_mutex_once, init_process_title_mutex_once); + uv_mutex_lock(&process_title_mutex); + if (process_title) { len = strlen(process_title) + 1; - if (size < len) + if (size < len) { + uv_mutex_unlock(&process_title_mutex); return -ENOBUFS; + } memcpy(buffer, process_title, len); } else { len = 0; } + uv_mutex_unlock(&process_title_mutex); + buffer[len] = '\0'; return 0; |