Fix bug that occasionally caused a call to be deleted twice

pull/6886/head
murgatroid99 9 years ago
parent 67e2525892
commit 00338657d9
  1. 9
      src/ruby/ext/grpc/rb_call.c
  2. 18
      src/ruby/lib/grpc/generic/bidi_call.rb

@ -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. */

@ -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)

Loading…
Cancel
Save