*conn_r = &conn->conn;
return 1;
}
+
+unsigned int worker_connections_get_count(struct connection_list *list)
+{
+ return list->connections_count;
+}
+
+struct connection *
+worker_connections_find_user(struct connection_list *list,
+ const char *username)
+{
+ struct connection *conn;
+ const char *worker_user;
+
+ for (conn = list->connections; conn != NULL; conn = conn->next) {
+ worker_user = worker_connection_get_username(conn);
+ if (worker_user != NULL && strcmp(worker_user, username) == 0)
+ return conn;
+ }
+ return NULL;
+}
or NULL if there are none. */
const char *worker_connection_get_username(struct connection *conn);
+unsigned int worker_connections_get_count(struct connection_list *list);
+struct connection *
+worker_connections_find_user(struct connection_list *list,
+ const char *username);
+
#endif
bool worker_pool_have_connections(struct worker_pool *pool)
{
- return pool->connection_list->connections != NULL;
+ return worker_connections_get_count(pool->connection_list) > 0;
}
bool worker_pool_get_connection(struct worker_pool *pool,
worker_pool_find_username_connection(struct worker_pool *pool,
const char *username)
{
- struct connection *list;
- const char *worker_user;
-
- for (list = pool->connection_list->connections; list != NULL; list = list->next) {
- worker_user = worker_connection_get_username(list);
- if (worker_user != NULL && strcmp(worker_user, username) == 0)
- return list;
- }
- return NULL;
+ return worker_connections_find_user(pool->connection_list, username);
}