accept_cb -> connection_cb

This commit is contained in:
Ryan Dahl 2011-06-07 14:12:08 +02:00
parent a7494416e9
commit 8a0742910c
8 changed files with 21 additions and 21 deletions

View File

@ -42,7 +42,7 @@ Returns zero on success, -1 on failure. Errors in order of least-seriousness:
* `UV_EFAULT` Memory of `address` parameter is unintelligible.
int uv_listen(uv_tcp_server_t*, int backlog, uv_accept_cb cb);
int uv_listen(uv_tcp_server_t*, int backlog, uv_connection_cb cb);
Begins listening for connections. The accept callback is level-triggered.
@ -58,7 +58,7 @@ used instead of `uv_tcp_init` for server-side `uv_tcp_t` initialization.
Return value 0 indicates success, -1 failure. Possible errors:
* `UV_EAGAIN` There are no connections. Wait for the `uv_accept_cb` callback
* `UV_EAGAIN` There are no connections. Wait for the `uv_connection_cb` callback
to be called again.
* `UV_EFAULT` The memory of either `server` is unintelligible.

View File

@ -250,7 +250,7 @@ static void maybe_connect_some() {
}
static void accept_cb(uv_tcp_t* s) {
static void connection_cb(uv_tcp_t* s) {
uv_tcp_t* tcp;
int r;
@ -353,7 +353,7 @@ HELPER_IMPL(pump_server) {
ASSERT(r == 0);
r = uv_bind(&server, listen_addr);
ASSERT(r == 0);
r = uv_listen(&server, MAX_WRITE_HANDLES, accept_cb);
r = uv_listen(&server, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);
uv_run();

View File

@ -27,7 +27,7 @@
static char BUFFER[1024];
static int accept_cb_called = 0;
static int connection_cb_called = 0;
static int do_accept_called = 0;
static int close_cb_called = 0;
static int connect_cb_called = 0;
@ -82,7 +82,7 @@ static void do_accept(uv_handle_t* timer_handle, int status) {
}
static void accept_cb(uv_tcp_t* tcp) {
static void connection_cb(uv_tcp_t* tcp) {
int r;
uv_timer_t* timer_handle;
@ -95,7 +95,7 @@ static void accept_cb(uv_tcp_t* tcp) {
r = uv_timer_start(timer_handle, do_accept, 1000, 0);
ASSERT(r == 0);
accept_cb_called++;
connection_cb_called++;
}
@ -112,7 +112,7 @@ static void start_server() {
r = uv_bind(server, addr);
ASSERT(r == 0);
r = uv_listen(server, 128, accept_cb);
r = uv_listen(server, 128, connection_cb);
ASSERT(r == 0);
}
@ -177,7 +177,7 @@ TEST_IMPL(delayed_accept) {
uv_run();
ASSERT(accept_cb_called == 2);
ASSERT(connection_cb_called == 2);
ASSERT(do_accept_called == 2);
ASSERT(connect_cb_called == 2);
ASSERT(close_cb_called == 7);

View File

@ -355,7 +355,7 @@ void uv__server_io(EV_P_ ev_io* watcher, int revents) {
} else {
tcp->accepted_fd = fd;
tcp->accept_cb(tcp);
tcp->connection_cb(tcp);
if (tcp->accepted_fd >= 0) {
/* The user hasn't yet accepted called uv_accept() */
ev_io_stop(EV_DEFAULT_ &tcp->read_watcher);
@ -389,7 +389,7 @@ int uv_accept(uv_tcp_t* server, uv_tcp_t* client,
}
int uv_listen(uv_tcp_t* tcp, int backlog, uv_accept_cb cb) {
int uv_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
int r;
assert(tcp->fd >= 0);
@ -405,7 +405,7 @@ int uv_listen(uv_tcp_t* tcp, int backlog, uv_accept_cb cb) {
return -1;
}
tcp->accept_cb = cb;
tcp->connection_cb = cb;
/* Start listening for connections. */
ev_io_set(&tcp->read_watcher, tcp->fd, EV_READ);

View File

@ -58,7 +58,7 @@ typedef struct {
int delayed_error; \
uv_read_cb read_cb; \
uv_alloc_cb alloc_cb; \
uv_accept_cb accept_cb; \
uv_connection_cb connection_cb; \
int accepted_fd; \
uv_req_t *connect_req; \
uv_req_t *shutdown_req; \

View File

@ -804,7 +804,7 @@ static void uv_queue_read(uv_tcp_t* handle) {
}
int uv_listen(uv_tcp_t* handle, int backlog, uv_accept_cb cb) {
int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
assert(backlog > 0);
if (handle->flags & UV_HANDLE_BIND_ERROR) {
@ -825,7 +825,7 @@ int uv_listen(uv_tcp_t* handle, int backlog, uv_accept_cb cb) {
}
handle->flags |= UV_HANDLE_LISTENING;
handle->accept_cb = cb;
handle->connection_cb = cb;
uv_req_init(&(handle->accept_req), (uv_handle_t*)handle, NULL);
uv_queue_accept(handle);
@ -1130,8 +1130,8 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
sizeof(handle->socket)) == 0);
if (success) {
if (handle->accept_cb) {
((uv_accept_cb)handle->accept_cb)(handle);
if (handle->connection_cb) {
((uv_connection_cb)handle->connection_cb)(handle);
}
} else {
/* Errorneous accept is ignored if the listen socket is still healthy. */

View File

@ -59,7 +59,7 @@ typedef struct uv_buf_t {
uv_req_t* shutdown_req;
#define uv_tcp_server_fields \
void *accept_cb; \
void *connection_cb; \
SOCKET accept_socket; \
struct uv_req_s accept_req; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];

6
uv.h
View File

@ -61,7 +61,7 @@ typedef void (*uv_read_cb)(uv_tcp_t* tcp, int nread, uv_buf_t buf);
typedef void (*uv_write_cb)(uv_req_t* req, int status);
typedef void (*uv_connect_cb)(uv_req_t* req, int status);
typedef void (*uv_shutdown_cb)(uv_req_t* req, int status);
typedef void (*uv_accept_cb)(uv_tcp_t* server);
typedef void (*uv_connection_cb)(uv_tcp_t* server);
typedef void (*uv_close_cb)(uv_handle_t* handle, int status);
/* TODO: do loop_cb and async_cb really need a status argument? */
typedef void (*uv_loop_cb)(uv_handle_t* handle, int status);
@ -202,9 +202,9 @@ int uv_connect(uv_req_t* req, struct sockaddr_in);
int uv_shutdown(uv_req_t* req);
int uv_listen(uv_tcp_t* handle, int backlog, uv_accept_cb cb);
int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
/* Call this after accept_cb. client does not need to be initialized. */
/* Call this after connection_cb. client does not need to be initialized. */
int uv_accept(uv_tcp_t* server, uv_tcp_t* client,
uv_close_cb close_cb, void* data);