aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2015-09-24 17:25:35 -0700
committerGravatar vjpai <vpai@google.com>2015-09-24 17:25:35 -0700
commit50d653476d4d49978ee3586b1b46b0f247eb60e5 (patch)
tree7bf429e17e09eb629357c9e1d846f39728264783 /src/core
parent7e0289e1c2faf3070d85860aec0369340d0ced33 (diff)
Annotate sleep calls
Diffstat (limited to 'src/core')
-rw-r--r--src/core/support/time_posix.c7
-rw-r--r--src/core/support/time_win32.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index dcecff0d05..889b63a88a 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.c
@@ -41,6 +41,7 @@
#include <unistd.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
+#include "src/core/iomgr/block_annotate.h"
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
@@ -126,6 +127,7 @@ void gpr_sleep_until(gpr_timespec until) {
gpr_timespec now;
gpr_timespec delta;
struct timespec delta_ts;
+ int ns_result;
for (;;) {
/* We could simplify by using clock_nanosleep instead, but it might be
@@ -137,7 +139,10 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
delta_ts = timespec_from_gpr(delta);
- if (nanosleep(&delta_ts, NULL) == 0) {
+ GRPC_IOMGR_START_BLOCKING_REGION;
+ ns_result = nanosleep(&delta_ts, NULL);
+ GRPC_IOMGR_END_BLOCKING_REGION;
+ if (ns_result == 0) {
break;
}
}
diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c
index f794855429..710c7969ba 100644
--- a/src/core/support/time_win32.c
+++ b/src/core/support/time_win32.c
@@ -41,6 +41,8 @@
#include <src/core/support/time_precise.h>
#include <sys/timeb.h>
+#include "src/core/iomgr/block_annotate.h"
+
static LARGE_INTEGER g_start_time;
static double g_time_scale;
@@ -92,7 +94,9 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
sleep_millis =
(DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
+ GRPC_IOMGR_START_BLOCKING_REGION;
Sleep(sleep_millis);
+ GRPC_IOMGR_END_BLOCKING_REGION;
}
}