MINOR: backend: export get_server_*() functions

This is in preparation for exposing more of the LB internals.
This commit is contained in:
Dragan Dosen 2023-12-27 14:08:08 +01:00 committed by Willy Tarreau
parent bdecff511c
commit 5b1609f9da
2 changed files with 17 additions and 8 deletions

View File

@ -30,6 +30,15 @@
#include <haproxy/stream-t.h> #include <haproxy/stream-t.h>
#include <haproxy/time.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(struct stream *s);
int assign_server_address(struct stream *s); int assign_server_address(struct stream *s);
int assign_server_and_queue(struct stream *s); int assign_server_and_queue(struct stream *s);

View 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, * If any server is found, it will be returned. If no valid server is found,
* NULL is returned. * 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; 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. * 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; unsigned int hash = 0;
int c; 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 returned. If any server is found, it will be returned. If no valid server
* is found, NULL is returned. * 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; unsigned int hash = 0;
const char *start, *end; 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 * 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; unsigned int hash = 0;
struct channel *req = &s->req; 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 * 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). * 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; unsigned int hash = 0;
struct proxy *px = s->be; 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. */ /* 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; unsigned int hash = 0;
struct proxy *px = s->be; 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 /* 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. * 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 proxy *px = s->be;
struct sample *smp; struct sample *smp;
@ -560,7 +560,7 @@ static struct server *get_server_expr(struct stream *s, const struct server *avo
} }
/* random value */ /* 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; unsigned int hash = 0;
struct proxy *px = s->be; struct proxy *px = s->be;