]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Reformat http-client-private.h.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 20 Mar 2018 19:59:07 +0000 (20:59 +0100)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 27 Aug 2020 09:36:36 +0000 (11:36 +0200)
src/lib-http/http-client-private.h

index 90aa8f9c62b25f9c08743afeb5a4bce936a5fcb5..d6c854e14e878c588acdce85737edff3b931f042 100644 (file)
@@ -29,26 +29,19 @@ struct http_client_queue;
 struct http_client_host_shared;
 struct http_client_host;
 
-ARRAY_DEFINE_TYPE(http_client_request,
-       struct http_client_request *);
-ARRAY_DEFINE_TYPE(http_client_connection,
-       struct http_client_connection *);
-ARRAY_DEFINE_TYPE(http_client_peer,
-       struct http_client_peer *);
-ARRAY_DEFINE_TYPE(http_client_peer_shared,
-       struct http_client_peer_shared *);
-ARRAY_DEFINE_TYPE(http_client_peer_pool,
-       struct http_client_peer_pool *);
-ARRAY_DEFINE_TYPE(http_client_queue,
-       struct http_client_queue *);
-ARRAY_DEFINE_TYPE(http_client_host,
-       struct http_client_host_shared *);
+ARRAY_DEFINE_TYPE(http_client_request, struct http_client_request *);
+ARRAY_DEFINE_TYPE(http_client_connection, struct http_client_connection *);
+ARRAY_DEFINE_TYPE(http_client_peer, struct http_client_peer *);
+ARRAY_DEFINE_TYPE(http_client_peer_shared, struct http_client_peer_shared *);
+ARRAY_DEFINE_TYPE(http_client_peer_pool, struct http_client_peer_pool *);
+ARRAY_DEFINE_TYPE(http_client_queue, struct http_client_queue *);
+ARRAY_DEFINE_TYPE(http_client_host, struct http_client_host_shared *);
 
 HASH_TABLE_DEFINE_TYPE(http_client_peer_shared,
-       const struct http_client_peer_addr *,
-       struct http_client_peer_shared *);
-HASH_TABLE_DEFINE_TYPE(http_client_host_shared,
-       const char *, struct http_client_host_shared *);
+                      const struct http_client_peer_addr *,
+                      struct http_client_peer_shared *);
+HASH_TABLE_DEFINE_TYPE(http_client_host_shared, const char *,
+                      struct http_client_host_shared *);
 
 enum http_client_peer_addr_type {
        HTTP_CLIENT_PEER_ADDR_HTTP = 0,
@@ -197,21 +190,21 @@ struct http_client_connection {
        struct ioloop *last_ioloop;
        struct io_wait_timer *io_wait_timer;
 
-       /* requests that have been sent, waiting for response */
+       /* Requests that have been sent, waiting for response */
        ARRAY_TYPE(http_client_request) request_wait_list;
 
-       bool connected:1;           /* connection is connected */
-       bool tunneling:1;           /* last sent request turns this
+       bool connected:1;           /* Connection is connected */
+       bool tunneling:1;           /* Last sent request turns this
                                       connection into tunnel */
-       bool connect_succeeded:1;   /* connection succeeded including SSL */
-       bool connect_failed:1;      /* connection failed */
-       bool lost_prematurely:1;    /* lost connection before receiving any data */
+       bool connect_succeeded:1;   /* Connection succeeded including SSL */
+       bool connect_failed:1;      /* Connection failed */
+       bool lost_prematurely:1;    /* Lost connection before receiving any data */
        bool closing:1;
        bool disconnected:1;
        bool close_indicated:1;
-       bool output_locked:1;       /* output is locked; no pipelining */
-       bool output_broken:1;       /* output is broken; no more requests */
-       bool in_req_callback:1;     /* performing request callback (busy) */
+       bool output_locked:1;       /* Output is locked; no pipelining */
+       bool output_broken:1;       /* Output is broken; no more requests */
+       bool in_req_callback:1;     /* Performing request callback (busy) */
        bool debug:1;
 };
 
@@ -231,17 +224,17 @@ struct http_client_peer_shared {
        struct http_client_peer *peers_list;
        unsigned int peers_count;
 
-       /* connection retry */
+       /* Connection retry */
        struct timeval last_failure;
        struct timeout *to_backoff;
        unsigned int backoff_initial_time_msecs;
        unsigned int backoff_current_time_msecs;
        unsigned int backoff_max_time_msecs;
 
-       bool no_payload_sync:1;  /* expect: 100-continue failed before */
-       bool seen_100_response:1;/* expect: 100-continue succeeded before */
-       bool allows_pipelining:1;/* peer is known to allow persistent
-                                   connections */
+       bool no_payload_sync:1;   /* Expect: 100-continue failed before */
+       bool seen_100_response:1; /* Expect: 100-continue succeeded before */
+       bool allows_pipelining:1; /* Peer is known to allow persistent
+                                    connections */
 };
 
 struct http_client_peer_pool {
@@ -250,21 +243,21 @@ struct http_client_peer_pool {
        struct http_client_peer_pool *prev, *next;
        struct event *event;
 
-       /* all connections to this peer */
+       /* All connections to this peer */
        ARRAY_TYPE(http_client_connection) conns;
 
-       /* pending connections (not ready connecting) */
+       /* Pending connections (not ready connecting) */
        ARRAY_TYPE(http_client_connection) pending_conns;
 
-       /* available connections to this peer */
+       /* Available connections to this peer */
        ARRAY_TYPE(http_client_connection) idle_conns;
 
-       /* distinguishing settings for these connections */
+       /* Distinguishing settings for these connections */
        struct ssl_iostream_context *ssl_ctx;
        char *rawlog_dir;
        struct pcap_output *pcap_output;
 
-       bool destroyed:1;        /* peer pool is being destroyed */
+       bool destroyed:1;         /* Peer pool is being destroyed */
 };
 
 struct http_client_peer {
@@ -278,21 +271,21 @@ struct http_client_peer {
        struct http_client_peer_pool *ppool;
        struct event *event;
 
-       /* queues using this peer */
+       /* Queues using this peer */
        ARRAY_TYPE(http_client_queue) queues;
 
-       /* active connections to this peer */
+       /* Active connections to this peer */
        ARRAY_TYPE(http_client_connection) conns;
-       /* pending connections (not ready connecting) */
+       /* Pending connections (not ready connecting) */
        ARRAY_TYPE(http_client_connection) pending_conns;
 
-       /* zero time-out for consolidating request handling */
+       /* Zero time-out for consolidating request handling */
        struct timeout *to_req_handling;
 
-       bool connect_failed:1;   /* last connection attempt failed */
-       bool connect_backoff:1;  /* peer is waiting for backoff timout*/
-       bool disconnected:1;     /* peer is already disconnected */
-       bool handling_requests:1;/* currently running request handler */
+       bool connect_failed:1;    /* Last connection attempt failed */
+       bool connect_backoff:1;   /* Peer is waiting for backoff timout*/
+       bool disconnected:1;      /* Peer is already disconnected */
+       bool handling_requests:1; /* Currently running request handler */
 };
 
 struct http_client_queue {
@@ -306,9 +299,9 @@ struct http_client_queue {
        struct http_client_peer_addr addr;
        char *addr_name;
 
-       /* current index in host->ips */
+       /* Current index in host->ips */
        unsigned int ips_connect_idx;
-       /* the first IP that started the current round of connection attempts.
+       /* The first IP that started the current round of connection attempts.
           initially 0, and later set to the ip index of the last successful
           connected IP */
        unsigned int ips_connect_start_idx;
@@ -316,21 +309,21 @@ struct http_client_queue {
        struct timeval first_connect_time;
        unsigned int connect_attempts;
 
-       /* peers we are trying to connect to;
+       /* Peers we are trying to connect to;
           this can be more than one when soft connect timeouts are enabled */
        ARRAY_TYPE(http_client_peer) pending_peers;
 
-       /* currently active peer */
+       /* Currently active peer */
        struct http_client_peer *cur_peer;
 
-       /* all requests associated to this queue
+       /* All requests associated to this queue
           (ordered by earliest timeout first) */
        ARRAY_TYPE(http_client_request) requests; 
 
-       /* delayed requests waiting to be released after delay */
+       /* Delayed requests waiting to be released after delay */
        ARRAY_TYPE(http_client_request) delayed_requests;
 
-       /* requests pending in queue to be picked up by connections */
+       /* Requests pending in queue to be picked up by connections */
        ARRAY_TYPE(http_client_request) queued_requests, queued_urgent_requests;
 
        struct timeout *to_connect, *to_request, *to_delayed;
@@ -343,21 +336,21 @@ struct http_client_host_shared {
        char *name;
        struct event *event;
 
-       /* the ip addresses DNS returned for this host */
+       /* The ip addresses DNS returned for this host */
        unsigned int ips_count;
        struct ip_addr *ips;
        struct timeval ips_timeout;
 
-       /* private instance for each client that uses this host */
+       /* Private instance for each client that uses this host */
        struct http_client_host *hosts_list;
 
-       /* active DNS lookup */
+       /* Active DNS lookup */
        struct dns_lookup *dns_lookup;
 
-       /* timeouts */
+       /* Timeouts */
        struct timeout *to_idle;
 
-       bool destroyed:1;       /* shared host object is being destroyed */
+       bool destroyed:1;       /* Shared host object is being destroyed */
        bool unix_local:1;
        bool explicit_ip:1;
 };
@@ -369,7 +362,7 @@ struct http_client_host {
        struct http_client *client;
        struct http_client_host *client_prev, *client_next;
 
-       /* separate queue for each host port */
+       /* Separate queue for each host port */
        ARRAY_TYPE(http_client_queue) queues;
 };
 
@@ -384,7 +377,7 @@ struct http_client {
        struct ioloop *ioloop;
        struct ssl_iostream_context *ssl_ctx;
 
-       /* list of failed requests that are waiting for ioloop */
+       /* List of failed requests that are waiting for ioloop */
        ARRAY(struct http_client_request *) delayed_failing_requests;
        struct timeout *to_failing_requests;
 
@@ -460,10 +453,12 @@ http_client_peer_addr2str(const struct http_client_peer_addr *addr)
        case HTTP_CLIENT_PEER_ADDR_RAW:
                if (addr->a.tcp.ip.family == AF_INET6) {
                        return t_strdup_printf("[%s]:%u",
-                               net_ip2addr(&addr->a.tcp.ip), addr->a.tcp.port);
+                                              net_ip2addr(&addr->a.tcp.ip),
+                                              addr->a.tcp.port);
                }
                return t_strdup_printf("%s:%u",
-                       net_ip2addr(&addr->a.tcp.ip), addr->a.tcp.port);
+                                      net_ip2addr(&addr->a.tcp.ip),
+                                      addr->a.tcp.port);
        case HTTP_CLIENT_PEER_ADDR_UNIX:
                return t_strdup_printf("unix:%s", addr->a.un.path);
        default:
@@ -483,8 +478,7 @@ http_client_request_to_proxy(const struct http_client_request *req)
        return (req->host_url != &req->origin_url);
 }
 
-const char *
-http_client_request_label(struct http_client_request *req);
+const char *http_client_request_label(struct http_client_request *req);
 
 void http_client_request_ref(struct http_client_request *req);
 /* Returns FALSE if unrefing destroyed the request entirely */
@@ -492,26 +486,27 @@ bool http_client_request_unref(struct http_client_request **_req);
 void http_client_request_destroy(struct http_client_request **_req);
 
 void http_client_request_get_peer_addr(const struct http_client_request *req,
-       struct http_client_peer_addr *addr);
+                                      struct http_client_peer_addr *addr);
 enum http_response_payload_type
 http_client_request_get_payload_type(struct http_client_request *req);
-int http_client_request_send(struct http_client_request *req,
-                           bool pipelined);
+int http_client_request_send(struct http_client_request *req, bool pipelined);
 int http_client_request_send_more(struct http_client_request *req,
                                  bool pipelined);
+
 bool http_client_request_callback(struct http_client_request *req,
-       struct http_response *response);
+                                 struct http_response *response);
 void http_client_request_connect_callback(struct http_client_request *req,
-                            const struct http_client_tunnel *tunnel,
-                            struct http_response *response);
+                                         const struct http_client_tunnel *tunnel,
+                                         struct http_response *response);
+
 void http_client_request_resubmit(struct http_client_request *req);
 void http_client_request_retry(struct http_client_request *req,
-       unsigned int status, const char *error);
+                              unsigned int status, const char *error);
 void http_client_request_error_delayed(struct http_client_request **_req);
 void http_client_request_error(struct http_client_request **req,
-       unsigned int status, const char *error);
+                              unsigned int status, const char *error);
 void http_client_request_redirect(struct http_client_request *req,
-       unsigned int status, const char *location);
+                                 unsigned int status, const char *location);
 void http_client_request_finish(struct http_client_request *req);
 
 /*
@@ -552,10 +547,10 @@ int http_client_connection_next_request(struct http_client_connection *conn);
 void http_client_connection_check_idle(struct http_client_connection *conn);
 void http_client_connection_switch_ioloop(struct http_client_connection *conn);
 void http_client_connection_start_tunnel(struct http_client_connection **_conn,
-       struct http_client_tunnel *tunnel);
+                                        struct http_client_tunnel *tunnel);
 void http_client_connection_lost_peer(struct http_client_connection *conn);
 void http_client_connection_claim_idle(struct http_client_connection *conn,
-       struct http_client_peer *peer);
+                                      struct http_client_peer *peer);
 
 /*
  * Peer
@@ -563,11 +558,11 @@ void http_client_connection_claim_idle(struct http_client_connection *conn,
 
 /* address */
 
-unsigned int http_client_peer_addr_hash
-       (const struct http_client_peer_addr *peer) ATTR_PURE;
-int http_client_peer_addr_cmp
-       (const struct http_client_peer_addr *peer1,
-               const struct http_client_peer_addr *peer2) ATTR_PURE;
+unsigned int
+http_client_peer_addr_hash(const struct http_client_peer_addr *peer) ATTR_PURE;
+int http_client_peer_addr_cmp(const struct http_client_peer_addr *peer1,
+                             const struct http_client_peer_addr *peer2)
+                             ATTR_PURE;
 
 /* connection pool */
 
@@ -585,35 +580,36 @@ void http_client_peer_shared_ref(struct http_client_peer_shared *pshared);
 void http_client_peer_shared_unref(struct http_client_peer_shared **_pshared);
 void http_client_peer_shared_close(struct http_client_peer_shared **_pshared);
 
-void http_client_peer_shared_switch_ioloop(struct http_client_peer_shared *pshared);
+void http_client_peer_shared_switch_ioloop(
+       struct http_client_peer_shared *pshared);
 
 unsigned int
-http_client_peer_shared_max_connections(struct http_client_peer_shared *pshared);
+http_client_peer_shared_max_connections(
+       struct http_client_peer_shared *pshared);
 
 /* peer */
 
 struct http_client_peer *
 http_client_peer_get(struct http_client *client,
-       const struct http_client_peer_addr *addr);
+                    const struct http_client_peer_addr *addr);
 void http_client_peer_ref(struct http_client_peer *peer);
 bool http_client_peer_unref(struct http_client_peer **_peer);
 void http_client_peer_close(struct http_client_peer **_peer);
 
 bool http_client_peer_have_queue(struct http_client_peer *peer,
-                               struct http_client_queue *queue);
+                                struct http_client_queue *queue);
 void http_client_peer_link_queue(struct http_client_peer *peer,
-       struct http_client_queue *queue);
+                                struct http_client_queue *queue);
 void http_client_peer_unlink_queue(struct http_client_peer *peer,
-                               struct http_client_queue *queue);
+                                  struct http_client_queue *queue);
 struct http_client_request *
-       http_client_peer_claim_request(struct http_client_peer *peer,
-               bool no_urgent);
+http_client_peer_claim_request(struct http_client_peer *peer, bool no_urgent);
 void http_client_peer_trigger_request_handler(struct http_client_peer *peer);
 void http_client_peer_connection_success(struct http_client_peer *peer);
 void http_client_peer_connection_failure(struct http_client_peer *peer,
                                         const char *reason);
 void http_client_peer_connection_lost(struct http_client_peer *peer,
-       bool premature);
+                                     bool premature);
 bool http_client_peer_is_connected(struct http_client_peer *peer);
 unsigned int
 http_client_peer_idle_connections(struct http_client_peer *peer);
@@ -629,31 +625,32 @@ void http_client_peer_switch_ioloop(struct http_client_peer *peer);
 
 struct http_client_queue *
 http_client_queue_get(struct http_client_host *host,
-       const struct http_client_peer_addr *addr);
+                     const struct http_client_peer_addr *addr);
 void http_client_queue_free(struct http_client_queue *queue);
 void http_client_queue_connection_setup(struct http_client_queue *queue);
 unsigned int
 http_client_queue_host_lookup_done(struct http_client_queue *queue);
-void http_client_queue_host_lookup_failure(
-       struct http_client_queue *queue, const char *error);
+void http_client_queue_host_lookup_failure(struct http_client_queue *queue,
+                                          const char *error);
 void http_client_queue_submit_request(struct http_client_queue *queue,
-       struct http_client_request *req);
+                                     struct http_client_request *req);
 void http_client_queue_drop_request(struct http_client_queue *queue,
-       struct http_client_request *req);
+                                   struct http_client_request *req);
 struct http_client_request *
 http_client_queue_claim_request(struct http_client_queue *queue,
-       const struct http_client_peer_addr *addr, bool no_urgent);
+                               const struct http_client_peer_addr *addr,
+                               bool no_urgent);
 unsigned int
 http_client_queue_requests_pending(struct http_client_queue *queue,
-       unsigned int *num_urgent_r) ATTR_NULL(2);
-unsigned int
-http_client_queue_requests_active(struct http_client_queue *queue);
+                                  unsigned int *num_urgent_r) ATTR_NULL(2);
+unsigned int http_client_queue_requests_active(struct http_client_queue *queue);
 void http_client_queue_connection_success(struct http_client_queue *queue,
-                                        struct http_client_peer *peer);
+                                         struct http_client_peer *peer);
 void http_client_queue_connection_failure(struct http_client_queue *queue,
-               struct http_client_peer *peer, const char *reason);
+                                         struct http_client_peer *peer,
+                                         const char *reason);
 void http_client_queue_peer_disconnected(struct http_client_queue *queue,
-       struct http_client_peer *peer);
+                                        struct http_client_peer *peer);
 void http_client_queue_switch_ioloop(struct http_client_queue *queue);
 
 /*
@@ -662,8 +659,7 @@ void http_client_queue_switch_ioloop(struct http_client_queue *queue);
 
 /* host (shared) */
 
-void http_client_host_shared_free(
-       struct http_client_host_shared **_hshared);
+void http_client_host_shared_free(struct http_client_host_shared **_hshared);
 void http_client_host_shared_switch_ioloop(
        struct http_client_host_shared *hshared);
 
@@ -676,8 +672,7 @@ http_client_host_get_ips_count(struct http_client_host *host)
 }
 
 static inline const struct ip_addr *
-http_client_host_get_ip(struct http_client_host *host,
-       unsigned int idx)
+http_client_host_get_ip(struct http_client_host *host, unsigned int idx)
 {
        i_assert(idx < host->shared->ips_count);
        return &host->shared->ips[idx];
@@ -691,27 +686,26 @@ http_client_host_ready(struct http_client_host *host)
 
 struct http_client_host *
 http_client_host_get(struct http_client *client,
-       const struct http_url *host_url);
+                    const struct http_url *host_url);
 void http_client_host_free(struct http_client_host **_host);
 void http_client_host_submit_request(struct http_client_host *host,
-       struct http_client_request *req);
+                                    struct http_client_request *req);
 void http_client_host_switch_ioloop(struct http_client_host *host);
 void http_client_host_check_idle(struct http_client_host *host);
 int http_client_host_refresh(struct http_client_host *host);
 bool http_client_host_get_ip_idx(struct http_client_host *host,
-       const struct ip_addr *ip, unsigned int *idx_r);
+                                const struct ip_addr *ip, unsigned int *idx_r);
 
 /*
  * Client
  */
 
-int http_client_init_ssl_ctx(struct http_client *client,
-       const char **error_r);
+int http_client_init_ssl_ctx(struct http_client *client, const char **error_r);
 
 void http_client_delay_request_error(struct http_client *client,
-       struct http_client_request *req);
+                                    struct http_client_request *req);
 void http_client_remove_request_error(struct http_client *client,
-       struct http_client_request *req);
+                                     struct http_client_request *req);
 
 /*
  * Client shared context