bench: let client close connection in tcp_multi_accept{2,4,8}
This commit is contained in:
parent
a8c6da8dfa
commit
29f44c7564
@ -91,6 +91,8 @@ static uv_buf_t ipc_alloc_cb(uv_handle_t* handle, size_t suggested_size);
|
||||
|
||||
static void sv_async_cb(uv_async_t* handle, int status);
|
||||
static void sv_connection_cb(uv_stream_t* server_handle, int status);
|
||||
static void sv_read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf);
|
||||
static uv_buf_t sv_alloc_cb(uv_handle_t* handle, size_t suggested_size);
|
||||
|
||||
static void cl_connect_cb(uv_connect_t* req, int status);
|
||||
static void cl_idle_cb(uv_idle_t* handle, int status);
|
||||
@ -292,11 +294,24 @@ static void sv_connection_cb(uv_stream_t* server_handle, int status) {
|
||||
ASSERT(0);
|
||||
|
||||
ASSERT(0 == uv_accept(server_handle, (uv_stream_t*) storage));
|
||||
uv_close((uv_handle_t*) storage, (uv_close_cb) free);
|
||||
ASSERT(0 == uv_read_start((uv_stream_t*) storage, sv_alloc_cb, sv_read_cb));
|
||||
ctx->num_connects++;
|
||||
}
|
||||
|
||||
|
||||
static uv_buf_t sv_alloc_cb(uv_handle_t* handle, size_t suggested_size) {
|
||||
static char buf[32];
|
||||
return uv_buf_init(buf, sizeof(buf));
|
||||
}
|
||||
|
||||
|
||||
static void sv_read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) {
|
||||
ASSERT(nread == -1);
|
||||
ASSERT(uv_last_error(handle->loop).code == UV_EOF);
|
||||
uv_close((uv_handle_t*) handle, (uv_close_cb) free);
|
||||
}
|
||||
|
||||
|
||||
static void cl_connect_cb(uv_connect_t* req, int status) {
|
||||
struct client_ctx* ctx = container_of(req, struct client_ctx, connect_req);
|
||||
uv_idle_start(&ctx->idle_handle, cl_idle_cb);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user