Have grpc_iomgr_work() adjust its poll deadline to account for the next alarm.

This fixes _low_test.py, once we reverse CL 82686562 accidentally reducing poll
timeouts to 1 us.
	Change on 2014/12/23 by klempner <klempner@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82741776
pull/1/merge
klempner 10 years ago committed by Jan Tattermusch
parent d94ad10cf1
commit 55af9b60cc
  1. 8
      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) ||

Loading…
Cancel
Save