http-client-peer.c revision 9dc01e0d10a61cab14867b26bf0d2d1dcf8ad978
/* 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;
return -1;
}
return 0;
}
static bool
{
struct http_client_host *const *host;
return TRUE;
}
return FALSE;
}
static bool
bool urgent)
{
struct http_client_connection *const *conn_idx;
/* 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)
break;
}
}
/* count the number of closing connections */
closing++;
}
/* do we have an idle connection? */
/* yes */
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 */
if (http_client_peer_connect(peer) < 0) {
/* 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;
}
{
/* check urgent requests first */
break;
}
/* check normal requests once we're done */
break;
}
}
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
if (http_client_peer_connect(peer) < 0) {
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)
}
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;
}
}
}
{
return;
else
}
}
{
struct http_client_connection *const *conn_idx;
unsigned int idle = 0;
/* find idle connections */
idle++;
}
return idle;
}