http-client-peer.c revision 035dfd76345a57b69e939ac872eb3dd00598ed0a
/* 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",
}
}
/*
* 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;
}
/*
* Peer
*/
static void
{
unsigned int i;
for (i = 0; i < count; i++) {
(void)http_client_connection_create(peer);
}
}
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;
return FALSE;
/* find the least busy connection */
if (http_client_connection_is_ready(*conn_idx)) {
waiting++;
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 */
/* don't create new connections until the existing ones have
finished connecting successfully. */
new_connections = 0;
} else if (num_urgent == 0) {
} else {
}
/* 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;
return peer;
}
{
struct http_client_connection **conn;
return;
/* make a copy of the connection array; freed connections modify it */
}
}
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)
}
struct http_client_request *
{
struct http_client_host *const *host_idx;
struct http_client_request *req;
return req;
}
}
return NULL;
}
const char *reason)
{
struct http_client_host *const *host;
unsigned int num_urgent;
/* if there are other connections attempting to connect, wait
for them before failing the requests. remember that we had
trouble with connecting so in future we don't try to create
more than one connection until connects work again. */
} else {
failed. a second connect will probably also fail, so just
abort all requests. */
}
}
}
{
unsigned int num_urgent;
return;
/* if there are pending requests, create a new connection for them. */
}
{
struct http_client_connection *const *conn_idx;
unsigned int idle = 0;
/* find idle connections */
idle++;
}
return idle;
}