aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/iomgr/iomgr_libevent.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/iomgr/iomgr_libevent.c b/src/core/iomgr/iomgr_libevent.c
index afaf113a02..6188ab2749 100644
--- a/src/core/iomgr/iomgr_libevent.c
+++ b/src/core/iomgr/iomgr_libevent.c
@@ -185,8 +185,8 @@ int grpc_iomgr_work(gpr_timespec deadline) {
gpr_timespec now = gpr_now();
gpr_timespec next = grpc_alarm_list_next_timeout();
gpr_timespec delay_timespec = gpr_time_sub(deadline, now);
- /* poll for no longer than 100 millis */
- gpr_timespec max_delay = {0, 1000};
+ /* poll for no longer than one second */
+ gpr_timespec max_delay = gpr_time_from_seconds(1);
struct timeval delay;
if (gpr_time_cmp(delay_timespec, gpr_time_0) <= 0) {
@@ -197,6 +197,10 @@ int grpc_iomgr_work(gpr_timespec deadline) {
delay_timespec = max_delay;
}
+ /* Adjust delay to account for the next alarm, if applicable. */
+ delay_timespec = gpr_time_min(
+ delay_timespec, gpr_time_sub(grpc_alarm_list_next_timeout(), now));
+
delay = gpr_timeval_from_timespec(delay_timespec);
if (maybe_do_queue_work() || maybe_do_alarm_work(now, next) ||