Lines Matching refs:ctx

140   struct ipc_peer_ctx* ctx;  in ipc_write_cb()  local
141 ctx = container_of(req, struct ipc_peer_ctx, write_req); in ipc_write_cb()
142 uv_close((uv_handle_t*) &ctx->peer_handle, ipc_close_cb); in ipc_write_cb()
147 struct ipc_peer_ctx* ctx; in ipc_close_cb() local
148 ctx = container_of(handle, struct ipc_peer_ctx, peer_handle); in ipc_close_cb()
149 free(ctx); in ipc_close_cb()
154 struct ipc_client_ctx* ctx; in ipc_connect_cb() local
155 ctx = container_of(req, struct ipc_client_ctx, connect_req); in ipc_connect_cb()
157 ASSERT_OK(uv_read_start((uv_stream_t*) &ctx->ipc_pipe, in ipc_connect_cb()
166 struct ipc_client_ctx* ctx; in ipc_alloc_cb() local
167 ctx = container_of(handle, struct ipc_client_ctx, ipc_pipe); in ipc_alloc_cb()
168 buf->base = ctx->scratch; in ipc_alloc_cb()
169 buf->len = sizeof(ctx->scratch); in ipc_alloc_cb()
176 struct ipc_client_ctx* ctx; in ipc_read_cb() local
182 ctx = container_of(ipc_pipe, struct ipc_client_ctx, ipc_pipe); in ipc_read_cb()
188 ASSERT_OK(uv_tcp_init(loop, (uv_tcp_t*) ctx->server_handle)); in ipc_read_cb()
190 ASSERT_OK(uv_pipe_init(loop, (uv_pipe_t*) ctx->server_handle, 0)); in ipc_read_cb()
194 ASSERT_OK(uv_accept(handle, ctx->server_handle)); in ipc_read_cb()
195 uv_close((uv_handle_t*) &ctx->ipc_pipe, NULL); in ipc_read_cb()
206 struct ipc_server_ctx ctx; in send_listen_handles() local
211 ctx.num_connects = num_servers; in send_listen_handles()
214 ASSERT_OK(uv_tcp_init(loop, (uv_tcp_t*) &ctx.server_handle)); in send_listen_handles()
215 ASSERT_OK(uv_tcp_bind((uv_tcp_t*) &ctx.server_handle, in send_listen_handles()
226 ASSERT_OK(uv_pipe_init(loop, &ctx.ipc_pipe, 0)); in send_listen_handles()
227 ASSERT_OK(uv_pipe_bind(&ctx.ipc_pipe, IPC_PIPE_NAME)); in send_listen_handles()
228 ASSERT_OK(uv_listen((uv_stream_t*) &ctx.ipc_pipe, 128, ipc_connection_cb)); in send_listen_handles()
234 uv_close((uv_handle_t*) &ctx.server_handle, NULL); in send_listen_handles()
243 struct ipc_client_ctx ctx; in get_listen_handle() local
245 ctx.server_handle = server_handle; in get_listen_handle()
246 ctx.server_handle->data = "server handle"; in get_listen_handle()
248 ASSERT_OK(uv_pipe_init(loop, &ctx.ipc_pipe, 1)); in get_listen_handle()
249 uv_pipe_connect(&ctx.connect_req, in get_listen_handle()
250 &ctx.ipc_pipe, in get_listen_handle()
258 struct server_ctx *ctx; in server_cb() local
261 ctx = arg; in server_cb()
264 ASSERT_OK(uv_async_init(&loop, &ctx->async_handle, sv_async_cb)); in server_cb()
265 uv_unref((uv_handle_t*) &ctx->async_handle); in server_cb()
268 uv_sem_wait(&ctx->semaphore); in server_cb()
269 get_listen_handle(&loop, (uv_stream_t*) &ctx->server_handle); in server_cb()
270 uv_sem_post(&ctx->semaphore); in server_cb()
273 ASSERT_OK(uv_listen((uv_stream_t*) &ctx->server_handle, in server_cb()
283 struct server_ctx* ctx; in sv_async_cb() local
284 ctx = container_of(handle, struct server_ctx, async_handle); in sv_async_cb()
285 uv_close((uv_handle_t*) &ctx->server_handle, NULL); in sv_async_cb()
286 uv_close((uv_handle_t*) &ctx->async_handle, NULL); in sv_async_cb()
292 struct server_ctx* ctx; in sv_connection_cb() local
294 ctx = container_of(server_handle, struct server_ctx, server_handle); in sv_connection_cb()
309 ctx->num_connects++; in sv_connection_cb()
331 struct client_ctx* ctx = container_of(req, struct client_ctx, connect_req); in cl_connect_cb() local
332 uv_idle_start(&ctx->idle_handle, cl_idle_cb); in cl_connect_cb()
338 struct client_ctx* ctx = container_of(handle, struct client_ctx, idle_handle); in cl_idle_cb() local
339 uv_close((uv_handle_t*) &ctx->client_handle, cl_close_cb); in cl_idle_cb()
340 uv_idle_stop(&ctx->idle_handle); in cl_idle_cb()
345 struct client_ctx* ctx; in cl_close_cb() local
347 ctx = container_of(handle, struct client_ctx, client_handle); in cl_close_cb()
349 if (--ctx->num_connects == 0) { in cl_close_cb()
350 uv_close((uv_handle_t*) &ctx->idle_handle, NULL); in cl_close_cb()
354 ASSERT_OK(uv_tcp_init(handle->loop, (uv_tcp_t*) &ctx->client_handle)); in cl_close_cb()
355 ASSERT_OK(uv_tcp_connect(&ctx->connect_req, in cl_close_cb()
356 (uv_tcp_t*) &ctx->client_handle, in cl_close_cb()
383 struct server_ctx* ctx = servers + i; in test_tcp() local
384 ASSERT_OK(uv_sem_init(&ctx->semaphore, 0)); in test_tcp()
385 ASSERT_OK(uv_thread_create(&ctx->thread_id, server_cb, ctx)); in test_tcp()
391 struct client_ctx* ctx = clients + i; in test_tcp() local
392 ctx->num_connects = NUM_CONNECTS / num_clients; in test_tcp()
393 handle = (uv_tcp_t*) &ctx->client_handle; in test_tcp()
396 ASSERT_OK(uv_tcp_connect(&ctx->connect_req, in test_tcp()
400 ASSERT_OK(uv_idle_init(loop, &ctx->idle_handle)); in test_tcp()
411 struct server_ctx* ctx = servers + i; in test_tcp() local
412 uv_async_send(&ctx->async_handle); in test_tcp()
413 ASSERT_OK(uv_thread_join(&ctx->thread_id)); in test_tcp()
414 uv_sem_destroy(&ctx->semaphore); in test_tcp()
423 struct server_ctx* ctx = servers + i; in test_tcp() local
426 ctx->num_connects / time, in test_tcp()
427 ctx->num_connects, in test_tcp()
428 ctx->num_connects * 100.0 / NUM_CONNECTS); in test_tcp()