Skip to content

Pubsub hp #1483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void reserve(int messages, int bytes) throws CloudPubsubFlowControlException {
// Will always allow to send a message even if it is larger than the flow control limit,
// if it doesn't then it will deadlock the thread.
if (outstandingByteCount != null) {
int permitsToDraw = maxOutstandingBytes.get() > bytes ? bytes : maxOutstandingBytes.get();
int permitsToDraw = Math.min(bytes, maxOutstandingBytes.get());
if (!failOnLimits) {
outstandingByteCount.acquireUninterruptibly(permitsToDraw);
} else if (!outstandingByteCount.tryAcquire(permitsToDraw)) {
Expand All @@ -76,7 +76,7 @@ void release(int messages, int bytes) {
}
if (outstandingByteCount != null) {
// Need to return at most as much bytes as it can be drawn.
int permitsToReturn = maxOutstandingBytes.get() > bytes ? bytes : maxOutstandingBytes.get();
int permitsToReturn = Math.min(bytes, maxOutstandingBytes.get());
outstandingByteCount.release(permitsToReturn);
}
}
Expand Down
Loading