grpc 1.42.0.pre1-arm64-darwin → 1.60.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/grpc_c.64-ucrt.ruby +0 -0
  3. data/src/ruby/bin/math_pb.rb +24 -18
  4. data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.clang +2 -0
  5. data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.gcc +7 -0
  6. data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.clang +2 -0
  7. data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.gcc +7 -0
  8. data/src/ruby/ext/grpc/ext-export.gcc +1 -1
  9. data/src/ruby/ext/grpc/extconf.rb +174 -27
  10. data/src/ruby/ext/grpc/rb_call.c +63 -39
  11. data/src/ruby/ext/grpc/rb_call_credentials.c +0 -1
  12. data/src/ruby/ext/grpc/rb_channel.c +113 -84
  13. data/src/ruby/ext/grpc/rb_channel.h +1 -0
  14. data/src/ruby/ext/grpc/rb_channel_args.c +19 -2
  15. data/src/ruby/ext/grpc/rb_channel_args.h +4 -0
  16. data/src/ruby/ext/grpc/rb_channel_credentials.c +0 -1
  17. data/src/ruby/ext/grpc/rb_compression_options.c +1 -2
  18. data/src/ruby/ext/grpc/rb_event_thread.c +22 -6
  19. data/src/ruby/ext/grpc/rb_event_thread.h +1 -0
  20. data/src/ruby/ext/grpc/rb_grpc.c +193 -30
  21. data/src/ruby/ext/grpc/rb_grpc.h +8 -2
  22. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +70 -72
  23. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +108 -111
  24. data/src/ruby/ext/grpc/rb_loader.c +6 -2
  25. data/src/ruby/ext/grpc/rb_server.c +69 -49
  26. data/src/ruby/ext/grpc/rb_server_credentials.c +0 -1
  27. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +0 -1
  28. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +0 -1
  29. data/src/ruby/lib/grpc/2.7/grpc_c.bundle +0 -0
  30. data/src/ruby/lib/grpc/3.0/grpc_c.bundle +0 -0
  31. data/src/ruby/lib/grpc/3.1/grpc_c.bundle +0 -0
  32. data/src/ruby/lib/grpc/3.2/grpc_c.bundle +0 -0
  33. data/src/ruby/lib/grpc/errors.rb +1 -1
  34. data/src/ruby/lib/grpc/generic/active_call.rb +16 -15
  35. data/src/ruby/lib/grpc/generic/bidi_call.rb +4 -0
  36. data/src/ruby/lib/grpc/grpc.rb +1 -1
  37. data/src/ruby/lib/grpc/version.rb +1 -1
  38. data/src/ruby/pb/generate_proto_ruby.sh +1 -6
  39. data/src/ruby/pb/grpc/health/v1/health_pb.rb +24 -13
  40. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +24 -3
  41. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +34 -108
  42. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +27 -3
  43. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +22 -0
  44. data/src/ruby/pb/test/client.rb +16 -0
  45. data/src/ruby/spec/channel_spec.rb +5 -43
  46. data/src/ruby/spec/client_server_spec.rb +20 -8
  47. data/src/ruby/spec/generic/active_call_spec.rb +12 -3
  48. data/src/ruby/spec/generic/client_stub_spec.rb +23 -23
  49. data/src/ruby/spec/generic/rpc_server_spec.rb +3 -3
  50. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  51. data/src/ruby/spec/user_agent_spec.rb +1 -1
  52. metadata +61 -60
  53. data/src/ruby/lib/grpc/2.4/grpc_c.bundle +0 -0
  54. data/src/ruby/lib/grpc/2.5/grpc_c.bundle +0 -0
  55. data/src/ruby/lib/grpc/2.6/grpc_c.bundle +0 -0
  56. /data/{grpc_c.32.ruby → grpc_c.32-msvcrt.ruby} +0 -0
  57. /data/{grpc_c.64.ruby → grpc_c.64-msvcrt.ruby} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a3f43b745189a7f5fc2d1ed80975fba571dd148d9d0dc052edf3f9c7e121474
4
- data.tar.gz: 36a667c816e614f0c8512f16d338d0c5773c2f7cd2ebbf995e3dd00df2ea03ac
3
+ metadata.gz: 03b702b48447c0ddb5e87210d32e4b6057f6bc8a3d71c4a6669398cad6a97673
4
+ data.tar.gz: 37ea8f451c11d6f0a2cd2f21e9c3c529928b670f6a8c9b6f059eb8982519a677
5
5
  SHA512:
6
- metadata.gz: 80c10cc51235057a3667d596e6e608923ef9e35ae1d573d2bd147877c92eb75e8189958cfc1bcd55e300bfc961c58bd2e8932f1775b29aa7a0a580feaeac1fda
7
- data.tar.gz: c3f9468165a426417883075811d1fe70dc621b92ac7ddb656db8313fb2a4917d385dcff6373d2e60e85397c50e751550a78dc26535ccac9fc697ba04da354ea0
6
+ metadata.gz: 9f742bf3d093cacc129c3aa1350f0394c62a1d274c3776a63eef85242177b8cfdb97cd52ebd1cacdfd8b4bc28008665c65338d785bc7bc5c885e69582c4343b4
7
+ data.tar.gz: 81503c83b4e067d4a45e179c277a0648dd5dde894f46afe88204d2c65c97f2b1cd3c460ec04442b82cc6225ebc54431165269f23c57cb23871495d98896ecbf5
File without changes
@@ -1,28 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: math.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("math.proto", :syntax => :proto3) do
8
- add_message "math.DivArgs" do
9
- optional :dividend, :int64, 1
10
- optional :divisor, :int64, 2
11
- end
12
- add_message "math.DivReply" do
13
- optional :quotient, :int64, 1
14
- optional :remainder, :int64, 2
15
- end
16
- add_message "math.FibArgs" do
17
- optional :limit, :int64, 1
18
- end
19
- add_message "math.Num" do
20
- optional :num, :int64, 1
21
- end
22
- add_message "math.FibReply" do
23
- optional :count, :int64, 1
7
+
8
+ descriptor_data = "\n\nmath.proto\x12\x04math\",\n\x07\x44ivArgs\x12\x10\n\x08\x64ividend\x18\x01 \x01(\x03\x12\x0f\n\x07\x64ivisor\x18\x02 \x01(\x03\"/\n\x08\x44ivReply\x12\x10\n\x08quotient\x18\x01 \x01(\x03\x12\x11\n\tremainder\x18\x02 \x01(\x03\"\x18\n\x07\x46ibArgs\x12\r\n\x05limit\x18\x01 \x01(\x03\"\x12\n\x03Num\x12\x0b\n\x03num\x18\x01 \x01(\x03\"\x19\n\x08\x46ibReply\x12\r\n\x05\x63ount\x18\x01 \x01(\x03\x32\xa4\x01\n\x04Math\x12&\n\x03\x44iv\x12\r.math.DivArgs\x1a\x0e.math.DivReply\"\x00\x12.\n\x07\x44ivMany\x12\r.math.DivArgs\x1a\x0e.math.DivReply\"\x00(\x01\x30\x01\x12#\n\x03\x46ib\x12\r.math.FibArgs\x1a\t.math.Num\"\x00\x30\x01\x12\x1f\n\x03Sum\x12\t.math.Num\x1a\t.math.Num\"\x00(\x01\x62\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
24
28
  end
25
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
26
32
  end
27
33
 
28
34
  module Math
@@ -0,0 +1,2 @@
1
+ _Init_grpc_c
2
+ _rb_tr_abi_version
@@ -0,0 +1,7 @@
1
+ grpc_1.0 {
2
+ global:
3
+ Init_grpc_c;
4
+ rb_tr_abi_version;
5
+ local:
6
+ *;
7
+ };
@@ -0,0 +1,2 @@
1
+ _Init_grpc_c
2
+ _ruby_abi_version
@@ -0,0 +1,7 @@
1
+ grpc_1.0 {
2
+ global:
3
+ Init_grpc_c;
4
+ ruby_abi_version;
5
+ local:
6
+ *;
7
+ };
@@ -3,4 +3,4 @@ grpc_1.0 {
3
3
  Init_grpc_c;
4
4
  local:
5
5
  *;
6
- };
6
+ };
@@ -14,12 +14,16 @@
14
14
 
15
15
  require 'etc'
16
16
  require 'mkmf'
17
+ require_relative '../../lib/grpc/version.rb'
17
18
 
18
19
  windows = RUBY_PLATFORM =~ /mingw|mswin/
20
+ windows_ucrt = RUBY_PLATFORM =~ /(mingw|mswin).*ucrt/
19
21
  bsd = RUBY_PLATFORM =~ /bsd/
20
22
  darwin = RUBY_PLATFORM =~ /darwin/
21
23
  linux = RUBY_PLATFORM =~ /linux/
22
24
  cross_compiling = ENV['RCD_HOST_RUBY_VERSION'] # set by rake-compiler-dock in build containers
25
+ # TruffleRuby uses the Sulong LLVM runtime, which is different from Apple's.
26
+ apple_toolchain = darwin && RUBY_ENGINE != 'truffleruby'
23
27
 
24
28
  grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
25
29
 
@@ -27,30 +31,79 @@ grpc_config = ENV['GRPC_CONFIG'] || 'opt'
27
31
 
28
32
  ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
29
33
 
30
- if ENV['AR'].nil? || ENV['AR'].size == 0
31
- ENV['AR'] = RbConfig::CONFIG['AR']
34
+ def debug_symbols_output_dir
35
+ d = ENV['GRPC_RUBY_DEBUG_SYMBOLS_OUTPUT_DIR']
36
+ return nil if d.nil? or d.size == 0
37
+ d
32
38
  end
33
- if ENV['CC'].nil? || ENV['CC'].size == 0
34
- ENV['CC'] = RbConfig::CONFIG['CC']
39
+
40
+ def maybe_remove_strip_all_linker_flag(flags)
41
+ if debug_symbols_output_dir
42
+ # Hack to prevent automatic stripping during shared library linking.
43
+ # rake-compiler-dock sets the -s LDFLAG when building rubies for
44
+ # cross compilation, and this -s flag propagates into RbConfig. Stripping
45
+ # during the link is problematic because it prevents us from saving
46
+ # debug symbols. We want to first link our shared library, then save
47
+ # debug symbols, and only after that strip.
48
+ flags = flags.split(' ')
49
+ flags = flags.reject {|flag| flag == '-s'}
50
+ flags = flags.join(' ')
51
+ end
52
+ flags
35
53
  end
36
- if ENV['CXX'].nil? || ENV['CXX'].size == 0
37
- ENV['CXX'] = RbConfig::CONFIG['CXX']
54
+
55
+ def env_unset?(name)
56
+ ENV[name].nil? || ENV[name].size == 0
38
57
  end
39
- if ENV['LD'].nil? || ENV['LD'].size == 0
40
- ENV['LD'] = ENV['CC']
58
+
59
+ def inherit_env_or_rbconfig(name)
60
+ ENV[name] = inherit_rbconfig(name) if env_unset?(name)
41
61
  end
42
62
 
43
- if darwin && !cross_compiling
63
+ def inherit_rbconfig(name, linker_flag: false)
64
+ value = RbConfig::CONFIG[name] || ''
65
+ if linker_flag
66
+ value = maybe_remove_strip_all_linker_flag(value)
67
+ end
68
+ p "extconf.rb setting ENV[#{name}] = #{value}"
69
+ ENV[name] = value
70
+ end
71
+
72
+ def env_append(name, string)
73
+ ENV[name] += ' ' + string
74
+ end
75
+
76
+ # build grpc C-core
77
+ inherit_env_or_rbconfig 'AR'
78
+ inherit_env_or_rbconfig 'CC'
79
+ inherit_env_or_rbconfig 'CXX'
80
+ inherit_env_or_rbconfig 'RANLIB'
81
+ inherit_env_or_rbconfig 'STRIP'
82
+ inherit_rbconfig 'CPPFLAGS'
83
+ inherit_rbconfig('LDFLAGS', linker_flag: true)
84
+
85
+ ENV['LD'] = ENV['CC'] if env_unset?('LD')
86
+ ENV['LDXX'] = ENV['CXX'] if env_unset?('LDXX')
87
+
88
+ if RUBY_ENGINE == 'truffleruby'
89
+ # ensure we can find the system's OpenSSL
90
+ env_append 'CPPFLAGS', RbConfig::CONFIG['cppflags']
91
+ end
92
+
93
+ if apple_toolchain && !cross_compiling
44
94
  ENV['AR'] = 'libtool'
45
95
  ENV['ARFLAGS'] = '-o'
46
96
  end
47
97
 
48
- ENV['EMBED_OPENSSL'] = 'true'
49
- ENV['EMBED_ZLIB'] = 'true'
98
+ # Don't embed on TruffleRuby (constant-time crypto is unsafe with Sulong, slow build times)
99
+ ENV['EMBED_OPENSSL'] = (RUBY_ENGINE != 'truffleruby').to_s
100
+ # Don't embed on TruffleRuby (the system zlib is already linked for the zlib C extension, slow build times)
101
+ ENV['EMBED_ZLIB'] = (RUBY_ENGINE != 'truffleruby').to_s
102
+
50
103
  ENV['EMBED_CARES'] = 'true'
51
104
 
52
105
  ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG']
53
- if darwin && !cross_compiling
106
+ if apple_toolchain && !cross_compiling
54
107
  if RUBY_PLATFORM =~ /arm64/
55
108
  ENV['ARCH_FLAGS'] = '-arch arm64'
56
109
  else
@@ -58,28 +111,77 @@ if darwin && !cross_compiling
58
111
  end
59
112
  end
60
113
 
61
- ENV['CPPFLAGS'] = '-DGPR_BACKWARDS_COMPATIBILITY_MODE'
62
- ENV['CPPFLAGS'] += ' -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="\"RUBY\"" '
63
- ENV['CPPFLAGS'] += ' -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX="\"1.42.0.pre1\"" '
114
+ env_append 'CPPFLAGS', '-DGPR_BACKWARDS_COMPATIBILITY_MODE'
115
+ env_append 'CPPFLAGS', '-DGRPC_XDS_USER_AGENT_NAME_SUFFIX="\"RUBY\""'
116
+
117
+ require_relative '../../lib/grpc/version'
118
+ env_append 'CPPFLAGS', '-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX="\"' + GRPC::VERSION + '\""'
119
+ env_append 'CPPFLAGS', '-DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1'
64
120
 
65
121
  output_dir = File.expand_path(RbConfig::CONFIG['topdir'])
66
122
  grpc_lib_dir = File.join(output_dir, 'libs', grpc_config)
67
123
  ENV['BUILDDIR'] = output_dir
68
124
 
125
+ strip_tool = RbConfig::CONFIG['STRIP']
126
+ strip_tool += ' -x' if apple_toolchain
127
+
69
128
  unless windows
70
129
  puts 'Building internal gRPC into ' + grpc_lib_dir
71
130
  nproc = 4
72
- nproc = Etc.nprocessors * 2 if Etc.respond_to? :nprocessors
131
+ nproc = Etc.nprocessors if Etc.respond_to? :nprocessors
132
+ nproc_override = ENV['GRPC_RUBY_BUILD_PROCS']
133
+ unless nproc_override.nil? or nproc_override.size == 0
134
+ nproc = nproc_override
135
+ puts "Overriding make parallelism to #{nproc}"
136
+ end
73
137
  make = bsd ? 'gmake' : 'make'
74
- system("#{make} -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q=")
138
+ cmd = "#{make} -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q="
139
+ puts "Building grpc native library: #{cmd}"
140
+ system(cmd)
75
141
  exit 1 unless $? == 0
76
142
  end
77
143
 
144
+ # C-core built, generate Makefile for ruby extension
145
+ $LDFLAGS = maybe_remove_strip_all_linker_flag($LDFLAGS)
146
+ $DLDFLAGS = maybe_remove_strip_all_linker_flag($DLDFLAGS)
147
+
148
+ $CFLAGS << ' -DGRPC_RUBY_WINDOWS_UCRT' if windows_ucrt
78
149
  $CFLAGS << ' -I' + File.join(grpc_root, 'include')
150
+ $CFLAGS << ' -g'
79
151
 
80
- ext_export_file = File.join(grpc_root, 'src', 'ruby', 'ext', 'grpc', 'ext-export')
152
+ def have_ruby_abi_version()
153
+ return true if RUBY_ENGINE == 'truffleruby'
154
+ # ruby_abi_version is only available in development versions: https://github.com/ruby/ruby/pull/6231
155
+ return false if RUBY_PATCHLEVEL >= 0
156
+
157
+ m = /(\d+)\.(\d+)/.match(RUBY_VERSION)
158
+ if m.nil?
159
+ puts "Failed to parse ruby version: #{RUBY_VERSION}. Assuming ruby_abi_version symbol is NOT present."
160
+ return false
161
+ end
162
+ major = m[1].to_i
163
+ minor = m[2].to_i
164
+ if major >= 3 and minor >= 2
165
+ puts "Ruby version #{RUBY_VERSION} >= 3.2. Assuming ruby_abi_version symbol is present."
166
+ return true
167
+ end
168
+ puts "Ruby version #{RUBY_VERSION} < 3.2. Assuming ruby_abi_version symbol is NOT present."
169
+ false
170
+ end
171
+
172
+ def ext_export_filename()
173
+ name = 'ext-export'
174
+ name += '-truffleruby' if RUBY_ENGINE == 'truffleruby'
175
+ name += '-with-ruby-abi-version' if have_ruby_abi_version()
176
+ name
177
+ end
178
+
179
+ ext_export_file = File.join(grpc_root, 'src', 'ruby', 'ext', 'grpc', ext_export_filename())
81
180
  $LDFLAGS << ' -Wl,--version-script="' + ext_export_file + '.gcc"' if linux
82
- $LDFLAGS << ' -Wl,-exported_symbols_list,"' + ext_export_file + '.clang"' if darwin
181
+ if apple_toolchain
182
+ $LDFLAGS << ' -weak_framework CoreFoundation'
183
+ $LDFLAGS << ' -Wl,-exported_symbols_list,"' + ext_export_file + '.clang"'
184
+ end
83
185
 
84
186
  $LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') unless windows
85
187
  if grpc_config == 'gcov'
@@ -88,36 +190,81 @@ if grpc_config == 'gcov'
88
190
  end
89
191
 
90
192
  if grpc_config == 'dbg'
91
- $CFLAGS << ' -O0 -ggdb3'
193
+ $CFLAGS << ' -O0'
92
194
  end
93
195
 
94
196
  $LDFLAGS << ' -Wl,-wrap,memcpy' if linux
95
- $LDFLAGS << ' -static-libgcc -static-libstdc++' if linux
197
+ # Do not statically link standard libraries on TruffleRuby as this does not work when compiling to bitcode
198
+ if linux && RUBY_ENGINE != 'truffleruby'
199
+ $LDFLAGS << ' -static-libgcc -static-libstdc++'
200
+ end
96
201
  $LDFLAGS << ' -static' if windows
97
202
 
98
- $CFLAGS << ' -std=c99 '
203
+ $CFLAGS << ' -std=c11 '
99
204
  $CFLAGS << ' -Wall '
100
205
  $CFLAGS << ' -Wextra '
101
206
  $CFLAGS << ' -pedantic '
102
207
 
103
208
  output = File.join('grpc', 'grpc_c')
209
+ puts "extconf.rb $LDFLAGS: #{$LDFLAGS}"
210
+ puts "extconf.rb $DLDFLAGS: #{$DLDFLAGS}"
211
+ puts "extconf.rb $CFLAGS: #{$CFLAGS}"
104
212
  puts 'Generating Makefile for ' + output
105
213
  create_makefile(output)
106
214
 
107
- strip_tool = RbConfig::CONFIG['STRIP']
108
- strip_tool += ' -x' if darwin
215
+ ruby_major_minor = /(\d+\.\d+)/.match(RUBY_VERSION).to_s
216
+ debug_symbols = "grpc-#{GRPC::VERSION}-#{RUBY_PLATFORM}-ruby-#{ruby_major_minor}.dbg"
217
+
218
+ File.open('Makefile.new', 'w') do |o|
219
+ o.puts 'hijack_remove_unused_artifacts: all remove_unused_artifacts'
220
+ o.puts
221
+ o.write(File.read('Makefile'))
222
+ o.puts
223
+ o.puts 'remove_unused_artifacts: $(DLLIB)'
224
+ # Now that the extension library has been linked, we can remove unused artifacts
225
+ # that take up a lot of disk space.
226
+ rm_obj_cmd = "rm -rf #{File.join(output_dir, 'objs')}"
227
+ o.puts "\t$(ECHO) Removing unused object artifacts: #{rm_obj_cmd}"
228
+ o.puts "\t$(Q) #{rm_obj_cmd}"
229
+ rm_grpc_core_libs = "rm -f #{grpc_lib_dir}/*.a"
230
+ o.puts "\t$(ECHO) Removing unused grpc core libraries: #{rm_grpc_core_libs}"
231
+ o.puts "\t$(Q) #{rm_grpc_core_libs}"
232
+ end
233
+ File.rename('Makefile.new', 'Makefile')
109
234
 
110
235
  if grpc_config == 'opt'
111
236
  File.open('Makefile.new', 'w') do |o|
112
237
  o.puts 'hijack: all strip'
113
238
  o.puts
114
- File.foreach('Makefile') do |i|
115
- o.puts i
116
- end
239
+ o.write(File.read('Makefile'))
117
240
  o.puts
118
241
  o.puts 'strip: $(DLLIB)'
242
+ if debug_symbols_output_dir
243
+ o.puts "\t$(ECHO) Saving debug symbols in #{debug_symbols_output_dir}/#{debug_symbols}"
244
+ o.puts "\t$(Q) objcopy --only-keep-debug $(DLLIB) #{debug_symbols_output_dir}/#{debug_symbols}"
245
+ end
119
246
  o.puts "\t$(ECHO) Stripping $(DLLIB)"
120
247
  o.puts "\t$(Q) #{strip_tool} $(DLLIB)"
121
248
  end
122
249
  File.rename('Makefile.new', 'Makefile')
123
250
  end
251
+
252
+ if ENV['GRPC_RUBY_TEST_ONLY_WORKAROUND_MAKE_INSTALL_BUG']
253
+ # Note: this env var setting is intended to work around a problem observed
254
+ # with the ginstall command on grpc's macos automated test infrastructure,
255
+ # and is not guaranteed to work in the wild.
256
+ # Also see https://github.com/rake-compiler/rake-compiler/issues/210.
257
+ puts 'Overriding the generated Makefile install target to use cp'
258
+ File.open('Makefile.new', 'w') do |o|
259
+ File.foreach('Makefile') do |i|
260
+ if i.start_with?('INSTALL_PROG = ')
261
+ override = 'INSTALL_PROG = cp'
262
+ puts "Replacing generated Makefile line: |#{i}|, with: |#{override}|"
263
+ o.puts override
264
+ else
265
+ o.puts i
266
+ end
267
+ end
268
+ end
269
+ File.rename('Makefile.new', 'Makefile')
270
+ end
@@ -801,6 +801,56 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
801
801
  return result;
802
802
  }
803
803
 
804
+ struct call_run_batch_args {
805
+ grpc_rb_call* call;
806
+ unsigned write_flag;
807
+ VALUE ops_hash;
808
+ run_batch_stack* st;
809
+ };
810
+
811
+ static VALUE grpc_rb_call_run_batch_try(VALUE value_args) {
812
+ grpc_rb_fork_unsafe_begin();
813
+ struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
814
+ void* tag = (void*)&args->st;
815
+
816
+ grpc_event ev;
817
+ grpc_call_error err;
818
+
819
+ args->st = gpr_malloc(sizeof(run_batch_stack));
820
+ grpc_run_batch_stack_init(args->st, args->write_flag);
821
+ grpc_run_batch_stack_fill_ops(args->st, args->ops_hash);
822
+
823
+ /* call grpc_call_start_batch, then wait for it to complete using
824
+ * pluck_event */
825
+ err = grpc_call_start_batch(args->call->wrapped, args->st->ops,
826
+ args->st->op_num, tag, NULL);
827
+ if (err != GRPC_CALL_OK) {
828
+ rb_raise(grpc_rb_eCallError,
829
+ "grpc_call_start_batch failed with %s (code=%d)",
830
+ grpc_call_error_detail_of(err), err);
831
+ }
832
+ ev = rb_completion_queue_pluck(args->call->queue, tag,
833
+ gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
834
+ if (!ev.success) {
835
+ rb_raise(grpc_rb_eCallError, "call#run_batch failed somehow");
836
+ }
837
+ /* Build and return the BatchResult struct result,
838
+ if there is an error, it's reflected in the status */
839
+ return grpc_run_batch_stack_build_result(args->st);
840
+ }
841
+
842
+ static VALUE grpc_rb_call_run_batch_ensure(VALUE value_args) {
843
+ grpc_rb_fork_unsafe_end();
844
+ struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
845
+
846
+ if (args->st) {
847
+ grpc_run_batch_stack_cleanup(args->st);
848
+ gpr_free(args->st);
849
+ }
850
+
851
+ return Qnil;
852
+ }
853
+
804
854
  /* call-seq:
805
855
  ops = {
806
856
  GRPC::Core::CallOps::SEND_INITIAL_METADATA => <op_value>,
@@ -819,56 +869,29 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
819
869
  Only one operation of each type can be active at once in any given
820
870
  batch */
821
871
  static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
822
- run_batch_stack* st = NULL;
823
- grpc_rb_call* call = NULL;
824
- grpc_event ev;
825
- grpc_call_error err;
826
- VALUE result = Qnil;
827
- VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
828
- unsigned write_flag = 0;
829
- void* tag = (void*)&st;
830
-
831
872
  grpc_ruby_fork_guard();
832
873
  if (RTYPEDDATA_DATA(self) == NULL) {
833
874
  rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
834
- return Qnil;
835
875
  }
876
+
877
+ grpc_rb_call* call = NULL;
836
878
  TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
837
879
 
838
880
  /* Validate the ops args, adding them to a ruby array */
839
881
  if (TYPE(ops_hash) != T_HASH) {
840
882
  rb_raise(rb_eTypeError, "call#run_batch: ops hash should be a hash");
841
- return Qnil;
842
883
  }
843
- if (rb_write_flag != Qnil) {
844
- write_flag = NUM2UINT(rb_write_flag);
845
- }
846
- st = gpr_malloc(sizeof(run_batch_stack));
847
- grpc_run_batch_stack_init(st, write_flag);
848
- grpc_run_batch_stack_fill_ops(st, ops_hash);
849
884
 
850
- /* call grpc_call_start_batch, then wait for it to complete using
851
- * pluck_event */
852
- err = grpc_call_start_batch(call->wrapped, st->ops, st->op_num, tag, NULL);
853
- if (err != GRPC_CALL_OK) {
854
- grpc_run_batch_stack_cleanup(st);
855
- gpr_free(st);
856
- rb_raise(grpc_rb_eCallError,
857
- "grpc_call_start_batch failed with %s (code=%d)",
858
- grpc_call_error_detail_of(err), err);
859
- return Qnil;
860
- }
861
- ev = rb_completion_queue_pluck(call->queue, tag,
862
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
863
- if (!ev.success) {
864
- rb_raise(grpc_rb_eCallError, "call#run_batch failed somehow");
865
- }
866
- /* Build and return the BatchResult struct result,
867
- if there is an error, it's reflected in the status */
868
- result = grpc_run_batch_stack_build_result(st);
869
- grpc_run_batch_stack_cleanup(st);
870
- gpr_free(st);
871
- return result;
885
+ VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
886
+
887
+ struct call_run_batch_args args = {
888
+ .call = call,
889
+ .write_flag = rb_write_flag == Qnil ? 0 : NUM2UINT(rb_write_flag),
890
+ .ops_hash = ops_hash,
891
+ .st = NULL};
892
+
893
+ return rb_ensure(grpc_rb_call_run_batch_try, (VALUE)&args,
894
+ grpc_rb_call_run_batch_ensure, (VALUE)&args);
872
895
  }
873
896
 
874
897
  static void Init_grpc_write_flags() {
@@ -973,6 +996,7 @@ void Init_grpc_call() {
973
996
  grpc_rb_cCall = rb_define_class_under(grpc_rb_mGrpcCore, "Call", rb_cObject);
974
997
  grpc_rb_cMdAry =
975
998
  rb_define_class_under(grpc_rb_mGrpcCore, "MetadataArray", rb_cObject);
999
+ rb_undef_alloc_func(grpc_rb_cMdAry);
976
1000
 
977
1001
  /* Prevent allocation or inialization of the Call class */
978
1002
  rb_define_alloc_func(grpc_rb_cCall, grpc_rb_cannot_alloc);
@@ -193,7 +193,6 @@ static void grpc_rb_call_credentials_free_internal(void* p) {
193
193
  /* Destroys the credentials instances. */
194
194
  static void grpc_rb_call_credentials_free(void* p) {
195
195
  grpc_rb_call_credentials_free_internal(p);
196
- grpc_ruby_shutdown();
197
196
  }
198
197
 
199
198
  /* Protects the mark object from GC */