uv_tcp_init() must be called before uv_accept()
Windows broken.
This commit is contained in:
parent
9400c3ffff
commit
aabe56b680
@ -256,6 +256,8 @@ static void connection_cb(uv_tcp_t* s, int status) {
|
||||
|
||||
tcp = malloc(sizeof(uv_tcp_t));
|
||||
|
||||
uv_tcp_init(tcp);
|
||||
|
||||
r = uv_accept(s, tcp);
|
||||
ASSERT(r == 0);
|
||||
|
||||
|
||||
@ -134,6 +134,8 @@ static void on_connection(uv_tcp_t* server, int status) {
|
||||
handle = (uv_tcp_t*) malloc(sizeof *handle);
|
||||
ASSERT(handle != NULL);
|
||||
|
||||
uv_tcp_init(handle);
|
||||
|
||||
r = uv_accept(server, handle);
|
||||
ASSERT(r == 0);
|
||||
|
||||
|
||||
@ -60,14 +60,16 @@ static void do_accept(uv_handle_t* timer_handle, int status) {
|
||||
ASSERT(status == 0);
|
||||
ASSERT(accepted_handle != NULL);
|
||||
|
||||
/* Test to that uv_cnt_tcp_init increases across the uv_accept. */
|
||||
uv_tcp_init(accepted_handle);
|
||||
|
||||
/* Test to that uv_cnt_tcp_init does not increase across the uv_accept. */
|
||||
tcpcnt = uv_cnt_tcp_init;
|
||||
|
||||
server = (uv_tcp_t*)timer_handle->data;
|
||||
r = uv_accept(server, accepted_handle);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(uv_cnt_tcp_init == tcpcnt + 1);
|
||||
ASSERT(uv_cnt_tcp_init == tcpcnt);
|
||||
|
||||
do_accept_called++;
|
||||
|
||||
|
||||
@ -367,10 +367,7 @@ void uv__server_io(EV_P_ ev_io* watcher, int revents) {
|
||||
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client) {
|
||||
if (server->accepted_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uv_tcp_init(client)) {
|
||||
uv_err_new((uv_handle_t*) server, EAGAIN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
6
uv.h
6
uv.h
@ -204,7 +204,11 @@ int uv_shutdown(uv_req_t* req);
|
||||
|
||||
int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
|
||||
|
||||
/* Call this after connection_cb. client does not need to be initialized. */
|
||||
/* This call is used in conjunction with uv_listen() to accept incoming TCP
|
||||
* connections. Call uv_accept after receiving a uv_connection_cb to accept
|
||||
* the connection. Before calling uv_accept use uv_tcp_init() must be
|
||||
* called on the client. Non-zero return value indicates an error.
|
||||
*/
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client);
|
||||
|
||||
/* Read data from an incoming stream. The callback will be made several
|
||||
|
||||
Loading…
Reference in New Issue
Block a user