Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Upgrade libuv to 2640aae

Add test for bug fixed in joyent/libuv@2640aae
  • Loading branch information...
ry committed Sep 15, 2011
1 parent 1b0a5cb commit 2d0b1ed7ad3f025630d55d79d4ca9b5218e49a69
@@ -504,11 +504,11 @@ static int _futime(const uv_file file, double atime, double mtime) {

int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
double mtime, uv_fs_cb cb) {
#if defined(HAVE_FUTIMES)
const char* path = NULL;

uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb);

#if defined(HAVE_FUTIMES)
WRAP_EIO(UV_FS_FUTIME, eio_futime, _futime, ARGS3(file, atime, mtime))
#else
uv_err_new(loop, ENOSYS);
@@ -179,16 +179,28 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
if (stdin_pipe[0] >= 0) {
uv__close(stdin_pipe[1]);
dup2(stdin_pipe[0], STDIN_FILENO);
} else {
/* Reset flags that might be set by Node */
uv__cloexec(STDIN_FILENO, 0);
uv__nonblock(STDIN_FILENO, 0);
}

if (stdout_pipe[1] >= 0) {
uv__close(stdout_pipe[0]);
dup2(stdout_pipe[1], STDOUT_FILENO);
} else {
/* Reset flags that might be set by Node */
uv__cloexec(STDOUT_FILENO, 0);
uv__nonblock(STDOUT_FILENO, 0);
}

if (stderr_pipe[1] >= 0) {
uv__close(stderr_pipe[0]);
dup2(stderr_pipe[1], STDERR_FILENO);
} else {
/* Reset flags that might be set by Node */
uv__cloexec(STDERR_FILENO, 0);
uv__nonblock(STDERR_FILENO, 0);
}

if (options.cwd && chdir(options.cwd)) {
@@ -97,6 +97,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
switch (sys_errno) {
case ERROR_SUCCESS: return UV_OK;
case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
case ERROR_PATH_NOT_FOUND: return UV_ENOENT;
case ERROR_NOACCESS: return UV_EACCESS;
case WSAEACCES: return UV_EACCESS;
case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
@@ -273,10 +273,12 @@ static void connection_cb(uv_stream_t* s, int status) {

if (type == TCP) {
stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
} else {
stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t));
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
}

r = uv_accept(s, stream);
@@ -272,7 +272,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle->state.prevbuf_pos = 0;
handle->state.prevbuf_rem = 0;

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

r = uv_accept(server, (uv_stream_t*)handle);
ASSERT(r == 0);
@@ -144,13 +144,15 @@ static void on_connection(uv_stream_t* server, int status) {
case TCP:
stream = malloc(sizeof(uv_tcp_t));
ASSERT(stream != NULL);
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
break;

case PIPE:
stream = malloc(sizeof(uv_pipe_t));
ASSERT(stream != NULL);
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
break;

default:
@@ -134,7 +134,10 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
TEST_IMPL(connection_fail_doesnt_auto_close) {
uv_timer_init(uv_default_loop(), &timer);
int r;

r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

connection_fail(on_connect_without_close);

@@ -57,7 +57,8 @@ static void do_accept(uv_timer_t* timer_handle, int status) {
ASSERT(status == 0);
ASSERT(accepted_handle != NULL);

uv_tcp_init(uv_default_loop(), accepted_handle);
r = uv_tcp_init(uv_default_loop(), accepted_handle);
ASSERT(r == 0);

/* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */
tcpcnt = uv_default_loop()->counters.tcp_init;
@@ -117,7 +117,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
ASSERT(handle != NULL);

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

/* associate server with stream */
handle->data = server;
@@ -43,7 +43,7 @@ typedef struct {
union {
uv_tcp_t tcp;
uv_pipe_t pipe;
};
} stream;
uv_connect_t connect_req;
char read_buffer[BUFSIZE];
} pinger_t;
@@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {

req = malloc(sizeof(uv_write_t));

if (uv_write(req, (uv_stream_t*)&pinger->tcp, &buf, 1, pinger_after_write)) {
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
FATAL("uv_write failed");
}

@@ -108,7 +108,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
free(buf.base);
}

uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);

return;
}
@@ -123,7 +123,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
if (pinger->pongs < NUM_PINGS) {
pinger_write_ping(pinger);
} else {
uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
return;
}
}
@@ -155,13 +155,13 @@ static void tcp_pinger_v6_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
pinger->tcp.data = pinger;
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
pinger->stream.tcp.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */
r = uv_tcp_connect6(&pinger->connect_req, &pinger->tcp, server_addr,
r = uv_tcp_connect6(&pinger->connect_req, &pinger->stream.tcp, server_addr,
pinger_on_connect);
ASSERT(!r);

@@ -180,13 +180,13 @@ static void tcp_pinger_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
pinger->tcp.data = pinger;
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
pinger->stream.tcp.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */
r = uv_tcp_connect(&pinger->connect_req, &pinger->tcp, server_addr,
r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, server_addr,
pinger_on_connect);
ASSERT(!r);

@@ -204,14 +204,14 @@ static void pipe_pinger_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_pipe_init(uv_default_loop(), &pinger->pipe);
pinger->pipe.data = pinger;
r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe);
pinger->stream.pipe.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */

r = uv_pipe_connect(&pinger->connect_req, &pinger->pipe, TEST_PIPENAME,
r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
pinger_on_connect);
ASSERT(!r);

@@ -156,7 +156,9 @@ TEST_IMPL(shutdown_eof) {
qbuf.base = "Q";
qbuf.len = 1;

uv_timer_init(uv_default_loop(), &timer);
r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

uv_timer_start(&timer, timer_cb, 100, 0);

server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
@@ -0,0 +1,40 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
var ch = require("child_process")

var SIZE = 100000
var childGone = false;

var cp = ch.spawn("python", ['-c', 'print ' + SIZE + ' * "C"'], {
customFds: [0, 1, 2]
});

cp.on("exit", function (code) {
childGone = true;
assert.equal(0, code);
});

process.on('exit', function() {
assert.ok(childGone);
});

0 comments on commit 2d0b1ed

Please sign in to comment.
You can’t perform that action at this time.