Skip to content

Commit dd4b280

Browse files
author
Igor Zinkovsky
committed
upgrade libuv to 60630dab0f
1 parent ae648a4 commit dd4b280

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

deps/uv/include/uv-private/uv-win.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
276276
LPFN_WSARECVFROM func_wsarecvfrom;
277277

278278
#define uv_pipe_server_fields \
279-
uv_pipe_accept_t accept_reqs[4]; \
279+
int pending_instances; \
280+
uv_pipe_accept_t* accept_reqs; \
280281
uv_pipe_accept_t* pending_accepts;
281282

282283
#define uv_pipe_connection_fields \

deps/uv/include/uv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,13 @@ UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
772772
UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
773773
const char* name, uv_connect_cb cb);
774774

775+
/*
776+
* This setting applies to Windows only.
777+
* Set the number of pending pipe instance handles when the pipe server
778+
* is waiting for connections.
779+
*/
780+
UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
781+
775782

776783
/*
777784
* uv_prepare_t is a subclass of uv_handle_t.

deps/uv/src/unix/pipe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,8 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents) {
271271

272272
errno = saved_errno;
273273
}
274+
275+
276+
void uv_pipe_pending_instances(uv_pipe_t* handle, int count) {
277+
return 0;
278+
}

deps/uv/src/win/pipe.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static const uv_buf_t uv_null_buf_ = { 0, NULL };
3939
/* when the local ends wants to shut it down. */
4040
static const int64_t eof_timeout = 50; /* ms */
4141

42+
static const int default_pending_pipe_instances = 4;
43+
4244
/* IPC protocol flags. */
4345
#define UV_IPC_RAW_DATA 0x0001
4446
#define UV_IPC_UV_STREAM 0x0002
@@ -293,6 +295,12 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
293295
}
294296
}
295297

298+
if (handle->flags & UV_HANDLE_PIPESERVER) {
299+
assert(handle->accept_reqs);
300+
free(handle->accept_reqs);
301+
handle->accept_reqs = NULL;
302+
}
303+
296304
/* Remember the state of this flag because the close callback is */
297305
/* allowed to clobber or free the handle's memory */
298306
uv_alloced = handle->flags & UV_HANDLE_UV_ALLOCED;
@@ -310,6 +318,12 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
310318
}
311319

312320

321+
void uv_pipe_pending_instances(uv_pipe_t* handle, int count) {
322+
handle->pending_instances = count;
323+
handle->flags |= UV_HANDLE_PIPESERVER;
324+
}
325+
326+
313327
/* Creates a pipe server. */
314328
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
315329
uv_loop_t* loop = handle->loop;
@@ -326,7 +340,17 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
326340
return -1;
327341
}
328342

329-
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) {
343+
if (!(handle->flags & UV_HANDLE_PIPESERVER)) {
344+
handle->pending_instances = default_pending_pipe_instances;
345+
}
346+
347+
handle->accept_reqs = (uv_pipe_accept_t*)
348+
malloc(sizeof(uv_pipe_accept_t) * handle->pending_instances);
349+
if (!handle->accept_reqs) {
350+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
351+
}
352+
353+
for (i = 0; i < handle->pending_instances; i++) {
330354
req = &handle->accept_reqs[i];
331355
uv_req_init(loop, (uv_req_t*) req);
332356
req->type = UV_ACCEPT;
@@ -537,14 +561,13 @@ void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) {
537561
}
538562

539563
if (handle->flags & UV_HANDLE_PIPESERVER) {
540-
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) {
564+
for (i = 0; i < handle->pending_instances; i++) {
541565
pipeHandle = handle->accept_reqs[i].pipeHandle;
542566
if (pipeHandle != INVALID_HANDLE_VALUE) {
543567
CloseHandle(pipeHandle);
544568
handle->accept_reqs[i].pipeHandle = INVALID_HANDLE_VALUE;
545569
}
546570
}
547-
548571
}
549572

550573
if (handle->flags & UV_HANDLE_CONNECTION) {
@@ -686,7 +709,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
686709
/* First pipe handle should have already been created in uv_pipe_bind */
687710
assert(handle->accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE);
688711

689-
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) {
712+
for (i = 0; i < handle->pending_instances; i++) {
690713
uv_pipe_queue_accept(loop, handle, &handle->accept_reqs[i], i == 0);
691714
}
692715

0 commit comments

Comments
 (0)