]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: export get_server_*() functions
authorDragan Dosen <ddosen@haproxy.com>
Wed, 27 Dec 2023 13:08:08 +0000 (14:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Jan 2024 10:44:42 +0000 (11:44 +0100)
This is in preparation for exposing more of the LB internals.

include/haproxy/backend.h
src/backend.c

index 4ab91700370026cb66af2e6dd1895a046c4a2422..a2015dc8116634893f2a62fbd3e9a0046c43b2b0 100644 (file)
 #include <haproxy/stream-t.h>
 #include <haproxy/time.h>
 
+struct server *get_server_sh(struct proxy *px, const char *addr, int len, const struct server *avoid);
+struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, const struct server *avoid);
+struct server *get_server_ph(struct proxy *px, const char *uri, int uri_len, const struct server *avoid);
+struct server *get_server_ph_post(struct stream *s, const struct server *avoid);
+struct server *get_server_hh(struct stream *s, const struct server *avoid);
+struct server *get_server_rch(struct stream *s, const struct server *avoid);
+struct server *get_server_expr(struct stream *s, const struct server *avoid);
+struct server *get_server_rnd(struct stream *s, const struct server *avoid);
+
 int assign_server(struct stream *s);
 int assign_server_address(struct stream *s);
 int assign_server_and_queue(struct stream *s);
index 39d2c75acfb35aceb6ade3566e2cadcdedaab36a..4780c3cfc9c42f762318e68ca43bb6737125b1fc 100644 (file)
@@ -176,7 +176,7 @@ void update_backend_weight(struct proxy *px)
  * If any server is found, it will be returned. If no valid server is found,
  * NULL is returned.
  */
-static struct server *get_server_sh(struct proxy *px, const char *addr, int len, const struct server *avoid)
+struct server *get_server_sh(struct proxy *px, const char *addr, int len, const struct server *avoid)
 {
        unsigned int h, l;
 
@@ -220,7 +220,7 @@ static struct server *get_server_sh(struct proxy *px, const char *addr, int len,
  * algorithm out of a tens because it gave him the best results.
  *
  */
-static struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, const struct server *avoid)
+struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, const struct server *avoid)
 {
        unsigned int hash = 0;
        int c;
@@ -268,7 +268,7 @@ static struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, co
  * is returned. If any server is found, it will be returned. If no valid server
  * is found, NULL is returned.
  */
-static struct server *get_server_ph(struct proxy *px, const char *uri, int uri_len, const struct server *avoid)
+struct server *get_server_ph(struct proxy *px, const char *uri, int uri_len, const struct server *avoid)
 {
        unsigned int hash = 0;
        const char *start, *end;
@@ -327,7 +327,7 @@ static struct server *get_server_ph(struct proxy *px, const char *uri, int uri_l
 /*
  * this does the same as the previous server_ph, but check the body contents
  */
-static struct server *get_server_ph_post(struct stream *s, const struct server *avoid)
+struct server *get_server_ph_post(struct stream *s, const struct server *avoid)
 {
        unsigned int hash = 0;
        struct channel  *req  = &s->req;
@@ -412,7 +412,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server *
  * is found, NULL is returned. When lbprm.arg_opt1 is set, the hash will only
  * apply to the middle part of a domain name ("use_domain_only" option).
  */
-static struct server *get_server_hh(struct stream *s, const struct server *avoid)
+struct server *get_server_hh(struct stream *s, const struct server *avoid)
 {
        unsigned int hash = 0;
        struct proxy    *px   = s->be;
@@ -485,7 +485,7 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
 }
 
 /* RDP Cookie HASH.  */
-static struct server *get_server_rch(struct stream *s, const struct server *avoid)
+struct server *get_server_rch(struct stream *s, const struct server *avoid)
 {
        unsigned int hash = 0;
        struct proxy    *px   = s->be;
@@ -530,7 +530,7 @@ static struct server *get_server_rch(struct stream *s, const struct server *avoi
 /* sample expression HASH. Returns NULL if the sample is not found or if there
  * are no server, relying on the caller to fall back to round robin instead.
  */
-static struct server *get_server_expr(struct stream *s, const struct server *avoid)
+struct server *get_server_expr(struct stream *s, const struct server *avoid)
 {
        struct proxy  *px = s->be;
        struct sample *smp;
@@ -560,7 +560,7 @@ static struct server *get_server_expr(struct stream *s, const struct server *avo
 }
 
 /* random value  */
-static struct server *get_server_rnd(struct stream *s, const struct server *avoid)
+struct server *get_server_rnd(struct stream *s, const struct server *avoid)
 {
        unsigned int hash = 0;
        struct proxy  *px = s->be;