http-client-peer.c revision 92e011227877493a1b6a5a38863aabde7e07bd76
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "net.h"
#include "str.h"
#include "hash.h"
#include "array.h"
#include "llist.h"
#include "istream.h"
#include "ostream.h"
#include "iostream-ssl.h"
#include "http-response-parser.h"
#include "http-client-private.h"
/*
* Logging
*/
static inline void
static inline void
const char *format, ...)
{
i_debug("http-client: peer %s:%u: %s",
}
}
const char *format, ...)
{
i_error("http-client: peer %s:%u: %s",
}
/*
* Peer address
*/
unsigned int http_client_peer_addr_hash
(const struct http_client_peer_addr *peer)
{
}
(const struct http_client_peer_addr *peer1,
const struct http_client_peer_addr *peer2)
{
int ret;
return ret;
return 0;
}
/*
* Peer
*/
const char *
{
struct http_client_host *const *host;
return NULL;
/* just return name of initial host */
}
static int
{
struct http_client_connection *conn;
unsigned int i;
for (i = 0; i < count; i++) {
return -1;
}
}
return 0;
}
static unsigned int
{
struct http_client_host *const *host;
num_requests += requests;
num_urgent += urgent;
}
return num_requests;
}
static bool
{
struct http_client_connection *const *conn_idx;
unsigned int num_urgent, new_connections;
/* at this point we already know that a request for this peer is pending
*/
/* find the least busy connection */
if (http_client_connection_is_ready(*conn_idx)) {
if (waiting < min_waiting) {
if (min_waiting == 0) {
/* found idle connection, use it now */
break;
}
}
}
/* count the number of connecting and closing connections */
closing++;
connecting++;
}
/* did we find an idle connection? */
/* yes, use it */
return http_client_connection_next_request(conn);
}
/* no, but can we create a new connection? */
/* no */
return FALSE;
/* pipeline it */
return http_client_connection_next_request(conn);
}
/* yes, determine how many connections to set up */
if (num_urgent == 0) {
new_connections = 1;
} else {
}
/* connection failed */
return FALSE;
/* pipeline it on the least busy connection we found */
return http_client_connection_next_request(conn);
}
/* now we wait until it is connected */
return FALSE;
}
{
while (http_client_peer_next_request(peer)) ;
}
static struct http_client_peer *
const struct http_client_peer_addr *addr)
{
struct http_client_peer *peer;
#ifdef HTTP_BUILD_SSL
struct ssl_iostream_settings ssl_set;
#endif
#ifdef HTTP_BUILD_SSL
const char *source;
return NULL;
}
}
#else
return NULL;
}
#endif
return NULL;
}
return peer;
}
{
struct http_client_connection **conn;
return;
/* make a copy of the connection array; freed connections modify it */
}
#ifdef HTTP_BUILD_SSL
#endif
}
struct http_client_peer *
const struct http_client_peer_addr *addr)
{
struct http_client_peer *peer;
return peer;
}
struct http_client_host *host)
{
struct http_client_host *const *host_idx;
break;
}
}
if (!exists)
(void)http_client_peer_next_request(peer);
}
struct http_client_request *
{
struct http_client_host *const *host_idx;
struct http_client_request *req;
return req;
}
}
return NULL;
}
{
struct http_client_host *const *host;
}
}
}
{
unsigned int num_urgent;
return;
if (!http_client_peer_next_request(peer)) {
}
}
}
{
struct http_client_connection *const *conn_idx;
unsigned int idle = 0;
/* find idle connections */
idle++;
}
return idle;
}