UV_EXTERN uv_loop_t* uv_default_loop(void);
/*
- * This function starts the event loop. It blocks until the reference count
- * of the loop drops to zero. Always returns zero.
- */
-UV_EXTERN int uv_run(uv_loop_t*);
-
-/*
* This function runs the event loop. It will act differently depending on the
* specified mode:
* - UV_RUN_DEFAULT: Runs the event loop until the reference count drops to
* - UV_RUN_NOWAIT: Poll for new events once but don't block if there are no
* pending events.
*/
-UV_EXTERN int uv_run2(uv_loop_t*, uv_run_mode mode);
+UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
/*
* Manually modify the event loop's reference count. Useful if the user wants
}
-int uv_run2(uv_loop_t* loop, uv_run_mode mode) {
+int uv_run(uv_loop_t* loop, uv_run_mode mode) {
int r;
if (!uv__loop_alive(loop))
}
-int uv_run(uv_loop_t* loop) {
- return uv_run2(loop, UV_RUN_DEFAULT);
-}
-
-
void uv_update_time(uv_loop_t* loop) {
uv__update_time(loop);
}
while (nread < 0 && errno == EINTR);
}
+#define INVOKE_READ_CB(stream, status, buf, type) \
+ do { \
+ if ((stream)->read_cb != NULL) \
+ (stream)->read_cb((stream), (status), (buf)); \
+ else \
+ (stream)->read2_cb((uv_pipe_t*) (stream), (status), (buf), (type)); \
+ } \
+ while (0)
if (nread < 0) {
/* Error */
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN);
}
uv__set_sys_error(stream->loop, EAGAIN);
-
- if (stream->read_cb) {
- stream->read_cb(stream, 0, buf);
- } else {
- stream->read2_cb((uv_pipe_t*)stream, 0, buf, UV_UNKNOWN_HANDLE);
- }
-
- return;
+ INVOKE_READ_CB(stream, 0, buf, UV_UNKNOWN_HANDLE);
} else {
/* Error. User should call uv_close(). */
uv__set_sys_error(stream->loop, errno);
-
- if (stream->read_cb) {
- stream->read_cb(stream, -1, buf);
- } else {
- stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
- }
-
- assert(!uv__io_active(&stream->io_watcher, UV__POLLIN));
- return;
+ INVOKE_READ_CB(stream, -1, buf, UV_UNKNOWN_HANDLE);
+ assert(!uv__io_active(&stream->io_watcher, UV__POLLIN) &&
+ "stream->read_cb(status=-1) did not call uv_close()");
}
-
+ return;
} else if (nread == 0) {
/* EOF */
- uv__set_artificial_error(stream->loop, UV_EOF);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
-
if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
uv__handle_stop(stream);
-
- if (stream->read_cb) {
- stream->read_cb(stream, -1, buf);
- } else {
- stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
- }
+ uv__set_artificial_error(stream->loop, UV_EOF);
+ INVOKE_READ_CB(stream, -1, buf, UV_UNKNOWN_HANDLE);
return;
} else {
/* Successful read */
!ngx_queue_empty(&(loop)->active_reqs) || \
(loop)->endgame_handles != NULL)
-int uv_run2(uv_loop_t *loop, uv_run_mode mode) {
+int uv_run(uv_loop_t *loop, uv_run_mode mode) {
int r;
void (*poll)(uv_loop_t* loop, int block);
}
return r;
}
-
-
-int uv_run(uv_loop_t* loop) {
- return uv_run2(loop, UV_RUN_DEFAULT);
-}
time = uv_hrtime();
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
time = uv_hrtime() - time;
done = 1;
static void worker(void* arg) {
struct ctx* ctx = arg;
ASSERT(0 == uv_async_send(&ctx->main_async));
- ASSERT(0 == uv_run(ctx->loop));
+ ASSERT(0 == uv_run(ctx->loop, UV_RUN_DEFAULT));
}
time = uv_hrtime();
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
for (i = 0; i < nthreads; i++)
ASSERT(0 == uv_thread_join(&threads[i].thread));
for (i = 0; i < ARRAY_SIZE(reqs); i++)
uv_fs_stat(uv_default_loop(), reqs + i, path, uv_fs_req_cleanup);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
/* warm up the OS dirent cache */
for (i = 0; i < 16; i++)
}
before = uv_hrtime();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
after = uv_hrtime();
printf("%s stats (%d concurrent): %.2fs (%s/s)\n",
getaddrinfo_initiate(&handles[i]);
}
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
uv_update_time(loop);
end_time = uv_now(loop);
uv_idle_start(&idle_handle, idle_cb);
ns = uv_hrtime();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ns = uv_hrtime() - ns;
ASSERT(ticks == NUM_TICKS);
uv_timer_init(loop, &timer_handle);
uv_timer_start(&timer_handle, timer_cb, 5000, 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
LOGF("loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0);
ASSERT(0 == uv_timer_init(loop, &timer_handle));
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, timeout, 0));
ASSERT(0 == uv_thread_create(&thread_id, thread_cb, NULL));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
printf("%s async events in %.1f seconds (%s/s, %s unique handles seen)\n",
fmt(container->async_events),
timeout / 1000.,
}
before = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
after = uv_hrtime();
for (i = 0; i < NUM_TIMERS; i++)
uv_close((uv_handle_t*) (timers + i), close_cb);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(timer_cb_called == NUM_TIMERS);
ASSERT(close_cb_called == NUM_TIMERS);
free(timers);
for (i = 0; i < num_servers; i++)
uv_sem_post(&servers[i].semaphore);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
uv_close((uv_handle_t*) &ctx.server_handle, NULL);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
for (i = 0; i < num_servers; i++)
uv_sem_wait(&servers[i].semaphore);
&ctx.ipc_pipe,
IPC_PIPE_NAME,
ipc_connect_cb);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
}
ASSERT(0 == uv_listen((uv_stream_t*) &ctx->server_handle,
128,
sv_connection_cb));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
uv_loop_delete(loop);
}
{
uint64_t t = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
t = uv_hrtime() - t;
time = t / 1e9;
}
start_time = uv_now(loop);
pinger_new();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(completed_pingers == 1);
r = do_connect(concurrency, make_connect, arg);
ASSERT(!r);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
end_time = uv_hrtime();
r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
r = uv_listen((uv_stream_t*)&pipeServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
return 0;
/* Start making connections */
maybe_connect_some();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
}
/* Start making connections */
maybe_connect_some();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
}
spawn();
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
uv_update_time(loop);
start = uv_hrtime();
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
stop = uv_hrtime();
}
duration = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
duration = uv_hrtime() - duration;
/* convert from nanoseconds to milliseconds */
duration = duration / (uint64_t) 1e6;
r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb);
ASSERT(r == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(0 && "Blackhole server dropped out of event loop.");
return 0;
if (dns_start(TEST_PORT_2))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
if (tcp4_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
if (tcp6_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
if (pipe_echo_start(TEST_PIPENAME))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
if (udp4_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
ASSERT(!uv_is_active((uv_handle_t*) &timer));
ASSERT(uv_is_closing((uv_handle_t*) &timer));
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(close_cb_called == 1);
r = uv_async_init(uv_default_loop(), &async, async_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(prepare_cb_called > 0);
ASSERT(idle_cb_called == 0);
ASSERT(timer_cb_called == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(idle_cb_called == 1);
ASSERT(timer_cb_called == 1);
}
nested--;
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(nested == 0);
ASSERT(connect_cb_called == 1 && "connect_cb must be called exactly once");
r = uv_tcp_connect(&req, &tcp, server_addr, connect_cb);
ASSERT(!r);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_calls == 1);
ASSERT(close_cb_calls == 1);
client_connect();
client_connect();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connection_cb_called == 2);
ASSERT(do_accept_called == 2);
static void embed_cb(uv_async_t* async, int status) {
- uv_run2(uv_default_loop(), UV_RUN_ONCE);
+ uv_run(uv_default_loop(), UV_RUN_ONCE);
uv_sem_post(&embed_sem);
}
uv_thread_create(&embed_thread, embed_thread_runner, NULL);
/* But run external loop */
- uv_run(external);
+ uv_run(external, UV_RUN_DEFAULT);
uv_thread_join(&embed_thread);
uv_loop_delete(external);
r = uv_timer_start(&timer, timer_cb_dir, 100, 0);
ASSERT(r != -1);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fs_event_cb_called == 1);
ASSERT(timer_cb_called == 1);
r = uv_timer_start(&timer, timer_cb_file, 100, 100);
ASSERT(r != -1);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fs_event_cb_called == 1);
ASSERT(timer_cb_called == 2);
ASSERT(0 == uv_fs_event_init(loop, watchers + 1, path, fail_cb, 0));
ASSERT(0 == uv_timer_init(loop, &timer));
ASSERT(0 == uv_timer_start(&timer, timer_cb_watch_twice, 10, 0));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
MAKE_VALGRIND_HAPPY();
return 0;
ASSERT(fs_event_cb_called == 0);
ASSERT(close_cb_called == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(timer_cb_touch_called == 1);
ASSERT(fs_event_cb_called == 1);
uv_close((uv_handle_t*)&fs_event, close_cb);
touch_file(loop, "watch_dir/file1");
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fs_event_cb_called == 0);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&fs_event, close_cb);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fs_event_cb_called == 0);
ASSERT(close_cb_called == 1);
r = uv_timer_start(&timer, timer_cb, 1, 0);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(close_cb_called == 2);
uv_close((uv_handle_t*)&fs_event, close_cb);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
touch_file(loop, "watch_dir/file4");
touch_file(loop, "watch_dir/file5");
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
ASSERT(fs_event_cb_called == 3);
ASSERT(0 == uv_timer_init(loop, &timer_handle));
ASSERT(0 == uv_fs_poll_init(loop, &poll_handle));
ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb, FIXTURE, 100));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(poll_cb_called == 5);
ASSERT(timer_cb_called == 2);
ASSERT(r == 0);
ASSERT(open_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 1);
/* TODO add EACCES test */
ASSERT(r == 0);
ASSERT(open_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 1);
MAKE_VALGRIND_HAPPY();
ASSERT(r == 0);
ASSERT(open_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 1);
unlink("test_symlink");
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
S_IREAD | S_IWRITE, create_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(create_cb_count == 1);
ASSERT(write_cb_count == 1);
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", rename_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(create_cb_count == 1);
ASSERT(write_cb_count == 1);
ASSERT(close_cb_count == 1);
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDWR, 0, open_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 1);
ASSERT(read_cb_count == 1);
ASSERT(close_cb_count == 2);
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, open_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 2);
ASSERT(read_cb_count == 2);
ASSERT(close_cb_count == 3);
r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(mkdir_cb_count == 1);
/* Create 2 files synchronously. */
r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, readdir_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(readdir_cb_count == 1);
/* sync uv_fs_readdir */
r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(stat_cb_count == 4);
r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(unlink_cb_count == 1);
r = uv_fs_unlink(loop, &unlink_req, "test_dir/file2", unlink_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(unlink_cb_count == 2);
r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(rmdir_cb_count == 1);
/* Cleanup */
r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result,
0, 131072, sendfile_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(sendfile_cb_count == 1);
/* Now do the uv_fs_fstat call asynchronously */
r = uv_fs_fstat(loop, &req, file, fstat_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fstat_cb_count == 1);
* Run the loop just to check we don't have make any extraneous uv_ref()
* calls. This should drop out immediately.
*/
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
/* Cleanup. */
unlink("test_file");
}
r = uv_fs_chmod(loop, &req, "test_file", 0200, chmod_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chmod_cb_count == 1);
chmod_cb_count = 0; /* reset for the next test */
#endif
}
r = uv_fs_chmod(loop, &req, "test_file", 0400, chmod_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chmod_cb_count == 1);
/* async fchmod */
}
r = uv_fs_fchmod(loop, &req, file, 0600, fchmod_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fchmod_cb_count == 1);
close(file);
* Run the loop just to check we don't have make any extraneous uv_ref()
* calls. This should drop out immediately.
*/
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
/* Cleanup. */
unlink("test_file");
/* async chown */
r = uv_fs_chown(loop, &req, "test_file", -1, -1, chown_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chown_cb_count == 1);
/* chown to root (fail) */
chown_cb_count = 0;
r = uv_fs_chown(loop, &req, "test_file", 0, 0, chown_root_cb);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chown_cb_count == 1);
/* async fchown */
r = uv_fs_fchown(loop, &req, file, -1, -1, fchown_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(fchown_cb_count == 1);
close(file);
* Run the loop just to check we don't have make any extraneous uv_ref()
* calls. This should drop out immediately.
*/
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
/* Cleanup. */
unlink("test_file");
/* async link */
r = uv_fs_link(loop, &req, "test_file", "test_file_link2", link_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(link_cb_count == 1);
r = uv_fs_open(loop, &req, "test_file_link2", O_RDWR, 0, NULL);
* Run the loop just to check we don't have make any extraneous uv_ref()
* calls. This should drop out immediately.
*/
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
/* Cleanup. */
unlink("test_file");
loop = uv_default_loop();
ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(dummy_cb_count == 1);
ASSERT(req.ptr == NULL);
ASSERT(req.result == -1);
/* async link */
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink2", 0, symlink_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(symlink_cb_count == 1);
r = uv_fs_open(loop, &req, "test_file_symlink2", O_RDWR, 0, NULL);
r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb);
ASSERT(r != -1);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(readlink_cb_count == 1);
/*
* Run the loop just to check we don't have make any extraneous uv_ref()
* calls. This should drop out immediately.
*/
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
/* Cleanup. */
unlink("test_file");
utime_req.data = &checkme;
r = uv_fs_utime(loop, &utime_req, path, atime, mtime, utime_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(utime_cb_count == 1);
/* Cleanup. */
futime_req.data = &checkme;
r = uv_fs_futime(loop, &futime_req, file, atime, mtime, futime_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(futime_cb_count == 1);
/* Cleanup. */
ASSERT(r == 0);
ASSERT(readdir_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(readdir_cb_count == 1);
uv_fs_rmdir(loop, &req, path, NULL);
ASSERT(r == 0);
ASSERT(readdir_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(readdir_cb_count == 1);
MAKE_VALGRIND_HAPPY();
ASSERT(r == 0);
ASSERT(open_cb_count == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(open_cb_count == 1);
MAKE_VALGRIND_HAPPY();
NULL);
ASSERT(r == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(getaddrinfo_cbs == 1);
ASSERT(r == 0);
}
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
for (i = 0; i < CONCURRENT_COUNT; i++) {
ASSERT(callback_counts[i] == 1);
tcp_connector();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(getsocknamecount == 3);
ASSERT(getpeernamecount == 3);
udp_sender();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(getsocknamecount == 2);
r = uv_timer_start(&timer_handle, timer_cb, 50, 0);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(idle_cb_called > 0);
r = uv_read2_start((uv_stream_t*)&ctx.channel, alloc_cb, recv_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(num_recv_handles == 1);
r = uv_read2_start((uv_stream_t*)&ctx.channel, alloc_cb, read2_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
spawn_helper(&channel, &process, helper);
uv_read2_start((uv_stream_t*)&channel, on_alloc, read_cb);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
ASSERT(r == 0);
}
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(connection_accepted == 1);
r = uv_tcp_connect(&conn.conn_req, (uv_tcp_t*)&conn.conn, addr, connect_child_process_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(tcp_conn_read_cb_called == 1);
TEST_DECLARE (tcp_close_while_connecting)
TEST_DECLARE (tcp_close)
TEST_DECLARE (tcp_flags)
-TEST_DECLARE (tcp_write_error)
TEST_DECLARE (tcp_write_to_half_open_connection)
TEST_DECLARE (tcp_unexpected_read)
TEST_DECLARE (tcp_read_stop)
TEST_ENTRY (tcp_close_while_connecting)
TEST_ENTRY (tcp_close)
TEST_ENTRY (tcp_flags)
- TEST_ENTRY (tcp_write_error)
TEST_ENTRY (tcp_write_to_half_open_connection)
TEST_ENTRY (tcp_unexpected_read)
ASSERT(r == 0);
uv_unref((uv_handle_t*)&timer_handle);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(loop_iteration == ITERATIONS);
client_connect();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connection_cb_called == 1);
ASSERT(connect_cb_called == 1);
TEST_IMPL(tcp_ping_pong) {
tcp_pinger_new();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(completed_pingers == 1);
TEST_IMPL(tcp_ping_pong_v6) {
tcp_pinger_v6_new();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(completed_pingers == 1);
TEST_IMPL(pipe_ping_pong) {
pipe_pinger_new();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(completed_pingers == 1);
uv_close((uv_handle_t*)&server1, close_cb);
uv_close((uv_handle_t*)&server2, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 2);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
ASSERT(r == 0);
uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
ASSERT(connect_cb_called == 1);
ASSERT(r == 0);
uv_pipe_connect(&req, &client, path, connect_cb_file);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
ASSERT(connect_cb_called == 1);
uv_close((uv_handle_t*) &poll_handles[i], close_cb);
}
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == NUM_SOCKETS);
for (i = 0; i < NUM_CLIENTS; i++)
start_client();
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
/* Assert that at most five percent of the writable wakeups was spurious. */
close_cb_called = 0;
uv_close((uv_handle_t*)handle, close_cb);
ASSERT(close_cb_called == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
}
TEST_IMPL(ref) {
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
return 0;
}
uv_idle_init(uv_default_loop(), &h);
uv_idle_start(&h, (uv_idle_cb) fail_cb2);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_async_t h;
uv_async_init(uv_default_loop(), &h, NULL);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_prepare_init(uv_default_loop(), &h);
uv_prepare_start(&h, (uv_prepare_cb) fail_cb2);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_check_init(uv_default_loop(), &h);
uv_check_start(&h, (uv_check_cb) fail_cb2);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_prepare_t h;
uv_prepare_init(uv_default_loop(), &h);
uv_prepare_start(&h, prepare_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_timer_t h;
uv_timer_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_timer_init(uv_default_loop(), &h);
uv_timer_start(&h, (uv_timer_cb)fail_cb, 42, 42);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_fs_event_t h;
uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb)fail_cb, 0);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_fs_poll_init(uv_default_loop(), &h);
uv_fs_poll_start(&h, NULL, ".", 999);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_tcp_t h;
uv_tcp_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_tcp_init(uv_default_loop(), &h);
uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
uv_unref((uv_handle_t*)&h);
uv_close((uv_handle_t*)&h, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
MAKE_VALGRIND_HAPPY();
return 0;
uv_tcp_init(uv_default_loop(), &h);
uv_tcp_connect(&connect_req, &h, addr, connect_and_shutdown);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 1);
ASSERT(shutdown_cb_called == 1);
do_close(&h);
uv_tcp_init(uv_default_loop(), &h);
uv_tcp_connect(&connect_req, &h, addr, connect_and_write);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 1);
ASSERT(write_cb_called == 1);
ASSERT(shutdown_cb_called == 1);
uv_udp_t h;
uv_udp_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_udp_bind(&h, addr, 0);
uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_udp_init(uv_default_loop(), &h);
uv_udp_send(&req, &h, &buf, 1, addr, (uv_udp_send_cb)req_cb);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(req_cb_called == 1);
do_close(&h);
uv_pipe_t h;
uv_pipe_init(uv_default_loop(), &h, 0);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_pipe_init(uv_default_loop(), &h, 0);
uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
MAKE_VALGRIND_HAPPY();
return 0;
uv_pipe_init(uv_default_loop(), &h, 0);
uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_shutdown);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 1);
ASSERT(shutdown_cb_called == 1);
do_close(&h);
uv_pipe_init(uv_default_loop(), &h, 0);
uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_write);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 1);
ASSERT(write_cb_called == 1);
ASSERT(shutdown_cb_called == 1);
ASSERT(r == 0);
uv_unref((uv_handle_t*)&h);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
r = uv_process_kill(&h, /* SIGTERM */ 15);
ASSERT(r == 0);
uv_timer_init(uv_default_loop(), &timer_handle);
uv_timer_start(&timer_handle, timer_cb, 100, 100);
- r = uv_run2(uv_default_loop(), UV_RUN_NOWAIT);
+ r = uv_run(uv_default_loop(), UV_RUN_NOWAIT);
ASSERT(r != 0);
ASSERT(timer_called == 0);
uv_idle_init(uv_default_loop(), &idle_handle);
uv_idle_start(&idle_handle, idle_cb);
- while (uv_run2(uv_default_loop(), UV_RUN_ONCE));
+ while (uv_run(uv_default_loop(), UV_RUN_ONCE));
ASSERT(idle_counter == NUM_TICKS);
MAKE_VALGRIND_HAPPY();
ASSERT(r == 0);
r = uv_tcp_connect(&connect_req, &h, addr, connect_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(connect_cb_called == 1);
r = uv_pipe_init(uv_default_loop(), &h, 0);
ASSERT(r == 0);
uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_cb);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(connect_cb_called == 1);
r = uv_tcp_connect(&connect_req, &tcp, server_addr, connect_cb);
ASSERT(!r);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(called_connect_cb == 1);
ASSERT(called_shutdown_cb == 1);
/* Wait for all signals. The signal callbacks stop the watcher, so uv_run
* will return when all signal watchers caught a signal.
*/
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
/* Restart the signal watchers. */
/* Wait for signals once more. */
uv_sem_post(&sem);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
/* Close the watchers. */
}
/* Wait for the signal watchers to close. */
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
uv_loop_delete(loop);
uv_close((uv_handle_t*) &signal, NULL);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
uv_loop_delete(loop);
start_timer(loop, SIGCHLD, &tc);
start_watcher(loop, SIGCHLD, &sc);
sc.stop_or_close = STOP; /* stop, don't close the signal handle */
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(tc.ncalls == NSIGNALS);
ASSERT(sc.ncalls == NSIGNALS);
start_timer(loop, SIGCHLD, &tc);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(tc.ncalls == NSIGNALS);
ASSERT(sc.ncalls == NSIGNALS);
uv_signal_start(&sc.handle, signal_cb, SIGCHLD);
start_timer(loop, SIGCHLD, &tc);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(tc.ncalls == NSIGNALS);
ASSERT(sc.ncalls == NSIGNALS);
start_watcher(loop, SIGUSR2, sc + 3);
start_timer(loop, SIGUSR1, tc + 0);
start_timer(loop, SIGUSR2, tc + 1);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
for (i = 0; i < ARRAY_SIZE(sc); i++)
ASSERT(sc[i].ncalls == NSIGNALS);
options.file = options.args[0] = "program-that-had-better-not-exist";
ASSERT(0 == uv_spawn(uv_default_loop(), &process, options));
ASSERT(0 != uv_is_active((uv_handle_t*)&process));
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
ASSERT(uv_last_error(uv_default_loop()).code == UV_ENOENT);
MAKE_VALGRIND_HAPPY();
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_read_start((uv_stream_t*) &pipe, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_timer_start(&timer, timer_cb, 500, 0);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
uv_unref((uv_handle_t*)&process);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 0);
r = uv_timer_start(&timer, timer_cb, 500, 0);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
ASSERT(exit_cb_called == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
err = uv_kill(process.pid, /* SIGTERM */ 15);
ASSERT(err.code == UV_OK);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
r = uv_spawn(uv_default_loop(), &process, options);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(exit_cb_called == 1);
ASSERT(r == -1);
ASSERT(uv_last_error(uv_default_loop()).code == UV_ENOTSUP);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(close_cb_called == 0);
ASSERT(r == -1);
ASSERT(uv_last_error(uv_default_loop()).code == UV_ENOTSUP);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(close_cb_called == 0);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(on_read_cb_called > 1);
ASSERT(r == 0);
}
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(after_write_called == 7);
ASSERT(on_pipe_read_called == 0);
on_pipe_read);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(after_write_called == 7);
ASSERT(on_pipe_read_called == 1);
uv_close((uv_handle_t*)&server1, close_cb);
uv_close((uv_handle_t*)&server2, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 2);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server1, close_cb);
uv_close((uv_handle_t*)&server2, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 2);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 1);
ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 50, 0));
ASSERT(0 == uv_timer_init(loop, &timer2_handle));
ASSERT(0 == uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(connect_cb_called == 1);
ASSERT(timer1_cb_called == 1);
ASSERT(write_cb_called == 0);
ASSERT(close_cb_called == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
printf("%d of %d write reqs seen\n", write_cb_called, NUM_WRITE_REQS);
r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(connect_cb_called == 1);
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 0);
ASSERT(close_cb_called == 1);
r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
uv_close((uv_handle_t*)&server, close_cb);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_called == 0);
ASSERT(close_cb_called == 1);
uv_close((uv_handle_t*)&handle, NULL);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
r = uv_tcp_connect(&connect_req, &client, addr, connect_cb);
ASSERT(r == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(shutdown_cb_called == 1);
ASSERT(connect_cb_called == 1);
ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle));
ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp_handle));
ASSERT(0 == uv_tcp_connect(&connect_req, &tcp_handle, addr, connect_cb));
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
MAKE_VALGRIND_HAPPY();
return 0;
r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb);
ASSERT(r == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(connect_cb_called == 1);
ASSERT(0 == uv_tcp_bind(&server_handle, addr));
ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb));
ASSERT(0 == uv_tcp_connect(&connect_req, &client_handle, addr, connect_cb));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
/* This is somewhat inexact but the idea is that the event loop should not
* start busy looping when the server sends a message and the client isn't
+++ /dev/null
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * 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.
- */
-
-#include "uv.h"
-#include "task.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void connection_cb(uv_stream_t* server, int status);
-static void connect_cb(uv_connect_t* req, int status);
-static void write_cb(uv_write_t* req, int status);
-static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);
-static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size);
-
-static uv_tcp_t tcp_server;
-static uv_tcp_t tcp_client;
-static uv_tcp_t tcp_peer; /* client socket as accept()-ed by server */
-static uv_connect_t connect_req;
-
-static int write_cb_called;
-static int write_cb_error_called;
-
-typedef struct {
- uv_write_t req;
- uv_buf_t buf;
-} write_req_t;
-
-
-static void connection_cb(uv_stream_t* server, int status) {
- int r;
-
- ASSERT(server == (uv_stream_t*)&tcp_server);
- ASSERT(status == 0);
-
- r = uv_tcp_init(server->loop, &tcp_peer);
- ASSERT(r == 0);
-
- r = uv_accept(server, (uv_stream_t*)&tcp_peer);
- ASSERT(r == 0);
-
- r = uv_read_start((uv_stream_t*)&tcp_peer, alloc_cb, read_cb);
- ASSERT(r == 0);
-}
-
-
-static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size) {
- static char slab[1024];
- return uv_buf_init(slab, sizeof slab);
-}
-
-
-static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
- uv_close((uv_handle_t*)&tcp_server, NULL);
- uv_close((uv_handle_t*)&tcp_peer, NULL);
-}
-
-
-static void connect_cb(uv_connect_t* req, int status) {
- uv_buf_t buf;
- size_t size;
- char* data;
- int r;
- write_req_t* wr;
-
- ASSERT(req == &connect_req);
- ASSERT(status == 0);
-
- while (1) {
- size = 10 * 1024 * 1024;
- data = malloc(size);
- ASSERT(data != NULL);
-
- memset(data, '$', size);
- buf = uv_buf_init(data, size);
-
- wr = (write_req_t*) malloc(sizeof *wr);
- wr->buf = buf;
- wr->req.data = data;
-
- r = uv_write(&(wr->req), req->handle, &wr->buf, 1, write_cb);
- ASSERT(r == 0);
-
- if (req->handle->write_queue_size >= size * 2) {
- break;
- }
- }
-}
-
-
-static void write_cb(uv_write_t* req, int status) {
- write_req_t* wr;
- wr = (write_req_t*) req;
-
- if (status == -1) {
- write_cb_error_called++;
- }
-
- if (req->handle->write_queue_size == 0) {
- uv_close((uv_handle_t*)&tcp_client, NULL);
- }
-
- free(wr->buf.base);
- free(wr);
-
- write_cb_called++;
-}
-
-
-/*
- * Assert that a failing write does not leave
- * the stream's write_queue_size in an inconsistent state.
- */
-TEST_IMPL(tcp_write_error) {
- uv_loop_t* loop;
- int r;
-
- loop = uv_default_loop();
- ASSERT(loop != NULL);
-
- r = uv_tcp_init(loop, &tcp_server);
- ASSERT(r == 0);
-
- r = uv_tcp_bind(&tcp_server, uv_ip4_addr("127.0.0.1", TEST_PORT));
- ASSERT(r == 0);
-
- r = uv_listen((uv_stream_t*)&tcp_server, 1, connection_cb);
- ASSERT(r == 0);
-
- r = uv_tcp_init(loop, &tcp_client);
- ASSERT(r == 0);
-
- r = uv_tcp_connect(&connect_req,
- &tcp_client,
- uv_ip4_addr("127.0.0.1", TEST_PORT),
- connect_cb);
- ASSERT(r == 0);
-
- ASSERT(write_cb_called == 0);
-
- r = uv_run(loop);
- ASSERT(r == 0);
-
- ASSERT(write_cb_called > 0);
- ASSERT(write_cb_error_called >= 1);
- ASSERT(tcp_client.write_queue_size == 0);
-
- MAKE_VALGRIND_HAPPY();
- return 0;
-}
connect_cb);
ASSERT(r == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(write_cb_called > 0);
r = uv_tcp_connect(&connect_req, &client, addr, connect_cb);
ASSERT(r == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(shutdown_cb_called == 1);
ASSERT(connect_cb_called == 1);
fs_do(req);
}
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
uv_loop_delete(loop);
ASSERT(0 == uv_timer_init(loop, &ci.timer_handle));
ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(1 == timer_cb_called);
cleanup_threadpool();
ASSERT(0 == uv_timer_init(loop, &ci.timer_handle));
ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(1 == timer_cb_called);
ASSERT(ARRAY_SIZE(reqs) == done2_cb_called);
ASSERT(0 == uv_timer_init(loop, &ci.timer_handle));
ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(n == fs_cb_called);
ASSERT(1 == timer_cb_called);
if (cancelled == 0)
break;
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
}
if (cancelled != 0) {
}
ASSERT(req.data == NULL);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(req.data != NULL); /* Should have been updated by nop_done_cb(). */
return 0;
work_req.data = &data;
r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb);
ASSERT(r == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(work_cb_count == 1);
ASSERT(after_work_cb_count == 1);
r = uv_queue_work(uv_default_loop(), &work_req, NULL, after_work_cb);
ASSERT(r == -1);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
ASSERT(work_cb_count == 0);
ASSERT(r == 0);
ASSERT(uv_timer_get_repeat(&repeat_2) == 100);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(repeat_1_cb_called == 10);
ASSERT(repeat_2_cb_called == 2);
ASSERT(r == 0);
uv_unref((uv_handle_t*)&never);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(once_cb_called == 10);
ASSERT(once_close_cb_called == 10);
ASSERT(r == 0);
r = uv_timer_start(&once, once_cb, 10, 0);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(once_cb_called == 1);
uv_close((uv_handle_t*) &tty_in, NULL);
uv_close((uv_handle_t*) &tty_out, NULL);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
return 0;
ASSERT(close_cb_called == 0);
ASSERT(send_cb_called == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(send_cb_called == 1);
ASSERT(close_cb_called == 1);
ASSERT(send_cb_called == 0);
ASSERT(recv_cb_called == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 3);
ASSERT(sv_send_cb_called == 0);
/* run the loop till all events are processed */
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(cl_recv_cb_called == 1);
ASSERT(sv_send_cb_called == 1);
ASSERT(sv_send_cb_called == 0);
/* run the loop till all events are processed */
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(sv_send_cb_called == 1);
ASSERT(close_cb_called == 1);
r = uv_udp_send(&send_req, &client, &buf, 1, addr, send_cb);
ASSERT(r == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(send_cb_called == 1);
ASSERT(close_cb_called == 1);
ASSERT(uv_last_error(loop).code == UV_EINVAL);
/* don't test ttl=-1, it's a valid value on some platforms */
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
ASSERT(sv_send_cb_called == 0);
ASSERT(sv_recv_cb_called == 0);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(cl_send_cb_called == 1);
ASSERT(cl_recv_cb_called == 1);
/* Start event loop, expect to see the timer handle in walk_cb. */
ASSERT(seen_timer_handle == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(seen_timer_handle == 1);
'test/test-tcp-connect-timeout.c',
'test/test-tcp-connect6-error.c',
'test/test-tcp-open.c',
- 'test/test-tcp-write-error.c',
'test/test-tcp-write-to-half-open-connection.c',
'test/test-tcp-writealot.c',
'test/test-tcp-unexpected-read.c',
// there are no watchers on the loop (except for the ones that were
// uv_unref'd) then this function exits. As long as there are active
// watchers, it blocks.
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
EmitExit(process_l);
RunAtExit();