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/peers.h>
|
||||
|
||||
void peers_init_sync(struct peers *peers);
|
||||
void peers_register_table(struct peers *, struct stktable *table);
|
||||
void peers_setup_frontend(struct proxy *fe);
|
||||
|
||||
|
@ -35,40 +35,23 @@
|
||||
#include <common/tools.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 stktable *table; /* stick table to sync */
|
||||
struct task *sync_task; /* main sync task */
|
||||
struct sig_handler *sighandler; /* signal handler */
|
||||
struct peer_session *local_session; /* local peer session */
|
||||
struct peer_session *sessions; /* peer sessions list */
|
||||
unsigned int flags; /* current table resync state */
|
||||
unsigned int resync_timeout; /* resync timeout timer */
|
||||
int local_id;
|
||||
int remote_id;
|
||||
int flags;
|
||||
uint64_t remote_data;
|
||||
unsigned int last_acked;
|
||||
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 peer {
|
||||
int local; /* proxy state */
|
||||
char *id;
|
||||
struct peers *peers;
|
||||
struct {
|
||||
const char *file; /* file where the section appears */
|
||||
int line; /* line where the section appears */
|
||||
@ -78,6 +61,15 @@ struct peer {
|
||||
struct protocol *proto; /* peer address protocol */
|
||||
struct xprt_ops *xprt; /* peer socket operations at transport layer */
|
||||
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 */
|
||||
};
|
||||
|
||||
@ -85,15 +77,19 @@ struct peer {
|
||||
struct peers {
|
||||
int state; /* proxy state */
|
||||
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 *local; /* local peer list */
|
||||
struct proxy *peers_fe; /* peer frontend */
|
||||
struct {
|
||||
const char *file; /* file where the section appears */
|
||||
int line; /* line where the section appears */
|
||||
} conf; /* config information */
|
||||
struct shared_table *tables; /* registered shared tables */
|
||||
time_t last_change;
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -1986,7 +1986,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
||||
curpeers->count++;
|
||||
newpeer->next = curpeers->remote;
|
||||
curpeers->remote = newpeer;
|
||||
newpeer->peers = curpeers;
|
||||
newpeer->conf.file = strdup(file);
|
||||
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) {
|
||||
/* Current is local peer, it define a frontend */
|
||||
newpeer->local = 1;
|
||||
peers->local = newpeer;
|
||||
|
||||
if (!curpeers->peers_fe) {
|
||||
if ((curpeers->peers_fe = calloc(1, sizeof(struct proxy))) == NULL) {
|
||||
@ -8397,6 +8397,7 @@ out_uri_auth_compat:
|
||||
curpeers->peers_fe = NULL;
|
||||
}
|
||||
else {
|
||||
peers_init_sync(curpeers);
|
||||
last = &curpeers->next;
|
||||
continue;
|
||||
}
|
||||
|
1788
src/peers.c
1788
src/peers.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user