Skip to content

Commit

Permalink
changed assert with if statement (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
accelerated authored and mfontanini committed Oct 6, 2018
1 parent f458514 commit d77e746
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/cppkafka/utils/buffered_producer.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,10 @@ void BufferedProducer<BufferType>::on_delivery_report(const Message& message) {
if (tracker) {
tracker->should_retry_.set_value(should_retry);
}
// Decrement the expected acks
--pending_acks_;
assert(pending_acks_ != (size_t)-1); // Prevent underflow
// Decrement the expected acks and check to prevent underflow
if (pending_acks_ > 0) {
--pending_acks_;
}
}

} // cppkafka
Expand Down

0 comments on commit d77e746

Please sign in to comment.