From 5ddbb9d405c01564b935e9ab81ae2833124e0b12 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Jul 2015 15:58:11 -0700 Subject: Allow specific pollers to be woken Currently, if two threads call grpc_completion_queue_pluck on the same completion queue for different tags, there is a 50% chance that we deliver the completion wakeup to the wrong poller - forcing the correct poller to wait until its polling times out before it can return an event up to the application. This change tweaks our polling interfaces so that we can indeed wake a specific poller. Nothing has been performance tuned yet. It's definitely sub-optimal in a number of places. Wakeup file-descriptors should be recycled. We should have a path that avoids calling poll() followed by epoll(). We can probably live without it right at the second though. This code will fail on Windows at least (I'll do that port when I'm in the office and have a Windows machine). --- test/core/iomgr/tcp_server_posix_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/core/iomgr/tcp_server_posix_test.c') diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index f8d0fe8217..b82d7c08b1 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -54,7 +54,7 @@ static void on_connect(void *arg, grpc_endpoint *tcp) { gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); g_nconnects++; - grpc_pollset_kick(&g_pollset); + grpc_pollset_kick(&g_pollset, NULL); gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); } @@ -136,7 +136,8 @@ static void test_connect(int n) { gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { - grpc_pollset_work(&g_pollset, deadline); + grpc_pollset_worker worker; + grpc_pollset_work(&g_pollset, &worker, deadline); } gpr_log(GPR_DEBUG, "wait done"); -- cgit v1.2.3