mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: peers: do not use appctx.ctx anymore
The peers code already uses its own generic pointer, let's move it to svcctx instead of keeping a struct peers in the appctx union.
This commit is contained in:
parent
1eea6657fb
commit
455caef642
@ -91,9 +91,6 @@ struct appctx {
|
|||||||
char storage[APPLET_MAX_SVCCTX]; /* storage of svcctx above */
|
char storage[APPLET_MAX_SVCCTX]; /* storage of svcctx above */
|
||||||
} svc; /* generic storage for most commands */
|
} svc; /* generic storage for most commands */
|
||||||
union {
|
union {
|
||||||
struct {
|
|
||||||
void *ptr; /* current peer or NULL, do not use for something else */
|
|
||||||
} peers; /* used by the peers applet */
|
|
||||||
struct {
|
struct {
|
||||||
int connected;
|
int connected;
|
||||||
struct xref xref; /* cross reference with the Lua object owner. */
|
struct xref xref; /* cross reference with the Lua object owner. */
|
||||||
|
20
src/peers.c
20
src/peers.c
@ -1082,10 +1082,10 @@ void __peer_session_deinit(struct peer *peer)
|
|||||||
*/
|
*/
|
||||||
static void peer_session_release(struct appctx *appctx)
|
static void peer_session_release(struct appctx *appctx)
|
||||||
{
|
{
|
||||||
struct peer *peer = appctx->ctx.peers.ptr;
|
struct peer *peer = appctx->svcctx;
|
||||||
|
|
||||||
TRACE_PROTO("releasing peer session", PEERS_EV_SESSREL, NULL, peer);
|
TRACE_PROTO("releasing peer session", PEERS_EV_SESSREL, NULL, peer);
|
||||||
/* appctx->ctx.peers.ptr is not a peer session */
|
/* appctx->svcctx is not a peer session */
|
||||||
if (appctx->st0 < PEER_SESS_ST_SENDSUCCESS)
|
if (appctx->st0 < PEER_SESS_ST_SENDSUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1286,7 +1286,7 @@ static inline int peer_send_updatemsg(struct shared_table *st, struct appctx *ap
|
|||||||
.updateid = updateid,
|
.updateid = updateid,
|
||||||
.use_identifier = use_identifier,
|
.use_identifier = use_identifier,
|
||||||
.use_timed = use_timed,
|
.use_timed = use_timed,
|
||||||
.peer = appctx->ctx.peers.ptr,
|
.peer = appctx->svcctx,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2842,7 +2842,7 @@ switchstate:
|
|||||||
switch(appctx->st0) {
|
switch(appctx->st0) {
|
||||||
case PEER_SESS_ST_ACCEPT:
|
case PEER_SESS_ST_ACCEPT:
|
||||||
prev_state = appctx->st0;
|
prev_state = appctx->st0;
|
||||||
appctx->ctx.peers.ptr = NULL;
|
appctx->svcctx = NULL;
|
||||||
appctx->st0 = PEER_SESS_ST_GETVERSION;
|
appctx->st0 = PEER_SESS_ST_GETVERSION;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PEER_SESS_ST_GETVERSION:
|
case PEER_SESS_ST_GETVERSION:
|
||||||
@ -2904,7 +2904,7 @@ switchstate:
|
|||||||
}
|
}
|
||||||
curpeer->appctx = appctx;
|
curpeer->appctx = appctx;
|
||||||
curpeer->flags |= PEER_F_ALIVE;
|
curpeer->flags |= PEER_F_ALIVE;
|
||||||
appctx->ctx.peers.ptr = curpeer;
|
appctx->svcctx = curpeer;
|
||||||
appctx->st0 = PEER_SESS_ST_SENDSUCCESS;
|
appctx->st0 = PEER_SESS_ST_SENDSUCCESS;
|
||||||
_HA_ATOMIC_INC(&active_peers);
|
_HA_ATOMIC_INC(&active_peers);
|
||||||
}
|
}
|
||||||
@ -2912,7 +2912,7 @@ switchstate:
|
|||||||
case PEER_SESS_ST_SENDSUCCESS: {
|
case PEER_SESS_ST_SENDSUCCESS: {
|
||||||
prev_state = appctx->st0;
|
prev_state = appctx->st0;
|
||||||
if (!curpeer) {
|
if (!curpeer) {
|
||||||
curpeer = appctx->ctx.peers.ptr;
|
curpeer = appctx->svcctx;
|
||||||
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
||||||
if (curpeer->appctx != appctx) {
|
if (curpeer->appctx != appctx) {
|
||||||
appctx->st0 = PEER_SESS_ST_END;
|
appctx->st0 = PEER_SESS_ST_END;
|
||||||
@ -2937,7 +2937,7 @@ switchstate:
|
|||||||
case PEER_SESS_ST_CONNECT: {
|
case PEER_SESS_ST_CONNECT: {
|
||||||
prev_state = appctx->st0;
|
prev_state = appctx->st0;
|
||||||
if (!curpeer) {
|
if (!curpeer) {
|
||||||
curpeer = appctx->ctx.peers.ptr;
|
curpeer = appctx->svcctx;
|
||||||
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
||||||
if (curpeer->appctx != appctx) {
|
if (curpeer->appctx != appctx) {
|
||||||
appctx->st0 = PEER_SESS_ST_END;
|
appctx->st0 = PEER_SESS_ST_END;
|
||||||
@ -2959,7 +2959,7 @@ switchstate:
|
|||||||
case PEER_SESS_ST_GETSTATUS: {
|
case PEER_SESS_ST_GETSTATUS: {
|
||||||
prev_state = appctx->st0;
|
prev_state = appctx->st0;
|
||||||
if (!curpeer) {
|
if (!curpeer) {
|
||||||
curpeer = appctx->ctx.peers.ptr;
|
curpeer = appctx->svcctx;
|
||||||
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
||||||
if (curpeer->appctx != appctx) {
|
if (curpeer->appctx != appctx) {
|
||||||
appctx->st0 = PEER_SESS_ST_END;
|
appctx->st0 = PEER_SESS_ST_END;
|
||||||
@ -3008,7 +3008,7 @@ switchstate:
|
|||||||
|
|
||||||
prev_state = appctx->st0;
|
prev_state = appctx->st0;
|
||||||
if (!curpeer) {
|
if (!curpeer) {
|
||||||
curpeer = appctx->ctx.peers.ptr;
|
curpeer = appctx->svcctx;
|
||||||
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
HA_SPIN_LOCK(PEER_LOCK, &curpeer->lock);
|
||||||
if (curpeer->appctx != appctx) {
|
if (curpeer->appctx != appctx) {
|
||||||
appctx->st0 = PEER_SESS_ST_END;
|
appctx->st0 = PEER_SESS_ST_END;
|
||||||
@ -3183,7 +3183,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
|
|||||||
goto out_close;
|
goto out_close;
|
||||||
|
|
||||||
appctx->st0 = PEER_SESS_ST_CONNECT;
|
appctx->st0 = PEER_SESS_ST_CONNECT;
|
||||||
appctx->ctx.peers.ptr = (void *)peer;
|
appctx->svcctx = (void *)peer;
|
||||||
|
|
||||||
sess = session_new(p, NULL, &appctx->obj_type);
|
sess = session_new(p, NULL, &appctx->obj_type);
|
||||||
if (!sess) {
|
if (!sess) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user