aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/ruby/ext/grpc/rb_call.c9
-rw-r--r--src/ruby/lib/grpc/generic/bidi_call.rb18
2 files changed, 16 insertions, 11 deletions
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c
index c1f5075b52..f62397e79f 100644
--- a/src/ruby/ext/grpc/rb_call.c
+++ b/src/ruby/ext/grpc/rb_call.c
@@ -94,8 +94,13 @@ typedef struct grpc_rb_call {
} grpc_rb_call;
static void destroy_call(grpc_rb_call *call) {
- grpc_call_destroy(call->wrapped);
- grpc_rb_completion_queue_destroy(call->queue);
+ /* Ensure that we only try to destroy the call once */
+ if (call->wrapped != NULL) {
+ grpc_call_destroy(call->wrapped);
+ call->wrapped = NULL;
+ grpc_rb_completion_queue_destroy(call->queue);
+ call->queue = NULL;
+ }
}
/* Destroys a Call. */
diff --git a/src/ruby/lib/grpc/generic/bidi_call.rb b/src/ruby/lib/grpc/generic/bidi_call.rb
index e2a026cacc..425dc3e519 100644
--- a/src/ruby/lib/grpc/generic/bidi_call.rb
+++ b/src/ruby/lib/grpc/generic/bidi_call.rb
@@ -161,7 +161,15 @@ module GRPC
count += 1
payload = @marshal.call(req)
# Fails if status already received
- @call.run_batch(SEND_MESSAGE => payload)
+ begin
+ @call.run_batch(SEND_MESSAGE => payload)
+ rescue GRPC::Core::CallError => e
+ # This is almost definitely caused by a status arriving while still
+ # writing. Don't re-throw the error
+ GRPC.logger.warn('bidi-write-loop: ended with error')
+ GRPC.logger.warn(e)
+ break
+ end
end
GRPC.logger.debug("bidi-write-loop: #{count} writes done")
if is_client
@@ -173,14 +181,6 @@ module GRPC
finished
end
GRPC.logger.debug('bidi-write-loop: finished')
- rescue GRPC::Core::CallError => e
- # This is almost definitely caused by a status arriving while still
- # writing. Don't re-throw the error
- GRPC.logger.warn('bidi-write-loop: ended with error')
- GRPC.logger.warn(e)
- notify_done
- @writes_complete = true
- finished
rescue StandardError => e
GRPC.logger.warn('bidi-write-loop: failed')
GRPC.logger.warn(e)