bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen struct worker_connection_list *busy_list, *idle_list;
6f7b4a6773eee7216c1afdc808c3cfdc92ac1b40Timo Sirainenworker_connection_list_free(struct worker_pool *pool,
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenworker_pool_init(const char *socket_path, indexer_status_callback_t *callback)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenvoid worker_pool_deinit(struct worker_pool **_pool)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen struct worker_connection_list *list = pool->busy_list;
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen struct worker_connection_list *list = pool->idle_list;
df26373d0aa3cb208da213fce32e2abc5d97f90bTimo Sirainenbool worker_pool_have_busy_connections(struct worker_pool *pool)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenstatic int worker_pool_add_connection(struct worker_pool *pool)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen conn = worker_connection_create(pool->socket_path, pool->callback);
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen list = i_new(struct worker_connection_list, 1);
6f7b4a6773eee7216c1afdc808c3cfdc92ac1b40Timo Sirainenworker_connection_list_free(struct worker_pool *pool,
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenstatic unsigned int worker_pool_find_max_connections(struct worker_pool *pool)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen for (list = pool->busy_list; list != NULL; list = list->next) {
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen if (worker_connection_get_process_limit(list->conn, &limit))
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen /* we have at least one connection that has already been created,
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen but without having handshaked yet. wait until it's finished. */
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenbool worker_pool_get_connection(struct worker_pool *pool,
6f7b4a6773eee7216c1afdc808c3cfdc92ac1b40Timo Sirainen !worker_connection_is_connected(pool->idle_list->conn)) {
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen max_connections = worker_pool_find_max_connections(pool);
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen if (pool->connection_count >= max_connections)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenstatic void worker_pool_kill_idle_connections(struct worker_pool *pool)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen kill_timestamp = ioloop_time - MAX_WORKER_IDLE_SECS;
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen for (list = pool->idle_list; list != NULL; list = next) {
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenvoid worker_pool_release_connection(struct worker_pool *pool,
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen /* not finished with all queued requests yet */
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen for (list = pool->busy_list; list != NULL; list = list->next) {
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenworker_pool_find_username_connection(struct worker_pool *pool,
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen for (list = pool->busy_list; list != NULL; list = list->next) {
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen worker_user = worker_connection_get_username(list->conn);