#include "str.h"
#include "hash.h"
#include "array.h"
+#include "llist.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
hostname = host->name;
hash_table_insert(client->hosts, hostname, host);
+ DLLIST_PREPEND(&client->hosts_list, host);
http_client_host_debug(host, "Host created");
}
{
struct http_client_host *host = *_host;
struct http_client_host_port *hport;
+ const char *hostname = host->name;
http_client_host_debug(host, "Host destroy");
+ DLLIST_REMOVE(&host->client->hosts_list, host);
+ hash_table_remove(host->client->hosts, hostname);
+
if (host->dns_lookup != NULL)
dns_lookup_abort(&host->dns_lookup);
};
struct http_client_host {
+ struct http_client_host *prev, *next;
+
struct http_client *client;
char *name;
struct connection_list *conn_list;
HASH_TABLE_TYPE(http_client_host) hosts;
+ struct http_client_host *hosts_list;
HASH_TABLE_TYPE(http_client_peer) peers;
unsigned int pending_requests;
};
{
struct http_client *client = *_client;
struct hash_iterate_context *iter;
- const char *hostname;
struct http_client_host *host;
const struct http_client_peer_addr *addr;
struct http_client_peer *peer;
hash_table_destroy(&client->peers);
/* free hosts */
- iter = hash_table_iterate_init(client->hosts);
- while (hash_table_iterate(iter, client->hosts, &hostname, &host)) {
+ while (client->hosts_list != NULL) {
+ host = client->hosts_list;
http_client_host_free(&host);
}
- hash_table_iterate_deinit(&iter);
hash_table_destroy(&client->hosts);
connection_list_deinit(&client->conn_list);
/* move dns lookups */
if (client->set.dns_client_socket_path != '\0') {
- struct hash_iterate_context *iter;
struct http_client_host *host;
- const char *hostname;
- iter = hash_table_iterate_init(client->hosts);
- while (hash_table_iterate(iter, client->hosts, &hostname, &host)) {
+ for (host = client->hosts_list; host != NULL; host = host->next)
http_client_host_switch_ioloop(host);
- }
- hash_table_iterate_deinit(&iter);
}
}