worker->request = NULL;
}
-void worker_connection_destroy(struct connection *conn)
+static void worker_connection_destroy(struct connection *conn)
{
struct worker_connection *worker =
container_of(conn, struct worker_connection, conn);
return ret;
}
-bool worker_connection_is_connected(struct connection *conn)
-{
- return !conn->disconnected;
-}
-
-unsigned int worker_connections_get_process_limit(void)
-{
- return worker_last_process_limit;
-}
-
void worker_connection_request(struct connection *conn,
struct indexer_request *request)
{
struct worker_connection *worker =
container_of(conn, struct worker_connection, conn);
- i_assert(worker_connection_is_connected(conn));
+ i_assert(!conn->disconnected);
if (worker->request_username == NULL)
worker->request_username = i_strdup(request->username);
} T_END;
}
-const char *worker_connection_get_username(struct connection *conn)
-{
- struct worker_connection *worker =
- container_of(conn, struct worker_connection, conn);
- return worker->request_username;
-}
-
static const struct connection_vfuncs worker_connection_vfuncs = {
.destroy = worker_connection_destroy,
.input_args = worker_connection_input_args,
struct worker_connection *conn;
unsigned int max_connections;
- max_connections = I_MAX(1, worker_connections_get_process_limit());
+ max_connections = I_MAX(1, worker_last_process_limit);
if (worker_connections->connections_count >= max_connections)
return 0;
struct connection *worker_connections_find_user(const char *username)
{
struct connection *conn;
- const char *worker_user;
for (conn = worker_connections->connections; conn != NULL; conn = conn->next) {
- worker_user = worker_connection_get_username(conn);
- if (worker_user != NULL && strcmp(worker_user, username) == 0)
+ struct worker_connection *worker =
+ container_of(conn, struct worker_connection, conn);
+
+ if (worker->request_username != NULL &&
+ strcmp(worker->request_username, username) == 0)
return conn;
}
return NULL;
indexer_status_callback_t *callback,
worker_available_callback_t *avail_callback,
struct connection **conn_r);
-void worker_connection_destroy(struct connection *conn);
-
-/* Returns TRUE if worker is connected to (not necessarily handshaked yet) */
-bool worker_connection_is_connected(struct connection *conn);
-
-/* Returns the last process_limit returned by a worker connection handshake.
- If no handshakes have been received yet, returns 0. */
-unsigned int worker_connections_get_process_limit(void);
/* Send a new indexing request for username+mailbox. The status callback is
called as necessary. Requests can be queued, but only for the same
username. */
void worker_connection_request(struct connection *conn,
struct indexer_request *request);
-/* Returns username of the currently pending requests,
- or NULL if there are none. */
-const char *worker_connection_get_username(struct connection *conn);
unsigned int worker_connections_get_count(void);
struct connection *worker_connections_find_user(const char *username);