From eb4b4fdb7fa60e0b76af9a0fbb866527328492fb Mon Sep 17 00:00:00 2001 From: hironoshin kaneko Date: Mon, 13 Feb 2017 16:52:31 +0900 Subject: [PATCH] solve freeze problem uses VS Debugger with UNITY. --- include/grpc/grpc.h | 4 +++- src/core/lib/surface/completion_queue.c | 7 ++++++- src/csharp/ext/grpc_csharp_ext.c | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 5e486215e01c5..35345988717c4 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -104,9 +104,11 @@ GRPCAPI grpc_completion_queue *grpc_completion_queue_create(void *reserved); Callers must not call grpc_completion_queue_next and grpc_completion_queue_pluck simultaneously on the same completion queue. */ +typedef void(*magic_for_debug_callback_funcptr)(); GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, - void *reserved); + void *reserved, + magic_for_debug_callback_funcptr callback); /** Blocks until an event with tag 'tag' is available, the completion queue is being shutdown or deadline is reached. diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index 184c1a1a16a61..53c6b33e0ae98 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -371,7 +371,8 @@ static void dump_pending_tags(grpc_completion_queue *cc) {} #endif grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, - gpr_timespec deadline, void *reserved) { + gpr_timespec deadline, void *reserved, + magic_for_debug_callback_funcptr callback) { grpc_event ret; grpc_pollset_worker *worker = NULL; gpr_timespec now; @@ -405,6 +406,10 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT_WITH_FINISH_CHECK( cq_is_next_finished, &is_finished_arg); for (;;) { + if (callback != NULL) { + callback(); + } + if (is_finished_arg.stolen_completion != NULL) { gpr_mu_unlock(cc->mu); grpc_cq_completion *c = is_finished_arg.stolen_completion; diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 946f5872c0ef2..b54ccd66274bb 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -376,8 +376,14 @@ grpcsharp_completion_queue_destroy(grpc_completion_queue *cq) { GPR_EXPORT grpc_event GPR_CALLTYPE grpcsharp_completion_queue_next(grpc_completion_queue *cq) { - return grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); + return grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL, NULL); +} + +GPR_EXPORT grpc_event GPR_CALLTYPE +grpcsharp_completion_queue_next_debuggable(grpc_completion_queue *cq, magic_for_debug_callback_funcptr callback) { + return grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL, callback); } GPR_EXPORT grpc_event GPR_CALLTYPE