static void accept_connection(h2o_socket_t *listener, const char *err) { if (err) ERROR(err); else { thread_context_t * const ctx = H2O_STRUCT_FROM_MEMBER(thread_context_t, event_loop, listener->data); if (!ctx->global_data->shutdown) { size_t accepted = ctx->config->max_accept; do { h2o_socket_t * const sock = h2o_evloop_socket_accept(listener); if (!sock) break; ctx->event_loop.conn_num++; sock->on_close.cb = on_close_connection; sock->on_close.data = &ctx->event_loop.conn_num; h2o_accept(&ctx->event_loop.h2o_accept_ctx, sock); } while (--accepted > 0); } } }
static void on_accept(h2o_socket_t *listener, const char *err) { h2o_socket_t *sock; if (err != NULL) { return; } if ((sock = h2o_evloop_socket_accept(listener)) == NULL) return; h2o_accept(&accept_ctx, sock); }
static void on_accept(h2o_socket_t *listener, int status) { h2o_socket_t *sock; if (status == -1) { return; } if ((sock = h2o_evloop_socket_accept(listener)) == NULL) { return; } h2o_accept(&ctx, sock); }
static void on_config_port_accept(h2o_socket_t *listener, int status) { h2o_context_t *ctx = listener->data; h2o_socket_t *sock; if (status == -1) { return; } if ((sock = h2o_evloop_socket_accept(listener)) == NULL) { return; } h2o_accept(ctx, sock); }
static void on_accept(uv_stream_t *listener, int status) { uv_tcp_t *conn; h2o_socket_t *sock; if (status != 0) return; conn = h2o_mem_alloc(sizeof(*conn)); uv_tcp_init(listener->loop, conn); if (uv_accept(listener, (uv_stream_t *)conn) != 0) { uv_close((uv_handle_t *)conn, (uv_close_cb)free); return; } sock = h2o_uv_socket_create((uv_handle_t *)conn, (uv_close_cb)free); h2o_accept(&accept_ctx, sock); }