Commit 5f33d756 authored by Jason Madden's avatar Jason Madden

Merge branch 'master' of https://github.com/gevent/gevent

parents 56cfd118 f187fd05
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
``close_fds`` is false (not the default), making process spawning up ``close_fds`` is false (not the default), making process spawning up
to 38 times faster. Initially reported in :issue:`1172` by Ofer Koren. to 38 times faster. Initially reported in :issue:`1172` by Ofer Koren.
- The bundled libuv is now 1.20, up from 1.19.2. See :issue:`1177`. - The bundled libuv is now 1.20.1, up from 1.19.2. See :issue:`1177`.
- The long-deprecated and undocumented module ``gevent.wsgi`` was removed. - The long-deprecated and undocumented module ``gevent.wsgi`` was removed.
......
...@@ -332,3 +332,7 @@ Ryuichi KAWAMATA <ryuichi.kawamata@dena.jp> ...@@ -332,3 +332,7 @@ Ryuichi KAWAMATA <ryuichi.kawamata@dena.jp>
Joyee Cheung <joyeec9h3@gmail.com> Joyee Cheung <joyeec9h3@gmail.com>
Michael Kilburn <crusader.mike@gmail.com> Michael Kilburn <crusader.mike@gmail.com>
Ruslan Bekenev <furyinbox@gmail.com> Ruslan Bekenev <furyinbox@gmail.com>
Bob Burger <rgburger@beckman.com>
Thomas Versteeg <thomasversteeg@gmx.com>
zzzjim <zzzjim@users.noreply.github.com>
Alex Arslan <ararslan@comcast.net>
2018.04.03, Version 1.20.0 (Stable) 2018.04.19, Version 1.20.1 (Stable)
Changes since version 1.20.0:
* doc,fs: improve documentation (Bob Burger)
* win: return a floored double from uv_uptime() (Refael Ackermann)
* doc: clarify platform specific pipe naming (Thomas Versteeg)
* unix: fix uv_pipe_chmod() on macOS (zzzjim)
* unix: work around glibc semaphore race condition (Anna Henningsen)
* tcp,openbsd: disable Unix TCP check for IPV6_ONLY (Alex Arslan)
* test,openbsd: use RETURN_SKIP in UDP IPv6 tests (Alex Arslan)
* test,openbsd: fix multicast test (Alex Arslan)
* Revert "win, fs: use FILE_WRITE_ATTRIBUTES when opening files" (cjihrig)
2018.04.03, Version 1.20.0 (Stable), 0012178ee2b04d9e4a2c66c27cf8891ad8325ceb
Changes since version 1.19.2: Changes since version 1.19.2:
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([libuv], [1.20.0], [https://github.com/libuv/libuv/issues]) AC_INIT([libuv], [1.20.1], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4]) m4_include([m4/as_case.m4])
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define UV_VERSION_MAJOR 1 #define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 20 #define UV_VERSION_MINOR 20
#define UV_VERSION_PATCH 0 #define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX "" #define UV_VERSION_SUFFIX ""
......
...@@ -319,21 +319,6 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { ...@@ -319,21 +319,6 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
mode != (UV_WRITABLE | UV_READABLE)) mode != (UV_WRITABLE | UV_READABLE))
return UV_EINVAL; return UV_EINVAL;
if (fstat(uv__stream_fd(handle), &pipe_stat) == -1)
return UV__ERR(errno);
desired_mode = 0;
if (mode & UV_READABLE)
desired_mode |= S_IRUSR | S_IRGRP | S_IROTH;
if (mode & UV_WRITABLE)
desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
/* Exit early if pipe already has desired mode. */
if ((pipe_stat.st_mode & desired_mode) == desired_mode)
return 0;
pipe_stat.st_mode |= desired_mode;
/* Unfortunately fchmod does not work on all platforms, we will use chmod. */ /* Unfortunately fchmod does not work on all platforms, we will use chmod. */
name_len = 0; name_len = 0;
r = uv_pipe_getsockname(handle, NULL, &name_len); r = uv_pipe_getsockname(handle, NULL, &name_len);
...@@ -350,6 +335,26 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) { ...@@ -350,6 +335,26 @@ int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
return r; return r;
} }
/* stat must be used as fstat has a bug on Darwin */
if (stat(name_buffer, &pipe_stat) == -1) {
uv__free(name_buffer);
return -errno;
}
desired_mode = 0;
if (mode & UV_READABLE)
desired_mode |= S_IRUSR | S_IRGRP | S_IROTH;
if (mode & UV_WRITABLE)
desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
/* Exit early if pipe already has desired mode. */
if ((pipe_stat.st_mode & desired_mode) == desired_mode) {
uv__free(name_buffer);
return 0;
}
pipe_stat.st_mode |= desired_mode;
r = chmod(name_buffer, pipe_stat.st_mode); r = chmod(name_buffer, pipe_stat.st_mode);
uv__free(name_buffer); uv__free(name_buffer);
......
...@@ -164,6 +164,7 @@ int uv__tcp_bind(uv_tcp_t* tcp, ...@@ -164,6 +164,7 @@ int uv__tcp_bind(uv_tcp_t* tcp,
if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
return UV__ERR(errno); return UV__ERR(errno);
#ifndef __OpenBSD__
#ifdef IPV6_V6ONLY #ifdef IPV6_V6ONLY
if (addr->sa_family == AF_INET6) { if (addr->sa_family == AF_INET6) {
on = (flags & UV_TCP_IPV6ONLY) != 0; on = (flags & UV_TCP_IPV6ONLY) != 0;
...@@ -179,6 +180,7 @@ int uv__tcp_bind(uv_tcp_t* tcp, ...@@ -179,6 +180,7 @@ int uv__tcp_bind(uv_tcp_t* tcp,
return UV__ERR(errno); return UV__ERR(errno);
} }
} }
#endif
#endif #endif
errno = 0; errno = 0;
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include <sys/sem.h> #include <sys/sem.h>
#endif #endif
#ifdef __GLIBC__
#include <gnu/libc-version.h> /* gnu_get_libc_version() */
#endif
#undef NANOSEC #undef NANOSEC
#define NANOSEC ((uint64_t) 1e9) #define NANOSEC ((uint64_t) 1e9)
...@@ -502,26 +506,138 @@ int uv_sem_trywait(uv_sem_t* sem) { ...@@ -502,26 +506,138 @@ int uv_sem_trywait(uv_sem_t* sem) {
#else /* !(defined(__APPLE__) && defined(__MACH__)) */ #else /* !(defined(__APPLE__) && defined(__MACH__)) */
int uv_sem_init(uv_sem_t* sem, unsigned int value) { #ifdef __GLIBC__
/* Hack around https://sourceware.org/bugzilla/show_bug.cgi?id=12674
* by providing a custom implementation for glibc < 2.21 in terms of other
* concurrency primitives.
* Refs: https://github.com/nodejs/node/issues/19903 */
/* To preserve ABI compatibility, we treat the uv_sem_t as storage for
* a pointer to the actual struct we're using underneath. */
static uv_once_t glibc_version_check_once = UV_ONCE_INIT;
static int glibc_needs_custom_semaphore = 0;
static void glibc_version_check(void) {
const char* version = gnu_get_libc_version();
glibc_needs_custom_semaphore =
version[0] == '2' && version[1] == '.' &&
atoi(version + 2) < 21;
}
#else /* !defined(__GLIBC__) */
#define glibc_needs_custom_semaphore 0
#endif
typedef struct uv_semaphore_s {
uv_mutex_t mutex;
uv_cond_t cond;
unsigned int value;
} uv_semaphore_t;
STATIC_ASSERT(sizeof(uv_sem_t) >= sizeof(uv_semaphore_t*));
static int uv__custom_sem_init(uv_sem_t* sem_, unsigned int value) {
int err;
uv_semaphore_t* sem;
sem = uv__malloc(sizeof(*sem));
if (sem == NULL)
return UV_ENOMEM;
if ((err = uv_mutex_init(&sem->mutex)) != 0) {
uv__free(sem);
return err;
}
if ((err = uv_cond_init(&sem->cond)) != 0) {
uv_mutex_destroy(&sem->mutex);
uv__free(sem);
return err;
}
sem->value = value;
*(uv_semaphore_t**)sem_ = sem;
return 0;
}
static void uv__custom_sem_destroy(uv_sem_t* sem_) {
uv_semaphore_t* sem;
sem = *(uv_semaphore_t**)sem_;
uv_cond_destroy(&sem->cond);
uv_mutex_destroy(&sem->mutex);
uv__free(sem);
}
static void uv__custom_sem_post(uv_sem_t* sem_) {
uv_semaphore_t* sem;
sem = *(uv_semaphore_t**)sem_;
uv_mutex_lock(&sem->mutex);
sem->value++;
if (sem->value == 1)
uv_cond_signal(&sem->cond);
uv_mutex_unlock(&sem->mutex);
}
static void uv__custom_sem_wait(uv_sem_t* sem_) {
uv_semaphore_t* sem;
sem = *(uv_semaphore_t**)sem_;
uv_mutex_lock(&sem->mutex);
while (sem->value == 0)
uv_cond_wait(&sem->cond, &sem->mutex);
sem->value--;
uv_mutex_unlock(&sem->mutex);
}
static int uv__custom_sem_trywait(uv_sem_t* sem_) {
uv_semaphore_t* sem;
sem = *(uv_semaphore_t**)sem_;
if (uv_mutex_trylock(&sem->mutex) != 0)
return UV_EAGAIN;
if (sem->value == 0) {
uv_mutex_unlock(&sem->mutex);
return UV_EAGAIN;
}
sem->value--;
uv_mutex_unlock(&sem->mutex);
return 0;
}
static int uv__sem_init(uv_sem_t* sem, unsigned int value) {
if (sem_init(sem, 0, value)) if (sem_init(sem, 0, value))
return UV__ERR(errno); return UV__ERR(errno);
return 0; return 0;
} }
void uv_sem_destroy(uv_sem_t* sem) { static void uv__sem_destroy(uv_sem_t* sem) {
if (sem_destroy(sem)) if (sem_destroy(sem))
abort(); abort();
} }
void uv_sem_post(uv_sem_t* sem) { static void uv__sem_post(uv_sem_t* sem) {
if (sem_post(sem)) if (sem_post(sem))
abort(); abort();
} }
void uv_sem_wait(uv_sem_t* sem) { static void uv__sem_wait(uv_sem_t* sem) {
int r; int r;
do do
...@@ -533,7 +649,7 @@ void uv_sem_wait(uv_sem_t* sem) { ...@@ -533,7 +649,7 @@ void uv_sem_wait(uv_sem_t* sem) {
} }
int uv_sem_trywait(uv_sem_t* sem) { static int uv__sem_trywait(uv_sem_t* sem) {
int r; int r;
do do
...@@ -549,6 +665,49 @@ int uv_sem_trywait(uv_sem_t* sem) { ...@@ -549,6 +665,49 @@ int uv_sem_trywait(uv_sem_t* sem) {
return 0; return 0;
} }
int uv_sem_init(uv_sem_t* sem, unsigned int value) {
#ifdef __GLIBC__
uv_once(&glibc_version_check_once, glibc_version_check);
#endif
if (glibc_needs_custom_semaphore)
return uv__custom_sem_init(sem, value);
else
return uv__sem_init(sem, value);
}
void uv_sem_destroy(uv_sem_t* sem) {
if (glibc_needs_custom_semaphore)
uv__custom_sem_destroy(sem);
else
uv__sem_destroy(sem);
}
void uv_sem_post(uv_sem_t* sem) {
if (glibc_needs_custom_semaphore)
uv__custom_sem_post(sem);
else
uv__sem_post(sem);
}
void uv_sem_wait(uv_sem_t* sem) {
if (glibc_needs_custom_semaphore)
uv__custom_sem_wait(sem);
else
uv__sem_wait(sem);
}
int uv_sem_trywait(uv_sem_t* sem) {
if (glibc_needs_custom_semaphore)
return uv__custom_sem_trywait(sem);
else
return uv__sem_trywait(sem);
}
#endif /* defined(__APPLE__) && defined(__MACH__) */ #endif /* defined(__APPLE__) && defined(__MACH__) */
......
...@@ -434,8 +434,6 @@ void fs__open(uv_fs_t* req) { ...@@ -434,8 +434,6 @@ void fs__open(uv_fs_t* req) {
access |= FILE_APPEND_DATA; access |= FILE_APPEND_DATA;
} }
access |= FILE_WRITE_ATTRIBUTES;
/* /*
* Here is where we deviate significantly from what CRT's _open() * Here is where we deviate significantly from what CRT's _open()
* does. We indiscriminately use all the sharing modes, to match * does. We indiscriminately use all the sharing modes, to match
......
...@@ -587,8 +587,8 @@ int uv_uptime(double* uptime) { ...@@ -587,8 +587,8 @@ int uv_uptime(double* uptime) {
BYTE* address = (BYTE*) object_type + object_type->DefinitionLength + BYTE* address = (BYTE*) object_type + object_type->DefinitionLength +
counter_definition->CounterOffset; counter_definition->CounterOffset;
uint64_t value = *((uint64_t*) address); uint64_t value = *((uint64_t*) address);
*uptime = (double) (object_type->PerfTime.QuadPart - value) / *uptime = floor((double) (object_type->PerfTime.QuadPart - value) /
(double) object_type->PerfFreq.QuadPart; (double) object_type->PerfFreq.QuadPart);
uv__free(malloced_buffer); uv__free(malloced_buffer);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment