return;
}
-
- ofs = ds->ofs;
-
HA_RWLOCK_WRLOCK(DNS_LOCK, &ring->lock);
LIST_DEL_INIT(&appctx->wait_entry);
HA_RWLOCK_WRUNLOCK(DNS_LOCK, &ring->lock);
* existing messages before grabbing a reference to a location. This
* value cannot be produced after initialization.
*/
- if (unlikely(ofs == ~0)) {
- ofs = 0;
+ if (unlikely(ds->ofs == ~0)) {
+ ds->ofs = 0;
- HA_ATOMIC_INC(b_peek(buf, ofs));
+ HA_ATOMIC_INC(b_peek(buf, ds->ofs));
}
/* in this loop, ofs always points to the counter byte that precedes
/* we were already there, adjust the offset to be relative to
* the buffer's head and remove us from the counter.
*/
+ ofs = ds->ofs - b_head_ofs(buf);
+ if (ds->ofs < b_head_ofs(buf))
+ ofs += b_size(buf);
+
BUG_ON(ofs >= buf->size);
HA_ATOMIC_DEC(b_peek(buf, ofs));
}
HA_ATOMIC_INC(b_peek(buf, ofs));
- ds->ofs = ofs;
+ ds->ofs = b_peek_ofs(buf, ofs);
}
HA_RWLOCK_RDUNLOCK(DNS_LOCK, &ring->lock);
struct dns_session *ds, *ads;
HA_SPIN_LOCK(DNS_LOCK, &dss->lock);
- ofs = dss->ofs_req;
-
HA_RWLOCK_RDLOCK(DNS_LOCK, &ring->lock);
/* explanation for the initialization below: it would be better to do
* existing messages before grabbing a reference to a location. This
* value cannot be produced after initialization.
*/
- if (unlikely(ofs == ~0)) {
- ofs = 0;
- HA_ATOMIC_INC(b_peek(buf, ofs));
+ if (unlikely(dss->ofs_req == ~0)) {
+ dss->ofs_req = 0;
+ HA_ATOMIC_INC(b_peek(buf, dss->ofs_req));
}
/* we were already there, adjust the offset to be relative to
* the buffer's head and remove us from the counter.
*/
+ ofs = dss->ofs_req - b_head_ofs(buf);
+ if (dss->ofs_req < b_head_ofs(buf))
+ ofs += b_size(buf);
+
BUG_ON(ofs >= buf->size);
HA_ATOMIC_DEC(b_peek(buf, ofs));
}
HA_ATOMIC_INC(b_peek(buf, ofs));
- dss->ofs_req = ofs;
+ dss->ofs_req = b_peek_ofs(buf, ofs);
HA_RWLOCK_RDUNLOCK(DNS_LOCK, &ring->lock);