Lines Matching refs:pool

201 static void evrpc_pool_schedule(struct evrpc_pool *pool);
509 struct evrpc_pool *pool = mm_calloc(1, sizeof(struct evrpc_pool));
510 if (pool == NULL)
513 TAILQ_INIT(&pool->connections);
514 TAILQ_INIT(&pool->requests);
516 TAILQ_INIT(&pool->paused_requests);
518 TAILQ_INIT(&pool->input_hooks);
519 TAILQ_INIT(&pool->output_hooks);
521 pool->base = base;
522 pool->timeout = -1;
524 return (pool);
537 evrpc_pool_free(struct evrpc_pool *pool)
545 while ((request = TAILQ_FIRST(&pool->requests)) != NULL) {
546 TAILQ_REMOVE(&pool->requests, request, next);
550 while ((pause = TAILQ_FIRST(&pool->paused_requests)) != NULL) {
551 TAILQ_REMOVE(&pool->paused_requests, pause, next);
555 while ((connection = TAILQ_FIRST(&pool->connections)) != NULL) {
556 TAILQ_REMOVE(&pool->connections, connection, next);
560 while ((hook = TAILQ_FIRST(&pool->input_hooks)) != NULL) {
561 r = evrpc_remove_hook(pool, EVRPC_INPUT, hook);
565 while ((hook = TAILQ_FIRST(&pool->output_hooks)) != NULL) {
566 r = evrpc_remove_hook(pool, EVRPC_OUTPUT, hook);
570 mm_free(pool);
574 * Add a connection to the RPC pool. A request scheduled on the pool
579 evrpc_pool_add_connection(struct evrpc_pool *pool,
583 TAILQ_INSERT_TAIL(&pool->connections, connection, next);
588 if (pool->base != NULL)
589 evhttp_connection_set_base(connection, pool->base);
593 * the connection inherits the timeout from the pool.
596 evhttp_connection_set_timeout(connection, pool->timeout);
603 if (TAILQ_FIRST(&pool->requests) != NULL) {
605 TAILQ_FIRST(&pool->requests);
606 TAILQ_REMOVE(&pool->requests, request, next);
612 evrpc_pool_remove_connection(struct evrpc_pool *pool,
615 TAILQ_REMOVE(&pool->connections, connection, next);
619 evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs)
622 TAILQ_FOREACH(evcon, &pool->connections, next) {
625 pool->timeout = timeout_in_secs;
633 * Finds a connection object associated with the pool that is currently
637 evrpc_pool_find_connection(struct evrpc_pool *pool)
640 TAILQ_FOREACH(connection, &pool->connections, next) {
655 * We assume that the ctx is no longer queued on the pool.
662 struct evrpc_pool *pool = ctx->pool;
677 if (TAILQ_FIRST(&pool->output_hooks) != NULL) {
683 hook_res = evrpc_process_hooks(&pool->output_hooks,
691 if (evrpc_pause_request(pool, ctx,
722 struct evrpc_pool *pool = ctx->pool;
734 if (pool->timeout > 0) {
740 tv.tv_sec = pool->timeout;
760 /* we just queue the paused request on the pool under the req object */
801 struct evrpc_pool *pool = ctx->pool;
804 evtimer_assign(&ctx->ev_timeout, pool->base, evrpc_request_timeout, ctx);
806 /* we better have some available connections on the pool */
807 EVUTIL_ASSERT(TAILQ_FIRST(&pool->connections) != NULL);
810 * if no connection is available, we queue the request on the pool,
813 TAILQ_INSERT_TAIL(&pool->requests, ctx, next);
815 evrpc_pool_schedule(pool);
823 struct evrpc_pool *pool, void *request, void *reply,
836 ctx->pool = pool;
862 struct evrpc_pool *pool = ctx->pool;
876 if (TAILQ_FIRST(&pool->input_hooks) != NULL) {
880 hook_res = evrpc_process_hooks(&pool->input_hooks,
897 evrpc_pause_request(pool, ctx,
917 struct evrpc_pool *pool = ctx->pool;
950 evrpc_pool_schedule(pool);
954 evrpc_pool_schedule(struct evrpc_pool *pool)
956 struct evrpc_request_wrapper *ctx = TAILQ_FIRST(&pool->requests);
963 if ((evcon = evrpc_pool_find_connection(pool)) != NULL) {
964 TAILQ_REMOVE(&pool->requests, ctx, next);
1079 evrpc_send_request_generic(struct evrpc_pool *pool,
1090 ctx = evrpc_make_request_ctx(pool, request, reply,
1154 return (ctx->pool);
1159 struct evrpc_pool *pool)
1161 ctx->pool = pool;