mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 17:17:06 +02:00
MAJOR: peers: peers protocol version 2.0
This patch does'nt add any new feature: the functional behavior is the same than version 1.0. Technical differences: In this version all updates on different stick tables are multiplexed on the same tcp session. There is only one established tcp session per peer whereas in first version there was one established tcp session per peer and per stick table. Messages format was reviewed to be more evolutive and to support further types of data exchange such as SSL sessions or other sticktable's data types (currently only the sticktable's server id is supported).
This commit is contained in:
parent
b8cdf52da0
commit
b3971ab062
@ -28,6 +28,7 @@
|
|||||||
#include <types/stream.h>
|
#include <types/stream.h>
|
||||||
#include <types/peers.h>
|
#include <types/peers.h>
|
||||||
|
|
||||||
|
void peers_init_sync(struct peers *peers);
|
||||||
void peers_register_table(struct peers *, struct stktable *table);
|
void peers_register_table(struct peers *, struct stktable *table);
|
||||||
void peers_setup_frontend(struct proxy *fe);
|
void peers_setup_frontend(struct proxy *fe);
|
||||||
|
|
||||||
|
@ -35,40 +35,23 @@
|
|||||||
#include <common/tools.h>
|
#include <common/tools.h>
|
||||||
#include <eb32tree.h>
|
#include <eb32tree.h>
|
||||||
|
|
||||||
struct peer_session {
|
|
||||||
struct shared_table *table; /* shared table */
|
|
||||||
struct peer *peer; /* current peer */
|
|
||||||
struct stream *stream; /* current transport stream */
|
|
||||||
struct appctx *appctx; /* the appctx running it */
|
|
||||||
unsigned int flags; /* peer session flags */
|
|
||||||
unsigned int statuscode; /* current/last session status code */
|
|
||||||
unsigned int update; /* current peer acked update */
|
|
||||||
unsigned int pushack; /* last commited update to ack */
|
|
||||||
unsigned int lastack; /* last acked update */
|
|
||||||
unsigned int lastpush; /* last pushed update */
|
|
||||||
unsigned int confirm; /* confirm message counter */
|
|
||||||
unsigned int pushed; /* equal to last pushed data or to table local update in case of total push
|
|
||||||
* or to teaching_origin if teaching is ended */
|
|
||||||
unsigned int reconnect; /* next connect timer */
|
|
||||||
unsigned int teaching_origin; /* resync teaching origine update */
|
|
||||||
struct peer_session *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct shared_table {
|
struct shared_table {
|
||||||
struct stktable *table; /* stick table to sync */
|
struct stktable *table; /* stick table to sync */
|
||||||
struct task *sync_task; /* main sync task */
|
int local_id;
|
||||||
struct sig_handler *sighandler; /* signal handler */
|
int remote_id;
|
||||||
struct peer_session *local_session; /* local peer session */
|
int flags;
|
||||||
struct peer_session *sessions; /* peer sessions list */
|
uint64_t remote_data;
|
||||||
unsigned int flags; /* current table resync state */
|
unsigned int last_acked;
|
||||||
unsigned int resync_timeout; /* resync timeout timer */
|
unsigned int last_pushed;
|
||||||
|
unsigned int last_get;
|
||||||
|
unsigned int teaching_origin;
|
||||||
|
unsigned int update;
|
||||||
struct shared_table *next; /* next shared table in list */
|
struct shared_table *next; /* next shared table in list */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct peer {
|
struct peer {
|
||||||
int local; /* proxy state */
|
int local; /* proxy state */
|
||||||
char *id;
|
char *id;
|
||||||
struct peers *peers;
|
|
||||||
struct {
|
struct {
|
||||||
const char *file; /* file where the section appears */
|
const char *file; /* file where the section appears */
|
||||||
int line; /* line where the section appears */
|
int line; /* line where the section appears */
|
||||||
@ -78,6 +61,15 @@ struct peer {
|
|||||||
struct protocol *proto; /* peer address protocol */
|
struct protocol *proto; /* peer address protocol */
|
||||||
struct xprt_ops *xprt; /* peer socket operations at transport layer */
|
struct xprt_ops *xprt; /* peer socket operations at transport layer */
|
||||||
void *sock_init_arg; /* socket operations's opaque init argument if needed */
|
void *sock_init_arg; /* socket operations's opaque init argument if needed */
|
||||||
|
unsigned int flags; /* peer session flags */
|
||||||
|
unsigned int statuscode; /* current/last session status code */
|
||||||
|
unsigned int reconnect; /* next connect timer */
|
||||||
|
unsigned int confirm; /* confirm message counter */
|
||||||
|
struct stream *stream; /* current transport stream */
|
||||||
|
struct appctx *appctx; /* the appctx running it */
|
||||||
|
struct shared_table *remote_table;
|
||||||
|
struct shared_table *last_local_table;
|
||||||
|
struct shared_table *tables;
|
||||||
struct peer *next; /* next peer in the list */
|
struct peer *next; /* next peer in the list */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,15 +77,19 @@ struct peer {
|
|||||||
struct peers {
|
struct peers {
|
||||||
int state; /* proxy state */
|
int state; /* proxy state */
|
||||||
char *id; /* peer section name */
|
char *id; /* peer section name */
|
||||||
|
struct task *sync_task; /* main sync task */
|
||||||
|
struct sig_handler *sighandler; /* signal handler */
|
||||||
struct peer *remote; /* remote peers list */
|
struct peer *remote; /* remote peers list */
|
||||||
|
struct peer *local; /* local peer list */
|
||||||
struct proxy *peers_fe; /* peer frontend */
|
struct proxy *peers_fe; /* peer frontend */
|
||||||
struct {
|
struct {
|
||||||
const char *file; /* file where the section appears */
|
const char *file; /* file where the section appears */
|
||||||
int line; /* line where the section appears */
|
int line; /* line where the section appears */
|
||||||
} conf; /* config information */
|
} conf; /* config information */
|
||||||
struct shared_table *tables; /* registered shared tables */
|
|
||||||
time_t last_change;
|
time_t last_change;
|
||||||
struct peers *next; /* next peer section */
|
struct peers *next; /* next peer section */
|
||||||
|
unsigned int flags; /* current peers section resync state */
|
||||||
|
unsigned int resync_timeout; /* resync timeout timer */
|
||||||
int count; /* total of peers */
|
int count; /* total of peers */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1986,7 +1986,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
|||||||
curpeers->count++;
|
curpeers->count++;
|
||||||
newpeer->next = curpeers->remote;
|
newpeer->next = curpeers->remote;
|
||||||
curpeers->remote = newpeer;
|
curpeers->remote = newpeer;
|
||||||
newpeer->peers = curpeers;
|
|
||||||
newpeer->conf.file = strdup(file);
|
newpeer->conf.file = strdup(file);
|
||||||
newpeer->conf.line = linenum;
|
newpeer->conf.line = linenum;
|
||||||
|
|
||||||
@ -2030,6 +2029,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
|||||||
if (strcmp(newpeer->id, localpeer) == 0) {
|
if (strcmp(newpeer->id, localpeer) == 0) {
|
||||||
/* Current is local peer, it define a frontend */
|
/* Current is local peer, it define a frontend */
|
||||||
newpeer->local = 1;
|
newpeer->local = 1;
|
||||||
|
peers->local = newpeer;
|
||||||
|
|
||||||
if (!curpeers->peers_fe) {
|
if (!curpeers->peers_fe) {
|
||||||
if ((curpeers->peers_fe = calloc(1, sizeof(struct proxy))) == NULL) {
|
if ((curpeers->peers_fe = calloc(1, sizeof(struct proxy))) == NULL) {
|
||||||
@ -8397,6 +8397,7 @@ int check_config_validity()
|
|||||||
curpeers->peers_fe = NULL;
|
curpeers->peers_fe = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
peers_init_sync(curpeers);
|
||||||
last = &curpeers->next;
|
last = &curpeers->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
1580
src/peers.c
1580
src/peers.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user