aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-06-15 10:10:54 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-06-15 10:10:54 -0700
commit1aab46b28a4f65fd9c99e9b9eb3f6fdeb3c2f5c1 (patch)
treec8f4c9ba3a8a4963577ab910d28540ab653be73d
parent796708dbe23c3a78c0f2a80d7195fa48df9dc79d (diff)
Be better about timeout rounding
-rw-r--r--src/core/iomgr/pollset_multipoller_with_epoll.c5
-rw-r--r--src/core/iomgr/pollset_multipoller_with_poll_posix.c5
-rw-r--r--src/core/iomgr/pollset_posix.c5
3 files changed, 9 insertions, 6 deletions
diff --git a/src/core/iomgr/pollset_multipoller_with_epoll.c b/src/core/iomgr/pollset_multipoller_with_epoll.c
index 8e585a007d..e5e3435feb 100644
--- a/src/core/iomgr/pollset_multipoller_with_epoll.c
+++ b/src/core/iomgr/pollset_multipoller_with_epoll.c
@@ -100,8 +100,9 @@ static int multipoll_with_epoll_pollset_maybe_work(
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout_ms = -1;
} else {
- timeout_ms = gpr_time_to_millis(gpr_time_sub(deadline, now));
- if (timeout_ms <= 0) {
+ timeout_ms = gpr_time_to_millis(
+ gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
+ if (timeout_ms < 0) {
return 1;
}
}
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index 5ee6980732..d21c52c0f0 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -116,8 +116,9 @@ static int multipoll_with_poll_pollset_maybe_work(
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout = -1;
} else {
- timeout = gpr_time_to_millis(gpr_time_sub(deadline, now));
- if (timeout <= 0) {
+ timeout = gpr_time_to_millis(
+ gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
+ if (timeout < 0) {
return 1;
}
}
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index db704b9df1..0fe54c8f1d 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -346,8 +346,9 @@ static int basic_pollset_maybe_work(grpc_pollset *pollset,
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout = -1;
} else {
- timeout = gpr_time_to_millis(gpr_time_sub(deadline, now));
- if (timeout <= 0) {
+ timeout = gpr_time_to_millis(
+ gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
+ if (timeout < 0) {
return 1;
}
}