make uv_pipe_connect return void

This commit is contained in:
Igor Zinkovsky 2011-11-04 16:06:53 -07:00
parent 82cf0b38c0
commit faca1402ef
7 changed files with 14 additions and 19 deletions

View File

@ -763,7 +763,7 @@ UV_EXTERN void uv_pipe_open(uv_pipe_t*, uv_file file);
UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
UV_EXTERN int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb); const char* name, uv_connect_cb cb);

View File

@ -177,7 +177,7 @@ void uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
} }
int uv_pipe_connect(uv_connect_t* req, void uv_pipe_connect(uv_connect_t* req,
uv_pipe_t* handle, uv_pipe_t* handle,
const char* name, const char* name,
uv_connect_cb cb) { uv_connect_cb cb) {
@ -237,7 +237,6 @@ out:
* return 0 and let the callback handle errors. * return 0 and let the callback handle errors.
*/ */
errno = saved_errno; errno = saved_errno;
return 0;
} }

View File

@ -443,7 +443,7 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
} }
int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb) { const char* name, uv_connect_cb cb) {
uv_loop_t* loop = handle->loop; uv_loop_t* loop = handle->loop;
int errno, nameSize; int errno, nameSize;
@ -488,7 +488,7 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
handle->reqs_pending++; handle->reqs_pending++;
return 0; return;
} }
errno = GetLastError(); errno = GetLastError();
@ -505,7 +505,7 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
SET_REQ_SUCCESS(req); SET_REQ_SUCCESS(req);
uv_insert_pending_req(loop, (uv_req_t*) req); uv_insert_pending_req(loop, (uv_req_t*) req);
handle->reqs_pending++; handle->reqs_pending++;
return 0; return;
error: error:
if (handle->name) { if (handle->name) {
@ -516,8 +516,12 @@ error:
if (pipeHandle != INVALID_HANDLE_VALUE) { if (pipeHandle != INVALID_HANDLE_VALUE) {
CloseHandle(pipeHandle); CloseHandle(pipeHandle);
} }
uv__set_sys_error(loop, errno);
return -1; /* Make this req pending reporting an error. */
SET_REQ_ERROR(req, errno);
uv_insert_pending_req(loop, (uv_req_t*) req);
handle->reqs_pending++;
return;
} }

View File

@ -225,12 +225,7 @@ static void pipe_make_connect(conn_rec* p) {
r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0); r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0);
ASSERT(r == 0); ASSERT(r == 0);
r = uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb); uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb);
if (r) {
fprintf(stderr, "uv_tcp_connect error %s\n",
uv_err_name(uv_last_error(loop)));
ASSERT(0);
}
#if DEBUG #if DEBUG
printf("make connect %d\n", p->i); printf("make connect %d\n", p->i);

View File

@ -257,8 +257,7 @@ static void maybe_connect_some() {
ASSERT(r == 0); ASSERT(r == 0);
req = (uv_connect_t*) req_alloc(); req = (uv_connect_t*) req_alloc();
r = uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb); uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb);
ASSERT(r == 0);
} }
} }
} }

View File

@ -211,9 +211,8 @@ static void pipe_pinger_new() {
/* We are never doing multiple reads/connects at a time anyway. */ /* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */ /* so these handles can be pre-initialized. */
r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME, uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
pinger_on_connect); pinger_on_connect);
ASSERT(!r);
/* Synchronous connect callbacks are not allowed. */ /* Synchronous connect callbacks are not allowed. */
ASSERT(pinger_on_connect_count == 0); ASSERT(pinger_on_connect_count == 0);

View File

@ -58,7 +58,6 @@ TEST_IMPL(pipe_connect_bad_name) {
r = uv_pipe_init(uv_default_loop(), &client, 0); r = uv_pipe_init(uv_default_loop(), &client, 0);
ASSERT(r == 0); ASSERT(r == 0);
uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb); uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb);
ASSERT(r == 0);
uv_run(uv_default_loop()); uv_run(uv_default_loop());