From 23925c1992418f28d498d2cc88077578ce66b56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E5=AE=87?= Date: Sat, 6 Dec 2025 09:37:12 +0000 Subject: [PATCH] update src/ubsocket/brpc/brpc_file_descriptor.h. ubsocket: fix incorrect rollback logic when flow control triggered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 华宇 --- src/ubsocket/brpc/brpc_file_descriptor.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ubsocket/brpc/brpc_file_descriptor.h b/src/ubsocket/brpc/brpc_file_descriptor.h index 769f77c..17959fe 100644 --- a/src/ubsocket/brpc/brpc_file_descriptor.h +++ b/src/ubsocket/brpc/brpc_file_descriptor.h @@ -1474,11 +1474,12 @@ private: return poll_num; } - ALWAYS_INLINE uint16_t HandleBadQBuf(umq_buf_t *head_qbuf, umq_buf_t *bad_qbuf, uint16_t unsolicited_wr_num, + ALWAYS_INLINE uint32_t HandleBadQBuf(umq_buf_t *head_qbuf, umq_buf_t *bad_qbuf, uint16_t unsolicited_wr_num, uint32_t unsolicited_bytes, uint16_t unsignaled_wr_num) { umq_buf_t *cur_qbuf = head_qbuf; umq_buf_t *last_qbuf = nullptr; + umq_buf_t *head_qbuf_ = head_qbuf; uint32_t wr_cnt = 0; uint16_t _unsolicited_wr_num = unsolicited_wr_num; uint32_t _unsolicited_bytes = unsolicited_bytes; @@ -1513,7 +1514,9 @@ private: } if (buf_pro->flag.bs.complete_enable == 1) { - QBUF_LIST_FIRST(&m_tx.m_head_buf) = cur_qbuf; + /* If the last successfully posted wr has 'complete_enable' set, it means no need to cache + * the posted qbuf list anymore, then reset head to nullptr */ + head_qbuf_ = (cur_qbuf != bad_qbuf) ? cur_qbuf : nullptr; } wr_cnt++; @@ -1524,8 +1527,11 @@ private: m_tx.m_unsignaled_wr_num = _unsignaled_wr_num; m_tx.m_window_size -= wr_cnt; + QBUF_LIST_FIRST(&m_tx.m_head_buf) = head_qbuf_; if (last_qbuf != nullptr) { - QBUF_LIST_FIRST(&m_tx.m_tail_buf) = last_qbuf; + /* If head set to nullptr, it means no need to cache the posted qbuf list anymore, reset head + * to nullptr as well */ + QBUF_LIST_FIRST(&m_tx.m_tail_buf) = (head_qbuf_ == nullptr) ? nullptr : last_qbuf; QBUF_LIST_NEXT(last_qbuf) = nullptr; } @@ -1533,7 +1539,7 @@ private: return total_size; } - ALWAYS_INLINE uint16_t HandleBadQBuf(umq_buf_t *head_qbuf, umq_buf_t *bad_qbuf) + ALWAYS_INLINE uint32_t HandleBadQBuf(umq_buf_t *head_qbuf, umq_buf_t *bad_qbuf) { umq_buf_t *cur_qbuf = head_qbuf; umq_buf_t *last_qbuf = nullptr; -- Gitee