Skip to content

Commit 21964fa

Browse files
committed
Upgrade libuv to b2ed24d
1 parent 8ace421 commit 21964fa

File tree

3 files changed

+3
-181
lines changed

3 files changed

+3
-181
lines changed

deps/uv/config-unix.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64
3232
ifeq (SunOS,$(uname_S))
3333
EV_CONFIG=config_sunos.h
3434
EIO_CONFIG=config_sunos.h
35-
CPPFLAGS += -Isrc/ares/config_sunos
35+
CPPFLAGS += -Isrc/ares/config_sunos -D__EXTENSIONS__
3636
LINKFLAGS+=-lsocket -lnsl
3737
UV_OS_FILE=uv-sunos.c
3838
endif

deps/uv/include/uv-unix.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ typedef struct {
8787
#define UV_PIPE_PRIVATE_TYPEDEF
8888
#define UV_PIPE_PRIVATE_FIELDS \
8989
UV_TCP_PRIVATE_FIELDS \
90-
const char* pipe_fname; /* strdup'ed */ \
91-
void* pipe_flock;
90+
const char* pipe_fname; /* strdup'ed */
9291

9392

9493
/* UV_PREPARE */ \

deps/uv/src/uv-unix.c

+1-178
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <unistd.h>
3636
#include <sys/types.h>
3737
#include <sys/stat.h>
38-
#include <sys/file.h>
3938
#include <fcntl.h>
4039
#include <sys/socket.h>
4140
#include <sys/un.h>
@@ -65,7 +64,6 @@
6564
extern char **environ;
6665
# endif
6766

68-
6967
static uv_err_t last_err;
7068

7169
struct uv_ares_data_s {
@@ -80,33 +78,6 @@ struct uv_ares_data_s {
8078

8179
static struct uv_ares_data_s ares_data;
8280

83-
typedef struct {
84-
const char* lockfile;
85-
int lockfd;
86-
} uv_flock_t;
87-
88-
89-
/* Create a new advisory file lock for `filename`.
90-
* Call `uv_flock_acquire()` to actually acquire the lock.
91-
*/
92-
int uv_flock_init(uv_flock_t* lock, const char* filename);
93-
94-
/* Try to acquire the file lock. Returns 0 on success, -1 on error.
95-
* Does not wait for the lock to be released if it is held by another process.
96-
*
97-
* If `locked` is not NULL, the memory pointed it points to is set to 1 if
98-
* the file is locked by another process. Only relevant in error scenarios.
99-
*/
100-
int uv_flock_acquire(uv_flock_t* lock, int* locked);
101-
102-
/* Release the file lock. Returns 0 on success, -1 on error.
103-
*/
104-
int uv_flock_release(uv_flock_t* lock);
105-
106-
/* Destroy the file lock. Releases the file lock and associated resources.
107-
*/
108-
int uv_flock_destroy(uv_flock_t* lock);
109-
11081
void uv__req_init(uv_req_t*);
11182
void uv__next(EV_P_ ev_idle* watcher, int revents);
11283
static int uv__stream_open(uv_stream_t*, int fd, int flags);
@@ -1838,7 +1809,6 @@ int uv_pipe_init(uv_pipe_t* handle) {
18381809
uv_counters()->pipe_init++;
18391810

18401811
handle->type = UV_NAMED_PIPE;
1841-
handle->pipe_flock = NULL; /* Only set by listener. */
18421812
handle->pipe_fname = NULL; /* Only set by listener. */
18431813

18441814
ev_init(&handle->write_watcher, uv__stream_io);
@@ -1858,7 +1828,6 @@ int uv_pipe_init(uv_pipe_t* handle) {
18581828
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
18591829
struct sockaddr_un sun;
18601830
const char* pipe_fname;
1861-
uv_flock_t* pipe_flock;
18621831
int saved_errno;
18631832
int locked;
18641833
int sockfd;
@@ -1867,7 +1836,6 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
18671836

18681837
saved_errno = errno;
18691838
pipe_fname = NULL;
1870-
pipe_flock = NULL;
18711839
sockfd = -1;
18721840
status = -1;
18731841
bound = 0;
@@ -1887,20 +1855,6 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
18871855
/* We've got a copy, don't touch the original any more. */
18881856
name = NULL;
18891857

1890-
/* Create and acquire a file lock for this UNIX socket. */
1891-
if ((pipe_flock = malloc(sizeof *pipe_flock)) == NULL
1892-
|| uv_flock_init(pipe_flock, pipe_fname) == -1) {
1893-
uv_err_new((uv_handle_t*)handle, ENOMEM);
1894-
goto out;
1895-
}
1896-
1897-
if (uv_flock_acquire(pipe_flock, &locked) == -1) {
1898-
/* Another process holds the lock so the socket is in use. */
1899-
uv_err_new_artificial((uv_handle_t*)handle,
1900-
locked ? UV_EADDRINUSE : UV_EACCESS);
1901-
goto out;
1902-
}
1903-
19041858
if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
19051859
uv_err_new((uv_handle_t*)handle, errno);
19061860
goto out;
@@ -1931,7 +1885,6 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
19311885

19321886
/* Success. */
19331887
handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */
1934-
handle->pipe_flock = pipe_flock;
19351888
handle->fd = sockfd;
19361889
status = 0;
19371890

@@ -1945,10 +1898,6 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
19451898
}
19461899
uv__close(sockfd);
19471900

1948-
if (pipe_flock) {
1949-
uv_flock_destroy(pipe_flock);
1950-
}
1951-
19521901
free((void*)pipe_fname);
19531902
}
19541903

@@ -2005,11 +1954,6 @@ static int uv_pipe_cleanup(uv_pipe_t* handle) {
20051954
free((void*)handle->pipe_fname);
20061955
}
20071956

2008-
if (handle->pipe_flock) {
2009-
uv_flock_destroy((uv_flock_t*)handle->pipe_flock);
2010-
free(handle->pipe_flock);
2011-
}
2012-
20131957
errno = saved_errno;
20141958
return status;
20151959
}
@@ -2236,6 +2180,7 @@ size_t uv__strlcpy(char* dst, const char* src, size_t size) {
22362180

22372181
uv_stream_t* uv_std_handle(uv_std_type type) {
22382182
assert(0 && "implement me");
2183+
return NULL;
22392184
}
22402185

22412186

@@ -2410,125 +2355,3 @@ int uv_process_kill(uv_process_t* process, int signum) {
24102355
return 0;
24112356
}
24122357
}
2413-
2414-
2415-
#define LOCKFILE_SUFFIX ".lock"
2416-
int uv_flock_init(uv_flock_t* lock, const char* filename) {
2417-
int saved_errno;
2418-
int status;
2419-
char* lockfile;
2420-
2421-
saved_errno = errno;
2422-
status = -1;
2423-
2424-
lock->lockfd = -1;
2425-
lock->lockfile = NULL;
2426-
2427-
if ((lockfile = malloc(strlen(filename) + sizeof LOCKFILE_SUFFIX)) == NULL) {
2428-
goto out;
2429-
}
2430-
2431-
strcpy(lockfile, filename);
2432-
strcat(lockfile, LOCKFILE_SUFFIX);
2433-
lock->lockfile = lockfile;
2434-
status = 0;
2435-
2436-
out:
2437-
errno = saved_errno;
2438-
return status;
2439-
}
2440-
#undef LOCKFILE_SUFFIX
2441-
2442-
2443-
int uv_flock_acquire(uv_flock_t* lock, int* locked_p) {
2444-
char buf[32];
2445-
int saved_errno;
2446-
int status;
2447-
int lockfd;
2448-
int locked;
2449-
2450-
saved_errno = errno;
2451-
status = -1;
2452-
lockfd = -1;
2453-
locked = 0;
2454-
2455-
do {
2456-
lockfd = open(lock->lockfile, O_WRONLY | O_CREAT, 0666);
2457-
}
2458-
while (lockfd == -1 && errno == EINTR);
2459-
2460-
if (lockfd == -1) {
2461-
goto out;
2462-
}
2463-
2464-
do {
2465-
status = flock(lockfd, LOCK_EX | LOCK_NB);
2466-
}
2467-
while (status == -1 && errno == EINTR);
2468-
2469-
if (status == -1) {
2470-
locked = (errno == EAGAIN); /* Lock is held by another process. */
2471-
goto out;
2472-
}
2473-
2474-
snprintf(buf, sizeof buf, "%d\n", getpid());
2475-
do {
2476-
status = write(lockfd, buf, strlen(buf));
2477-
}
2478-
while (status == -1 && errno == EINTR);
2479-
2480-
lock->lockfd = lockfd;
2481-
status = 0;
2482-
2483-
out:
2484-
if (status) {
2485-
uv__close(lockfd);
2486-
}
2487-
2488-
if (locked_p) {
2489-
*locked_p = locked;
2490-
}
2491-
2492-
errno = saved_errno;
2493-
return status;
2494-
}
2495-
2496-
2497-
int uv_flock_release(uv_flock_t* lock) {
2498-
int saved_errno;
2499-
int status;
2500-
2501-
saved_errno = errno;
2502-
status = -1;
2503-
2504-
if (unlink(lock->lockfile) == -1) {
2505-
/* Now what? */
2506-
goto out;
2507-
}
2508-
2509-
uv__close(lock->lockfd);
2510-
lock->lockfd = -1;
2511-
status = 0;
2512-
2513-
out:
2514-
errno = saved_errno;
2515-
return status;
2516-
}
2517-
2518-
2519-
int uv_flock_destroy(uv_flock_t* lock) {
2520-
int saved_errno;
2521-
int status;
2522-
2523-
saved_errno = errno;
2524-
status = unlink(lock->lockfile);
2525-
2526-
uv__close(lock->lockfd);
2527-
lock->lockfd = -1;
2528-
2529-
free((void*)lock->lockfile);
2530-
lock->lockfile = NULL;
2531-
2532-
errno = saved_errno;
2533-
return status;
2534-
}

0 commit comments

Comments
 (0)