mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-01 15:51:01 +01:00
EXP: peers: Improve the update list manipulations from peers
This commit is contained in:
parent
43b2955891
commit
97a2907028
35
src/peers.c
35
src/peers.c
@ -1585,14 +1585,20 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p, struct shared_tab
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
el2 = mt_list_lock_next(el1.next);
|
|
||||||
/* el2 = mt_list_try_lock_next(el1.next); */
|
if (el1.next == &st->end->upd || el1.next == &st->table->updates) {
|
||||||
/* if (el2.next == NULL) { */
|
mt_list_unlock_full(&st->last->upd, el1);
|
||||||
/* mt_list_unlock_full(&st->last->upd, el1); */
|
break;
|
||||||
/* applet_have_more_data(appctx); */
|
}
|
||||||
/* ret = -1; */
|
|
||||||
/* break; */
|
/* el2 = mt_list_lock_next(el1.next); */
|
||||||
/* } */
|
el2 = mt_list_try_lock_next(el1.next);
|
||||||
|
if (el2.next == NULL) {
|
||||||
|
mt_list_unlock_full(&st->last->upd, el1);
|
||||||
|
applet_have_more_data(appctx);
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ts = MT_LIST_ELEM(el1.next, typeof(ts), upd);
|
ts = MT_LIST_ELEM(el1.next, typeof(ts), upd);
|
||||||
HA_ATOMIC_INC(&ts->ref_cnt);
|
HA_ATOMIC_INC(&ts->ref_cnt);
|
||||||
@ -1636,7 +1642,7 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p, struct shared_tab
|
|||||||
updates_sent++;
|
updates_sent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 1)
|
if (ret == 1 && MT_LIST_INLIST(&st->end->upd))
|
||||||
MT_LIST_DELETE(&st->end->upd);
|
MT_LIST_DELETE(&st->end->upd);
|
||||||
end:
|
end:
|
||||||
TRACE_LEAVE(PEERS_EV_SESS_IO, appctx, p, st);
|
TRACE_LEAVE(PEERS_EV_SESS_IO, appctx, p, st);
|
||||||
@ -2452,8 +2458,10 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee
|
|||||||
TRACE_PROTO("Resync request message received", PEERS_EV_SESS_IO|PEERS_EV_RX_MSG|PEERS_EV_PROTO_CTRL, appctx, peer);
|
TRACE_PROTO("Resync request message received", PEERS_EV_SESS_IO|PEERS_EV_RX_MSG|PEERS_EV_PROTO_CTRL, appctx, peer);
|
||||||
/* prepare tables for a global push */
|
/* prepare tables for a global push */
|
||||||
for (st = peer->tables; st; st = st->next) {
|
for (st = peer->tables; st; st = st->next) {
|
||||||
|
if (MT_LIST_INLIST(&st->last->upd))
|
||||||
MT_LIST_DELETE(&st->last->upd);
|
MT_LIST_DELETE(&st->last->upd);
|
||||||
MT_LIST_INSERT(&st->table->updates, &st->last->upd);
|
MT_LIST_INSERT(&st->table->updates, &st->last->upd);
|
||||||
|
if (MT_LIST_INLIST(&st->end->upd))
|
||||||
MT_LIST_DELETE(&st->end->upd);
|
MT_LIST_DELETE(&st->end->upd);
|
||||||
MT_LIST_APPEND(&st->table->updates, &st->end->upd);
|
MT_LIST_APPEND(&st->table->updates, &st->end->upd);
|
||||||
st->flags = 0;
|
st->flags = 0;
|
||||||
@ -2499,8 +2507,10 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
peer->flags |= PEER_F_SYNCHED;
|
peer->flags |= PEER_F_SYNCHED;
|
||||||
for (st = peer->tables; st; st = st->next)
|
for (st = peer->tables; st; st = st->next) {
|
||||||
|
if (MT_LIST_INLIST(&st->end->upd))
|
||||||
MT_LIST_DELETE(&st->end->upd);
|
MT_LIST_DELETE(&st->end->upd);
|
||||||
|
}
|
||||||
|
|
||||||
/* reset teaching flags to 0 */
|
/* reset teaching flags to 0 */
|
||||||
peer->flags &= ~PEER_TEACH_FLAGS;
|
peer->flags &= ~PEER_TEACH_FLAGS;
|
||||||
@ -2816,10 +2826,13 @@ static inline void init_connected_peer(struct peer *peer, struct peers *peers)
|
|||||||
st->last_get = st->last_acked = 0;
|
st->last_get = st->last_acked = 0;
|
||||||
st->flags = 0;
|
st->flags = 0;
|
||||||
|
|
||||||
if (!MT_LIST_INLIST(&st->last->upd) || !(peer->flags & PEER_F_SYNCHED)) {
|
if (!MT_LIST_INLIST(&st->last->upd))
|
||||||
|
MT_LIST_INSERT(&st->table->updates, &st->last->upd);
|
||||||
|
else if (!(peer->flags & PEER_F_SYNCHED)) {
|
||||||
MT_LIST_DELETE(&st->last->upd);
|
MT_LIST_DELETE(&st->last->upd);
|
||||||
MT_LIST_INSERT(&st->table->updates, &st->last->upd);
|
MT_LIST_INSERT(&st->table->updates, &st->last->upd);
|
||||||
}
|
}
|
||||||
|
if (MT_LIST_INLIST(&st->end->upd))
|
||||||
MT_LIST_DELETE(&st->end->upd);
|
MT_LIST_DELETE(&st->end->upd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user