Skip to content

Commit 59858bb

Browse files
author
Petr Matousek
committed
credit handling fix#2
1 parent f97224d commit 59858bb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/api/qpid-proton/reactor/handler/TxReceiverHandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ void TxReceiverHandler::on_session_open(session &s) {
138138
s.transaction_declare(*this);
139139
} else {
140140
logger(trace) << "[on_session_open] Transaction is declared: " << s.transaction_id();
141+
credit = batch_size;
141142
if (count != 0 && (processed + batch_size > count)) {
142-
batch_size = count % batch_size;
143+
credit = count % batch_size;
143144
} else if (count == 0) {
144145
batch_size = 1;
146+
credit = batch_size;
145147
}
146-
recv.add_credit(batch_size);
148+
recv.add_credit(credit);
147149
logger(debug) << "[on_session_open] Receiver credit: " << recv.credit();
148150
}
149151
}

src/api/qpid-proton/reactor/handler/TxReceiverHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class TxReceiverHandler : public ReceiverHandler {
157157
int batch_size = 10;
158158
int current_batch = 0;
159159
int processed = 0;
160+
int credit = 0;
160161
string tx_action = "commit";
161162
string tx_endloop_action = "none";
162163
};

0 commit comments

Comments
 (0)