Skip to content

Commit

Permalink
pw_transfer: Prevent zero length sleeps on the transfer thread
Browse files Browse the repository at this point in the history
The transfer thread was ignoring the next timeout and always setting
sleepFor to 0.

Fixes: b/236881052
Change-Id: Ic08fd9195f4cb7a315bb791220c99d7c677496cb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/99680
Reviewed-by: Alexei Frolov <frolv@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
  • Loading branch information
255 authored and CQ Bot Account committed Jun 24, 2022
1 parent 84e4983 commit d5b4537
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void enqueueEvent(Event event) {
}

private void handleNextEvent() {
final long sleepFor = Math.min(0, Instant.now().until(getNextTimeout(), TIME_UNIT));
final long sleepFor = TIME_UNIT.between(Instant.now(), getNextTimeout());
try {
Event event = events.poll(sleepFor, POLL_TIME_UNIT);
if (event != null) {
Expand Down

0 comments on commit d5b4537

Please sign in to comment.