static bool idle_die(void)
{
return indexer_queue_is_empty(queue) &&
- !worker_pool_have_busy_connections(worker_pool);
+ !worker_pool_have_connections(worker_pool);
}
static void client_connected(struct master_service_connection *conn)
while ((request = indexer_queue_request_peek(queue)) != NULL) {
conn = worker_pool_find_username_connection(worker_pool,
request->username);
- if (conn != NULL && worker_connection_is_busy(conn)) {
+ if (conn != NULL) {
/* There is already a connection handling a request
* for this user. Move the request to the back of the
* queue and handle requests from other users.
first_moved_request = request;
indexer_queue_move_head_to_tail(queue);
continue;
- } else if (conn == NULL) {
+ } else {
/* create a new connection to a worker */
if (!worker_pool_get_connection(worker_pool, &conn))
break;
} T_END;
}
-bool worker_connection_is_busy(struct connection *conn)
-{
- struct worker_connection *worker =
- container_of(conn, struct worker_connection, conn);
- return worker->request != NULL;
-}
-
const char *worker_connection_get_username(struct connection *conn)
{
struct worker_connection *worker =
void worker_connection_request(struct connection *conn,
struct indexer_request *request,
void *context);
-/* Returns TRUE if a request is being handled. */
-bool worker_connection_is_busy(struct connection *conn);
/* Returns username of the currently pending requests,
or NULL if there are none. */
const char *worker_connection_get_username(struct connection *conn);
i_free(pool);
}
-bool worker_pool_have_busy_connections(struct worker_pool *pool)
+bool worker_pool_have_connections(struct worker_pool *pool)
{
- struct connection *list;
- for (list = pool->connection_list->connections; list != NULL; list = list->next)
- if (worker_connection_is_busy(list))
- return TRUE;
- return FALSE;
+ return pool->connection_list->connections != NULL;
}
static int worker_pool_add_connection(struct worker_pool *pool,
worker_available_callback_t *avail_callback);
void worker_pool_deinit(struct worker_pool **pool);
-bool worker_pool_have_busy_connections(struct worker_pool *pool);
+bool worker_pool_have_connections(struct worker_pool *pool);
bool worker_pool_get_connection(struct worker_pool *pool,
struct connection **conn_r);