diff options
author | cjihrig <cjihrig@gmail.com> | 2017-10-02 19:44:44 -0400 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-10-05 12:08:33 -0700 |
commit | fca6c5839a6154275913656dfedb3242959031e3 (patch) | |
tree | e1fed70c4929b71306e6a18a92bf5501245a286c /deps/uv/src/unix/os390-syscalls.c | |
parent | b9a55a93c91fb7fd7ac81e182f843f28014179ca (diff) | |
download | android-node-v8-fca6c5839a6154275913656dfedb3242959031e3.tar.gz android-node-v8-fca6c5839a6154275913656dfedb3242959031e3.tar.bz2 android-node-v8-fca6c5839a6154275913656dfedb3242959031e3.zip |
deps: upgrade libuv to 1.15.0
PR-URL: https://github.com/nodejs/node/pull/15745
Refs: https://github.com/nodejs/node/pull/15380
Refs: https://github.com/nodejs/node/issues/15683
Fixes: https://github.com/nodejs/node/issues/15394
Fixes: https://github.com/nodejs/node/issues/15770
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/os390-syscalls.c')
-rw-r--r-- | deps/uv/src/unix/os390-syscalls.c | 93 |
1 files changed, 84 insertions, 9 deletions
diff --git a/deps/uv/src/unix/os390-syscalls.c b/deps/uv/src/unix/os390-syscalls.c index 08623f4eaf..ca539c26f7 100644 --- a/deps/uv/src/unix/os390-syscalls.c +++ b/deps/uv/src/unix/os390-syscalls.c @@ -130,17 +130,17 @@ static void epoll_init(void) { uv__os390_epoll* epoll_create1(int flags) { uv__os390_epoll* lst; - uv_once(&once, epoll_init); - uv_mutex_lock(&global_epoll_lock); lst = uv__malloc(sizeof(*lst)); - if (lst == -1) - return NULL; - QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); - uv_mutex_unlock(&global_epoll_lock); + if (lst != NULL) { + /* initialize list */ + lst->size = 0; + lst->items = NULL; + uv_once(&once, epoll_init); + uv_mutex_lock(&global_epoll_lock); + QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member); + uv_mutex_unlock(&global_epoll_lock); + } - /* initialize list */ - lst->size = 0; - lst->items = NULL; return lst; } @@ -149,8 +149,11 @@ int epoll_ctl(uv__os390_epoll* lst, int op, int fd, struct epoll_event *event) { + uv_mutex_lock(&global_epoll_lock); + if(op == EPOLL_CTL_DEL) { if (fd >= lst->size || lst->items[fd].fd == -1) { + uv_mutex_unlock(&global_epoll_lock); errno = ENOENT; return -1; } @@ -158,6 +161,7 @@ int epoll_ctl(uv__os390_epoll* lst, } else if(op == EPOLL_CTL_ADD) { maybe_resize(lst, fd + 1); if (lst->items[fd].fd != -1) { + uv_mutex_unlock(&global_epoll_lock); errno = EEXIST; return -1; } @@ -165,6 +169,7 @@ int epoll_ctl(uv__os390_epoll* lst, lst->items[fd].events = event->events; } else if(op == EPOLL_CTL_MOD) { if (fd >= lst->size || lst->items[fd].fd == -1) { + uv_mutex_unlock(&global_epoll_lock); errno = ENOENT; return -1; } @@ -172,6 +177,7 @@ int epoll_ctl(uv__os390_epoll* lst, } else abort(); + uv_mutex_unlock(&global_epoll_lock); return 0; } @@ -321,3 +327,72 @@ char* mkdtemp(char* path) { return path; } + + +ssize_t os390_readlink(const char* path, char* buf, size_t len) { + ssize_t rlen; + ssize_t vlen; + ssize_t plen; + char* delimiter; + char old_delim; + char* tmpbuf; + char realpathstr[PATH_MAX + 1]; + + tmpbuf = uv__malloc(len + 1); + if (tmpbuf == NULL) { + errno = ENOMEM; + return -1; + } + + rlen = readlink(path, tmpbuf, len); + if (rlen < 0) { + uv__free(tmpbuf); + return rlen; + } + + if (rlen < 3 || strncmp("/$", tmpbuf, 2) != 0) { + /* Straightforward readlink. */ + memcpy(buf, tmpbuf, rlen); + uv__free(tmpbuf); + return rlen; + } + + /* + * There is a parmlib variable at the beginning + * which needs interpretation. + */ + tmpbuf[rlen] = '\0'; + delimiter = strchr(tmpbuf + 2, '/'); + if (delimiter == NULL) + /* No slash at the end */ + delimiter = strchr(tmpbuf + 2, '\0'); + + /* Read real path of the variable. */ + old_delim = *delimiter; + *delimiter = '\0'; + if (realpath(tmpbuf, realpathstr) == NULL) { + uv__free(tmpbuf); + return -1; + } + + /* realpathstr is not guaranteed to end with null byte.*/ + realpathstr[PATH_MAX] = '\0'; + + /* Reset the delimiter and fill up the buffer. */ + *delimiter = old_delim; + plen = strlen(delimiter); + vlen = strlen(realpathstr); + rlen = plen + vlen; + if (rlen > len) { + uv__free(tmpbuf); + errno = ENAMETOOLONG; + return -1; + } + memcpy(buf, realpathstr, vlen); + memcpy(buf + vlen, delimiter, plen); + + /* Done using temporary buffer. */ + uv__free(tmpbuf); + + return rlen; +} |