aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/pollset_uv.cc
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-11-09 10:50:25 -0800
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-11-09 10:50:25 -0800
commit3a128c098fff4e2fd93f006d7c128735cec62611 (patch)
tree89b32d9c87a4048873bf043762ce096e253982dd /src/core/lib/iomgr/pollset_uv.cc
parent096f883e5e4e2b76c2892d5c29a8ad48dc12dab1 (diff)
parent3a54b8673eed472679b11bb463cfcaf50ba6e282 (diff)
Merge branch 'master' into cc-tsan-1
Diffstat (limited to 'src/core/lib/iomgr/pollset_uv.cc')
-rw-r--r--src/core/lib/iomgr/pollset_uv.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc
index 6b9c53c01c..1d54942c1d 100644
--- a/src/core/lib/iomgr/pollset_uv.cc
+++ b/src/core/lib/iomgr/pollset_uv.cc
@@ -40,7 +40,7 @@ grpc_tracer_flag grpc_trace_fd_refcount =
#endif
struct grpc_pollset {
- uv_timer_t timer;
+ uv_timer_t* timer;
int shutting_down;
};
@@ -78,12 +78,16 @@ void grpc_pollset_global_shutdown(void) {
static void timer_run_cb(uv_timer_t* timer) {}
-static void timer_close_cb(uv_handle_t* handle) { handle->data = (void*)1; }
+static void timer_close_cb(uv_handle_t* handle) {
+ handle->data = (void*)1;
+ gpr_free(handle);
+}
void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
GRPC_UV_ASSERT_SAME_THREAD();
*mu = &grpc_polling_mu;
- uv_timer_init(uv_default_loop(), &pollset->timer);
+ pollset->timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
+ uv_timer_init(uv_default_loop(), pollset->timer);
pollset->shutting_down = 0;
}
@@ -104,11 +108,11 @@ void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
GRPC_UV_ASSERT_SAME_THREAD();
- uv_close((uv_handle_t*)&pollset->timer, timer_close_cb);
+ uv_close((uv_handle_t*)pollset->timer, timer_close_cb);
// timer.data is a boolean indicating that the timer has finished closing
- pollset->timer.data = (void*)0;
+ pollset->timer->data = (void*)0;
if (grpc_pollset_work_run_loop) {
- while (!pollset->timer.data) {
+ while (!pollset->timer->data) {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
@@ -130,11 +134,11 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
/* We special-case timeout=0 so that we don't bother with the timer when
the loop won't block anyway */
if (timeout > 0) {
- uv_timer_start(&pollset->timer, timer_run_cb, timeout, 0);
+ uv_timer_start(pollset->timer, timer_run_cb, timeout, 0);
/* Run until there is some I/O activity or the timer triggers. It doesn't
matter which happens */
uv_run(uv_default_loop(), UV_RUN_ONCE);
- uv_timer_stop(&pollset->timer);
+ uv_timer_stop(pollset->timer);
} else {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}