MEDIUM: peers: drop then re-acquire the wrlock in peer_send_teachmsgs()

This function maintains the write lock for a while. In practice it does
not need to hold it that long, and some parts could be performed under a
read lock. This patch first drops then re-acquires the write lock at the
function's entry. The purpose is simply to break the end-to-end atomicity
to prove that it has no impact in case something needs to be bisected
later. In fact the write lock is already dropped while calling
peer_send_updatemsg().
This commit is contained in:
Willy Tarreau 2023-07-28 14:03:27 +00:00
parent 4eddf26f58
commit d4f8286e45

View File

@ -1575,8 +1575,10 @@ static inline int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
/* We force new pushed to 1 to force identifier in update message */
new_pushed = 1;
if (!locked)
HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &st->table->lock);
if (locked)
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &st->table->lock);
HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &st->table->lock);
while (1) {
struct stksess *ts;
@ -1633,8 +1635,10 @@ static inline int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
}
out:
if (!locked)
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &st->table->lock);
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &st->table->lock);
if (locked)
HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &st->table->lock);
return ret;
}