grpc 1.9.1-universal-darwin → 1.10.0.pre1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

@@ -193,7 +193,7 @@ end
193
193
  Args = Struct.new(:host, :port, :action, :project_id, :topic_name,
194
194
  :sub_name)
195
195
 
196
- # validates the the command line options, returning them as an Arg.
196
+ # validates the command line options, returning them as an Arg.
197
197
  def parse_args
198
198
  args = Args.new('pubsub-staging.googleapis.com',
199
199
  443, 'list_some_topics', 'stoked-keyword-656')
@@ -362,8 +362,8 @@ static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
362
362
 
363
363
  /* Wait until the channel's connectivity state becomes different from
364
364
  * "last_state", or "deadline" expires.
365
- * Returns true if the the channel's connectivity state becomes
366
- * different from "last_state" within "deadline".
365
+ * Returns true if the channel's connectivity state becomes different
366
+ * from "last_state" within "deadline".
367
367
  * Returns false if "deadline" expires before the channel's connectivity
368
368
  * state changes from "last_state".
369
369
  * */
@@ -427,16 +427,15 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
427
427
  parent_call = grpc_rb_get_wrapped_call(parent);
428
428
  }
429
429
 
430
- cq = grpc_completion_queue_create_for_pluck(NULL);
431
430
  TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
432
431
  if (wrapper->bg_wrapped == NULL) {
433
432
  rb_raise(rb_eRuntimeError, "closed!");
434
433
  return Qnil;
435
434
  }
436
435
 
436
+ cq = grpc_completion_queue_create_for_pluck(NULL);
437
437
  method_slice =
438
438
  grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method));
439
-
440
439
  call = grpc_channel_create_call(wrapper->bg_wrapped->channel, parent_call,
441
440
  flags, cq, method_slice, host_slice_ptr,
442
441
  grpc_rb_time_timeval(deadline,
@@ -27,6 +27,8 @@
27
27
  #include <grpc/impl/codegen/compression_types.h>
28
28
  #include <grpc/impl/codegen/grpc_types.h>
29
29
  #include <grpc/support/alloc.h>
30
+ #include <grpc/support/log.h>
31
+ #include <grpc/support/string_util.h>
30
32
  #include <string.h>
31
33
 
32
34
  #include "rb_grpc.h"
@@ -159,7 +161,6 @@ void grpc_rb_compression_options_algorithm_name_to_value_internal(
159
161
  grpc_compression_algorithm* algorithm_value, VALUE algorithm_name) {
160
162
  grpc_slice name_slice;
161
163
  VALUE algorithm_name_as_string = Qnil;
162
- char* tmp_str = NULL;
163
164
 
164
165
  Check_Type(algorithm_name, T_SYMBOL);
165
166
 
@@ -175,8 +176,17 @@ void grpc_rb_compression_options_algorithm_name_to_value_internal(
175
176
  * the algorithm parse function
176
177
  * in GRPC core. */
177
178
  if (!grpc_compression_algorithm_parse(name_slice, algorithm_value)) {
178
- tmp_str = grpc_slice_to_c_string(name_slice);
179
- rb_raise(rb_eNameError, "Invalid compression algorithm name: %s", tmp_str);
179
+ char* name_slice_str = grpc_slice_to_c_string(name_slice);
180
+ char* error_message_str = NULL;
181
+ VALUE error_message_ruby_str = Qnil;
182
+ GPR_ASSERT(gpr_asprintf(&error_message_str,
183
+ "Invalid compression algorithm name: %s",
184
+ name_slice_str) != -1);
185
+ gpr_free(name_slice_str);
186
+ error_message_ruby_str =
187
+ rb_str_new(error_message_str, strlen(error_message_str));
188
+ gpr_free(error_message_str);
189
+ rb_raise(rb_eNameError, StringValueCStr(error_message_ruby_str));
180
190
  }
181
191
 
182
192
  grpc_slice_unref(name_slice);
@@ -22,16 +22,15 @@
22
22
 
23
23
  #include "rb_grpc_imports.generated.h"
24
24
 
25
+ grpc_compression_algorithm_is_message_type grpc_compression_algorithm_is_message_import;
26
+ grpc_compression_algorithm_is_stream_type grpc_compression_algorithm_is_stream_import;
25
27
  grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
26
28
  grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
27
- grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
28
29
  grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
29
- grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
30
30
  grpc_compression_options_init_type grpc_compression_options_init_import;
31
31
  grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
32
32
  grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
33
33
  grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
34
- grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
35
34
  grpc_metadata_array_init_type grpc_metadata_array_init_import;
36
35
  grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import;
37
36
  grpc_call_details_init_type grpc_call_details_init_import;
@@ -51,10 +50,6 @@ grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import;
51
50
  grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import;
52
51
  grpc_completion_queue_thread_local_cache_init_type grpc_completion_queue_thread_local_cache_init_import;
53
52
  grpc_completion_queue_thread_local_cache_flush_type grpc_completion_queue_thread_local_cache_flush_import;
54
- grpc_alarm_create_type grpc_alarm_create_import;
55
- grpc_alarm_set_type grpc_alarm_set_import;
56
- grpc_alarm_cancel_type grpc_alarm_cancel_import;
57
- grpc_alarm_destroy_type grpc_alarm_destroy_import;
58
53
  grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
59
54
  grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
60
55
  grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
@@ -204,27 +199,8 @@ gpr_malloc_aligned_type gpr_malloc_aligned_import;
204
199
  gpr_free_aligned_type gpr_free_aligned_import;
205
200
  gpr_set_allocation_functions_type gpr_set_allocation_functions_import;
206
201
  gpr_get_allocation_functions_type gpr_get_allocation_functions_import;
207
- gpr_avl_create_type gpr_avl_create_import;
208
- gpr_avl_ref_type gpr_avl_ref_import;
209
- gpr_avl_unref_type gpr_avl_unref_import;
210
- gpr_avl_add_type gpr_avl_add_import;
211
- gpr_avl_remove_type gpr_avl_remove_import;
212
- gpr_avl_get_type gpr_avl_get_import;
213
- gpr_avl_maybe_get_type gpr_avl_maybe_get_import;
214
- gpr_avl_is_empty_type gpr_avl_is_empty_import;
215
- gpr_cmdline_create_type gpr_cmdline_create_import;
216
- gpr_cmdline_add_int_type gpr_cmdline_add_int_import;
217
- gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import;
218
- gpr_cmdline_add_string_type gpr_cmdline_add_string_import;
219
- gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import;
220
- gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import;
221
- gpr_cmdline_parse_type gpr_cmdline_parse_import;
222
- gpr_cmdline_destroy_type gpr_cmdline_destroy_import;
223
- gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import;
224
202
  gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
225
203
  gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
226
- gpr_join_host_port_type gpr_join_host_port_import;
227
- gpr_split_host_port_type gpr_split_host_port_import;
228
204
  gpr_log_severity_string_type gpr_log_severity_string_import;
229
205
  gpr_log_type gpr_log_import;
230
206
  gpr_log_message_type gpr_log_message_import;
@@ -234,11 +210,6 @@ gpr_set_log_function_type gpr_set_log_function_import;
234
210
  gpr_format_message_type gpr_format_message_import;
235
211
  gpr_strdup_type gpr_strdup_import;
236
212
  gpr_asprintf_type gpr_asprintf_import;
237
- gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import;
238
- gpr_subprocess_create_type gpr_subprocess_create_import;
239
- gpr_subprocess_destroy_type gpr_subprocess_destroy_import;
240
- gpr_subprocess_join_type gpr_subprocess_join_import;
241
- gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import;
242
213
  gpr_mu_init_type gpr_mu_init_import;
243
214
  gpr_mu_destroy_type gpr_mu_destroy_import;
244
215
  gpr_mu_lock_type gpr_mu_lock_import;
@@ -263,14 +234,7 @@ gpr_ref_is_unique_type gpr_ref_is_unique_import;
263
234
  gpr_stats_init_type gpr_stats_init_import;
264
235
  gpr_stats_inc_type gpr_stats_inc_import;
265
236
  gpr_stats_read_type gpr_stats_read_import;
266
- gpr_thd_new_type gpr_thd_new_import;
267
- gpr_thd_options_default_type gpr_thd_options_default_import;
268
- gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import;
269
- gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import;
270
- gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import;
271
- gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import;
272
237
  gpr_thd_currentid_type gpr_thd_currentid_import;
273
- gpr_thd_join_type gpr_thd_join_import;
274
238
  gpr_time_0_type gpr_time_0_import;
275
239
  gpr_inf_future_type gpr_inf_future_import;
276
240
  gpr_inf_past_type gpr_inf_past_import;
@@ -294,16 +258,15 @@ gpr_sleep_until_type gpr_sleep_until_import;
294
258
  gpr_timespec_to_micros_type gpr_timespec_to_micros_import;
295
259
 
296
260
  void grpc_rb_load_imports(HMODULE library) {
261
+ grpc_compression_algorithm_is_message_import = (grpc_compression_algorithm_is_message_type) GetProcAddress(library, "grpc_compression_algorithm_is_message");
262
+ grpc_compression_algorithm_is_stream_import = (grpc_compression_algorithm_is_stream_type) GetProcAddress(library, "grpc_compression_algorithm_is_stream");
297
263
  grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
298
264
  grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
299
- grpc_stream_compression_algorithm_name_import = (grpc_stream_compression_algorithm_name_type) GetProcAddress(library, "grpc_stream_compression_algorithm_name");
300
265
  grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");
301
- grpc_stream_compression_algorithm_for_level_import = (grpc_stream_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_stream_compression_algorithm_for_level");
302
266
  grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init");
303
267
  grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm");
304
268
  grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm");
305
269
  grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled");
306
- grpc_compression_options_is_stream_compression_algorithm_enabled_import = (grpc_compression_options_is_stream_compression_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_stream_compression_algorithm_enabled");
307
270
  grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init");
308
271
  grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy");
309
272
  grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init");
@@ -323,10 +286,6 @@ void grpc_rb_load_imports(HMODULE library) {
323
286
  grpc_completion_queue_destroy_import = (grpc_completion_queue_destroy_type) GetProcAddress(library, "grpc_completion_queue_destroy");
324
287
  grpc_completion_queue_thread_local_cache_init_import = (grpc_completion_queue_thread_local_cache_init_type) GetProcAddress(library, "grpc_completion_queue_thread_local_cache_init");
325
288
  grpc_completion_queue_thread_local_cache_flush_import = (grpc_completion_queue_thread_local_cache_flush_type) GetProcAddress(library, "grpc_completion_queue_thread_local_cache_flush");
326
- grpc_alarm_create_import = (grpc_alarm_create_type) GetProcAddress(library, "grpc_alarm_create");
327
- grpc_alarm_set_import = (grpc_alarm_set_type) GetProcAddress(library, "grpc_alarm_set");
328
- grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel");
329
- grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy");
330
289
  grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state");
331
290
  grpc_channel_num_external_connectivity_watchers_import = (grpc_channel_num_external_connectivity_watchers_type) GetProcAddress(library, "grpc_channel_num_external_connectivity_watchers");
332
291
  grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state");
@@ -476,27 +435,8 @@ void grpc_rb_load_imports(HMODULE library) {
476
435
  gpr_free_aligned_import = (gpr_free_aligned_type) GetProcAddress(library, "gpr_free_aligned");
477
436
  gpr_set_allocation_functions_import = (gpr_set_allocation_functions_type) GetProcAddress(library, "gpr_set_allocation_functions");
478
437
  gpr_get_allocation_functions_import = (gpr_get_allocation_functions_type) GetProcAddress(library, "gpr_get_allocation_functions");
479
- gpr_avl_create_import = (gpr_avl_create_type) GetProcAddress(library, "gpr_avl_create");
480
- gpr_avl_ref_import = (gpr_avl_ref_type) GetProcAddress(library, "gpr_avl_ref");
481
- gpr_avl_unref_import = (gpr_avl_unref_type) GetProcAddress(library, "gpr_avl_unref");
482
- gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add");
483
- gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove");
484
- gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get");
485
- gpr_avl_maybe_get_import = (gpr_avl_maybe_get_type) GetProcAddress(library, "gpr_avl_maybe_get");
486
- gpr_avl_is_empty_import = (gpr_avl_is_empty_type) GetProcAddress(library, "gpr_avl_is_empty");
487
- gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create");
488
- gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int");
489
- gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag");
490
- gpr_cmdline_add_string_import = (gpr_cmdline_add_string_type) GetProcAddress(library, "gpr_cmdline_add_string");
491
- gpr_cmdline_on_extra_arg_import = (gpr_cmdline_on_extra_arg_type) GetProcAddress(library, "gpr_cmdline_on_extra_arg");
492
- gpr_cmdline_set_survive_failure_import = (gpr_cmdline_set_survive_failure_type) GetProcAddress(library, "gpr_cmdline_set_survive_failure");
493
- gpr_cmdline_parse_import = (gpr_cmdline_parse_type) GetProcAddress(library, "gpr_cmdline_parse");
494
- gpr_cmdline_destroy_import = (gpr_cmdline_destroy_type) GetProcAddress(library, "gpr_cmdline_destroy");
495
- gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string");
496
438
  gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores");
497
439
  gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu");
498
- gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port");
499
- gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port");
500
440
  gpr_log_severity_string_import = (gpr_log_severity_string_type) GetProcAddress(library, "gpr_log_severity_string");
501
441
  gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
502
442
  gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
@@ -506,11 +446,6 @@ void grpc_rb_load_imports(HMODULE library) {
506
446
  gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message");
507
447
  gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup");
508
448
  gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf");
509
- gpr_subprocess_binary_extension_import = (gpr_subprocess_binary_extension_type) GetProcAddress(library, "gpr_subprocess_binary_extension");
510
- gpr_subprocess_create_import = (gpr_subprocess_create_type) GetProcAddress(library, "gpr_subprocess_create");
511
- gpr_subprocess_destroy_import = (gpr_subprocess_destroy_type) GetProcAddress(library, "gpr_subprocess_destroy");
512
- gpr_subprocess_join_import = (gpr_subprocess_join_type) GetProcAddress(library, "gpr_subprocess_join");
513
- gpr_subprocess_interrupt_import = (gpr_subprocess_interrupt_type) GetProcAddress(library, "gpr_subprocess_interrupt");
514
449
  gpr_mu_init_import = (gpr_mu_init_type) GetProcAddress(library, "gpr_mu_init");
515
450
  gpr_mu_destroy_import = (gpr_mu_destroy_type) GetProcAddress(library, "gpr_mu_destroy");
516
451
  gpr_mu_lock_import = (gpr_mu_lock_type) GetProcAddress(library, "gpr_mu_lock");
@@ -535,14 +470,7 @@ void grpc_rb_load_imports(HMODULE library) {
535
470
  gpr_stats_init_import = (gpr_stats_init_type) GetProcAddress(library, "gpr_stats_init");
536
471
  gpr_stats_inc_import = (gpr_stats_inc_type) GetProcAddress(library, "gpr_stats_inc");
537
472
  gpr_stats_read_import = (gpr_stats_read_type) GetProcAddress(library, "gpr_stats_read");
538
- gpr_thd_new_import = (gpr_thd_new_type) GetProcAddress(library, "gpr_thd_new");
539
- gpr_thd_options_default_import = (gpr_thd_options_default_type) GetProcAddress(library, "gpr_thd_options_default");
540
- gpr_thd_options_set_detached_import = (gpr_thd_options_set_detached_type) GetProcAddress(library, "gpr_thd_options_set_detached");
541
- gpr_thd_options_set_joinable_import = (gpr_thd_options_set_joinable_type) GetProcAddress(library, "gpr_thd_options_set_joinable");
542
- gpr_thd_options_is_detached_import = (gpr_thd_options_is_detached_type) GetProcAddress(library, "gpr_thd_options_is_detached");
543
- gpr_thd_options_is_joinable_import = (gpr_thd_options_is_joinable_type) GetProcAddress(library, "gpr_thd_options_is_joinable");
544
473
  gpr_thd_currentid_import = (gpr_thd_currentid_type) GetProcAddress(library, "gpr_thd_currentid");
545
- gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join");
546
474
  gpr_time_0_import = (gpr_time_0_type) GetProcAddress(library, "gpr_time_0");
547
475
  gpr_inf_future_import = (gpr_inf_future_type) GetProcAddress(library, "gpr_inf_future");
548
476
  gpr_inf_past_import = (gpr_inf_past_type) GetProcAddress(library, "gpr_inf_past");
@@ -33,33 +33,29 @@
33
33
  #include <grpc/slice.h>
34
34
  #include <grpc/slice_buffer.h>
35
35
  #include <grpc/support/alloc.h>
36
- #include <grpc/support/avl.h>
37
- #include <grpc/support/cmdline.h>
38
36
  #include <grpc/support/cpu.h>
39
- #include <grpc/support/host_port.h>
40
37
  #include <grpc/support/log.h>
41
38
  #include <grpc/support/log_windows.h>
42
39
  #include <grpc/support/string_util.h>
43
- #include <grpc/support/subprocess.h>
44
40
  #include <grpc/support/sync.h>
45
- #include <grpc/support/thd.h>
41
+ #include <grpc/support/thd_id.h>
46
42
  #include <grpc/support/time.h>
47
43
 
44
+ typedef int(*grpc_compression_algorithm_is_message_type)(grpc_compression_algorithm algorithm);
45
+ extern grpc_compression_algorithm_is_message_type grpc_compression_algorithm_is_message_import;
46
+ #define grpc_compression_algorithm_is_message grpc_compression_algorithm_is_message_import
47
+ typedef int(*grpc_compression_algorithm_is_stream_type)(grpc_compression_algorithm algorithm);
48
+ extern grpc_compression_algorithm_is_stream_type grpc_compression_algorithm_is_stream_import;
49
+ #define grpc_compression_algorithm_is_stream grpc_compression_algorithm_is_stream_import
48
50
  typedef int(*grpc_compression_algorithm_parse_type)(grpc_slice value, grpc_compression_algorithm* algorithm);
49
51
  extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
50
52
  #define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import
51
53
  typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, const char** name);
52
54
  extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
53
55
  #define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
54
- typedef int(*grpc_stream_compression_algorithm_name_type)(grpc_stream_compression_algorithm algorithm, const char** name);
55
- extern grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
56
- #define grpc_stream_compression_algorithm_name grpc_stream_compression_algorithm_name_import
57
56
  typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
58
57
  extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
59
58
  #define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
60
- typedef grpc_stream_compression_algorithm(*grpc_stream_compression_algorithm_for_level_type)(grpc_stream_compression_level level, uint32_t accepted_stream_encodings);
61
- extern grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
62
- #define grpc_stream_compression_algorithm_for_level grpc_stream_compression_algorithm_for_level_import
63
59
  typedef void(*grpc_compression_options_init_type)(grpc_compression_options* opts);
64
60
  extern grpc_compression_options_init_type grpc_compression_options_init_import;
65
61
  #define grpc_compression_options_init grpc_compression_options_init_import
@@ -72,9 +68,6 @@ extern grpc_compression_options_disable_algorithm_type grpc_compression_options_
72
68
  typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options* opts, grpc_compression_algorithm algorithm);
73
69
  extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
74
70
  #define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import
75
- typedef int(*grpc_compression_options_is_stream_compression_algorithm_enabled_type)(const grpc_compression_options* opts, grpc_stream_compression_algorithm algorithm);
76
- extern grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
77
- #define grpc_compression_options_is_stream_compression_algorithm_enabled grpc_compression_options_is_stream_compression_algorithm_enabled_import
78
71
  typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array* array);
79
72
  extern grpc_metadata_array_init_type grpc_metadata_array_init_import;
80
73
  #define grpc_metadata_array_init grpc_metadata_array_init_import
@@ -132,18 +125,6 @@ extern grpc_completion_queue_thread_local_cache_init_type grpc_completion_queue_
132
125
  typedef int(*grpc_completion_queue_thread_local_cache_flush_type)(grpc_completion_queue* cq, void** tag, int* ok);
133
126
  extern grpc_completion_queue_thread_local_cache_flush_type grpc_completion_queue_thread_local_cache_flush_import;
134
127
  #define grpc_completion_queue_thread_local_cache_flush grpc_completion_queue_thread_local_cache_flush_import
135
- typedef grpc_alarm*(*grpc_alarm_create_type)(void* reserved);
136
- extern grpc_alarm_create_type grpc_alarm_create_import;
137
- #define grpc_alarm_create grpc_alarm_create_import
138
- typedef void(*grpc_alarm_set_type)(grpc_alarm* alarm, grpc_completion_queue* cq, gpr_timespec deadline, void* tag, void* reserved);
139
- extern grpc_alarm_set_type grpc_alarm_set_import;
140
- #define grpc_alarm_set grpc_alarm_set_import
141
- typedef void(*grpc_alarm_cancel_type)(grpc_alarm* alarm, void* reserved);
142
- extern grpc_alarm_cancel_type grpc_alarm_cancel_import;
143
- #define grpc_alarm_cancel grpc_alarm_cancel_import
144
- typedef void(*grpc_alarm_destroy_type)(grpc_alarm* alarm, void* reserved);
145
- extern grpc_alarm_destroy_type grpc_alarm_destroy_import;
146
- #define grpc_alarm_destroy grpc_alarm_destroy_import
147
128
  typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel* channel, int try_to_connect);
148
129
  extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
149
130
  #define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import
@@ -579,7 +560,7 @@ extern gpr_free_type gpr_free_import;
579
560
  typedef void*(*gpr_realloc_type)(void* p, size_t size);
580
561
  extern gpr_realloc_type gpr_realloc_import;
581
562
  #define gpr_realloc gpr_realloc_import
582
- typedef void*(*gpr_malloc_aligned_type)(size_t size, size_t alignment_log);
563
+ typedef void*(*gpr_malloc_aligned_type)(size_t size, size_t alignment);
583
564
  extern gpr_malloc_aligned_type gpr_malloc_aligned_import;
584
565
  #define gpr_malloc_aligned gpr_malloc_aligned_import
585
566
  typedef void(*gpr_free_aligned_type)(void* ptr);
@@ -591,69 +572,12 @@ extern gpr_set_allocation_functions_type gpr_set_allocation_functions_import;
591
572
  typedef gpr_allocation_functions(*gpr_get_allocation_functions_type)(void);
592
573
  extern gpr_get_allocation_functions_type gpr_get_allocation_functions_import;
593
574
  #define gpr_get_allocation_functions gpr_get_allocation_functions_import
594
- typedef gpr_avl(*gpr_avl_create_type)(const gpr_avl_vtable* vtable);
595
- extern gpr_avl_create_type gpr_avl_create_import;
596
- #define gpr_avl_create gpr_avl_create_import
597
- typedef gpr_avl(*gpr_avl_ref_type)(gpr_avl avl, void* user_data);
598
- extern gpr_avl_ref_type gpr_avl_ref_import;
599
- #define gpr_avl_ref gpr_avl_ref_import
600
- typedef void(*gpr_avl_unref_type)(gpr_avl avl, void* user_data);
601
- extern gpr_avl_unref_type gpr_avl_unref_import;
602
- #define gpr_avl_unref gpr_avl_unref_import
603
- typedef gpr_avl(*gpr_avl_add_type)(gpr_avl avl, void* key, void* value, void* user_data);
604
- extern gpr_avl_add_type gpr_avl_add_import;
605
- #define gpr_avl_add gpr_avl_add_import
606
- typedef gpr_avl(*gpr_avl_remove_type)(gpr_avl avl, void* key, void* user_data);
607
- extern gpr_avl_remove_type gpr_avl_remove_import;
608
- #define gpr_avl_remove gpr_avl_remove_import
609
- typedef void*(*gpr_avl_get_type)(gpr_avl avl, void* key, void* user_data);
610
- extern gpr_avl_get_type gpr_avl_get_import;
611
- #define gpr_avl_get gpr_avl_get_import
612
- typedef int(*gpr_avl_maybe_get_type)(gpr_avl avl, void* key, void** value, void* user_data);
613
- extern gpr_avl_maybe_get_type gpr_avl_maybe_get_import;
614
- #define gpr_avl_maybe_get gpr_avl_maybe_get_import
615
- typedef int(*gpr_avl_is_empty_type)(gpr_avl avl);
616
- extern gpr_avl_is_empty_type gpr_avl_is_empty_import;
617
- #define gpr_avl_is_empty gpr_avl_is_empty_import
618
- typedef gpr_cmdline*(*gpr_cmdline_create_type)(const char* description);
619
- extern gpr_cmdline_create_type gpr_cmdline_create_import;
620
- #define gpr_cmdline_create gpr_cmdline_create_import
621
- typedef void(*gpr_cmdline_add_int_type)(gpr_cmdline* cl, const char* name, const char* help, int* value);
622
- extern gpr_cmdline_add_int_type gpr_cmdline_add_int_import;
623
- #define gpr_cmdline_add_int gpr_cmdline_add_int_import
624
- typedef void(*gpr_cmdline_add_flag_type)(gpr_cmdline* cl, const char* name, const char* help, int* value);
625
- extern gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import;
626
- #define gpr_cmdline_add_flag gpr_cmdline_add_flag_import
627
- typedef void(*gpr_cmdline_add_string_type)(gpr_cmdline* cl, const char* name, const char* help, const char** value);
628
- extern gpr_cmdline_add_string_type gpr_cmdline_add_string_import;
629
- #define gpr_cmdline_add_string gpr_cmdline_add_string_import
630
- typedef void(*gpr_cmdline_on_extra_arg_type)(gpr_cmdline* cl, const char* name, const char* help, void (*on_extra_arg)(void* user_data, const char* arg), void* user_data);
631
- extern gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import;
632
- #define gpr_cmdline_on_extra_arg gpr_cmdline_on_extra_arg_import
633
- typedef void(*gpr_cmdline_set_survive_failure_type)(gpr_cmdline* cl);
634
- extern gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import;
635
- #define gpr_cmdline_set_survive_failure gpr_cmdline_set_survive_failure_import
636
- typedef int(*gpr_cmdline_parse_type)(gpr_cmdline* cl, int argc, char** argv);
637
- extern gpr_cmdline_parse_type gpr_cmdline_parse_import;
638
- #define gpr_cmdline_parse gpr_cmdline_parse_import
639
- typedef void(*gpr_cmdline_destroy_type)(gpr_cmdline* cl);
640
- extern gpr_cmdline_destroy_type gpr_cmdline_destroy_import;
641
- #define gpr_cmdline_destroy gpr_cmdline_destroy_import
642
- typedef char*(*gpr_cmdline_usage_string_type)(gpr_cmdline* cl, const char* argv0);
643
- extern gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import;
644
- #define gpr_cmdline_usage_string gpr_cmdline_usage_string_import
645
575
  typedef unsigned(*gpr_cpu_num_cores_type)(void);
646
576
  extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
647
577
  #define gpr_cpu_num_cores gpr_cpu_num_cores_import
648
578
  typedef unsigned(*gpr_cpu_current_cpu_type)(void);
649
579
  extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
650
580
  #define gpr_cpu_current_cpu gpr_cpu_current_cpu_import
651
- typedef int(*gpr_join_host_port_type)(char** out, const char* host, int port);
652
- extern gpr_join_host_port_type gpr_join_host_port_import;
653
- #define gpr_join_host_port gpr_join_host_port_import
654
- typedef int(*gpr_split_host_port_type)(const char* name, char** host, char** port);
655
- extern gpr_split_host_port_type gpr_split_host_port_import;
656
- #define gpr_split_host_port gpr_split_host_port_import
657
581
  typedef const char*(*gpr_log_severity_string_type)(gpr_log_severity severity);
658
582
  extern gpr_log_severity_string_type gpr_log_severity_string_import;
659
583
  #define gpr_log_severity_string gpr_log_severity_string_import
@@ -681,21 +605,6 @@ extern gpr_strdup_type gpr_strdup_import;
681
605
  typedef int(*gpr_asprintf_type)(char** strp, const char* format, ...) GPR_PRINT_FORMAT_CHECK(2, 3);
682
606
  extern gpr_asprintf_type gpr_asprintf_import;
683
607
  #define gpr_asprintf gpr_asprintf_import
684
- typedef const char*(*gpr_subprocess_binary_extension_type)();
685
- extern gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import;
686
- #define gpr_subprocess_binary_extension gpr_subprocess_binary_extension_import
687
- typedef gpr_subprocess*(*gpr_subprocess_create_type)(int argc, const char** argv);
688
- extern gpr_subprocess_create_type gpr_subprocess_create_import;
689
- #define gpr_subprocess_create gpr_subprocess_create_import
690
- typedef void(*gpr_subprocess_destroy_type)(gpr_subprocess* p);
691
- extern gpr_subprocess_destroy_type gpr_subprocess_destroy_import;
692
- #define gpr_subprocess_destroy gpr_subprocess_destroy_import
693
- typedef int(*gpr_subprocess_join_type)(gpr_subprocess* p);
694
- extern gpr_subprocess_join_type gpr_subprocess_join_import;
695
- #define gpr_subprocess_join gpr_subprocess_join_import
696
- typedef void(*gpr_subprocess_interrupt_type)(gpr_subprocess* p);
697
- extern gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import;
698
- #define gpr_subprocess_interrupt gpr_subprocess_interrupt_import
699
608
  typedef void(*gpr_mu_init_type)(gpr_mu* mu);
700
609
  extern gpr_mu_init_type gpr_mu_init_import;
701
610
  #define gpr_mu_init gpr_mu_init_import
@@ -768,30 +677,9 @@ extern gpr_stats_inc_type gpr_stats_inc_import;
768
677
  typedef intptr_t(*gpr_stats_read_type)(const gpr_stats_counter* c);
769
678
  extern gpr_stats_read_type gpr_stats_read_import;
770
679
  #define gpr_stats_read gpr_stats_read_import
771
- typedef int(*gpr_thd_new_type)(gpr_thd_id* t, const char* thd_name, void (*thd_body)(void* arg), void* arg, const gpr_thd_options* options);
772
- extern gpr_thd_new_type gpr_thd_new_import;
773
- #define gpr_thd_new gpr_thd_new_import
774
- typedef gpr_thd_options(*gpr_thd_options_default_type)(void);
775
- extern gpr_thd_options_default_type gpr_thd_options_default_import;
776
- #define gpr_thd_options_default gpr_thd_options_default_import
777
- typedef void(*gpr_thd_options_set_detached_type)(gpr_thd_options* options);
778
- extern gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import;
779
- #define gpr_thd_options_set_detached gpr_thd_options_set_detached_import
780
- typedef void(*gpr_thd_options_set_joinable_type)(gpr_thd_options* options);
781
- extern gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import;
782
- #define gpr_thd_options_set_joinable gpr_thd_options_set_joinable_import
783
- typedef int(*gpr_thd_options_is_detached_type)(const gpr_thd_options* options);
784
- extern gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import;
785
- #define gpr_thd_options_is_detached gpr_thd_options_is_detached_import
786
- typedef int(*gpr_thd_options_is_joinable_type)(const gpr_thd_options* options);
787
- extern gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import;
788
- #define gpr_thd_options_is_joinable gpr_thd_options_is_joinable_import
789
680
  typedef gpr_thd_id(*gpr_thd_currentid_type)(void);
790
681
  extern gpr_thd_currentid_type gpr_thd_currentid_import;
791
682
  #define gpr_thd_currentid gpr_thd_currentid_import
792
- typedef void(*gpr_thd_join_type)(gpr_thd_id t);
793
- extern gpr_thd_join_type gpr_thd_join_import;
794
- #define gpr_thd_join gpr_thd_join_import
795
683
  typedef gpr_timespec(*gpr_time_0_type)(gpr_clock_type type);
796
684
  extern gpr_time_0_type gpr_time_0_import;
797
685
  #define gpr_time_0 gpr_time_0_import
@@ -46,21 +46,38 @@ typedef struct grpc_rb_server {
46
46
  /* The actual server */
47
47
  grpc_server* wrapped;
48
48
  grpc_completion_queue* queue;
49
- gpr_atm shutdown_started;
49
+ int shutdown_and_notify_done;
50
+ int destroy_done;
50
51
  } grpc_rb_server;
51
52
 
52
- static void destroy_server(grpc_rb_server* server, gpr_timespec deadline) {
53
+ static void grpc_rb_server_maybe_shutdown_and_notify(grpc_rb_server* server,
54
+ gpr_timespec deadline) {
53
55
  grpc_event ev;
54
- // This can be started by app or implicitly by GC. Avoid a race between these.
55
- if (gpr_atm_full_fetch_add(&server->shutdown_started, (gpr_atm)1) == 0) {
56
+ void* tag = &ev;
57
+ if (!server->shutdown_and_notify_done) {
58
+ server->shutdown_and_notify_done = 1;
56
59
  if (server->wrapped != NULL) {
57
- grpc_server_shutdown_and_notify(server->wrapped, server->queue, NULL);
58
- ev = rb_completion_queue_pluck(server->queue, NULL, deadline, NULL);
60
+ grpc_server_shutdown_and_notify(server->wrapped, server->queue, tag);
61
+ ev = rb_completion_queue_pluck(server->queue, tag, deadline, NULL);
59
62
  if (ev.type == GRPC_QUEUE_TIMEOUT) {
60
63
  grpc_server_cancel_all_calls(server->wrapped);
61
- rb_completion_queue_pluck(server->queue, NULL,
62
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
64
+ ev = rb_completion_queue_pluck(
65
+ server->queue, tag, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
66
+ }
67
+ if (ev.type != GRPC_OP_COMPLETE) {
68
+ gpr_log(GPR_INFO,
69
+ "GRPC_RUBY: bad grpc_server_shutdown_and_notify result:%d",
70
+ ev.type);
63
71
  }
72
+ }
73
+ }
74
+ }
75
+
76
+ static void grpc_rb_server_maybe_destroy(grpc_rb_server* server) {
77
+ // This can be started by app or implicitly by GC. Avoid a race between these.
78
+ if (!server->destroy_done) {
79
+ server->destroy_done = 1;
80
+ if (server->wrapped != NULL) {
64
81
  grpc_server_destroy(server->wrapped);
65
82
  grpc_rb_completion_queue_destroy(server->queue);
66
83
  server->wrapped = NULL;
@@ -81,7 +98,8 @@ static void grpc_rb_server_free(void* p) {
81
98
  deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
82
99
  gpr_time_from_seconds(2, GPR_TIMESPAN));
83
100
 
84
- destroy_server(svr, deadline);
101
+ grpc_rb_server_maybe_shutdown_and_notify(svr, deadline);
102
+ grpc_rb_server_maybe_destroy(svr);
85
103
 
86
104
  xfree(p);
87
105
  }
@@ -107,7 +125,8 @@ static const rb_data_type_t grpc_rb_server_data_type = {
107
125
  static VALUE grpc_rb_server_alloc(VALUE cls) {
108
126
  grpc_rb_server* wrapper = ALLOC(grpc_rb_server);
109
127
  wrapper->wrapped = NULL;
110
- wrapper->shutdown_started = (gpr_atm)0;
128
+ wrapper->destroy_done = 0;
129
+ wrapper->shutdown_and_notify_done = 0;
111
130
  return TypedData_Wrap_Struct(cls, &grpc_rb_server_data_type, wrapper);
112
131
  }
113
132
 
@@ -232,25 +251,10 @@ static VALUE grpc_rb_server_start(VALUE self) {
232
251
  return Qnil;
233
252
  }
234
253
 
235
- /*
236
- call-seq:
237
- server = Server.new({'arg1': 'value1'})
238
- ... // do stuff with server
239
- ...
240
- ... // to shutdown the server
241
- server.destroy()
242
-
243
- ... // to shutdown the server with a timeout
244
- server.destroy(timeout)
245
-
246
- Destroys server instances. */
247
- static VALUE grpc_rb_server_destroy(int argc, VALUE* argv, VALUE self) {
248
- VALUE timeout = Qnil;
254
+ static VALUE grpc_rb_server_shutdown_and_notify(VALUE self, VALUE timeout) {
249
255
  gpr_timespec deadline;
250
256
  grpc_rb_server* s = NULL;
251
257
 
252
- /* "01" == 0 mandatory args, 1 (timeout) is optional */
253
- rb_scan_args(argc, argv, "01", &timeout);
254
258
  TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
255
259
  if (TYPE(timeout) == T_NIL) {
256
260
  deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
@@ -258,8 +262,26 @@ static VALUE grpc_rb_server_destroy(int argc, VALUE* argv, VALUE self) {
258
262
  deadline = grpc_rb_time_timeval(timeout, /* absolute time*/ 0);
259
263
  }
260
264
 
261
- destroy_server(s, deadline);
265
+ grpc_rb_server_maybe_shutdown_and_notify(s, deadline);
266
+
267
+ return Qnil;
268
+ }
269
+
270
+ /*
271
+ call-seq:
272
+ server = Server.new({'arg1': 'value1'})
273
+ ... // do stuff with server
274
+ ...
275
+ ... // initiate server shutdown
276
+ server.shutdown_and_notify(timeout)
277
+ ... // to shutdown the server
278
+ server.destroy()
262
279
 
280
+ Destroys server instances. */
281
+ static VALUE grpc_rb_server_destroy(VALUE self) {
282
+ grpc_rb_server* s = NULL;
283
+ TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
284
+ grpc_rb_server_maybe_destroy(s);
263
285
  return Qnil;
264
286
  }
265
287
 
@@ -326,7 +348,9 @@ void Init_grpc_server() {
326
348
  rb_define_method(grpc_rb_cServer, "request_call", grpc_rb_server_request_call,
327
349
  0);
328
350
  rb_define_method(grpc_rb_cServer, "start", grpc_rb_server_start, 0);
329
- rb_define_method(grpc_rb_cServer, "destroy", grpc_rb_server_destroy, -1);
351
+ rb_define_method(grpc_rb_cServer, "shutdown_and_notify",
352
+ grpc_rb_server_shutdown_and_notify, 1);
353
+ rb_define_method(grpc_rb_cServer, "destroy", grpc_rb_server_destroy, 0);
330
354
  rb_define_alias(grpc_rb_cServer, "close", "destroy");
331
355
  rb_define_method(grpc_rb_cServer, "add_http2_port",
332
356
  grpc_rb_server_add_http2_port, 2);