grpc 1.28.0.pre1-universal-darwin → 1.30.1-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.

Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/src/ruby/ext/grpc/rb_call.c +9 -1
  3. data/src/ruby/ext/grpc/rb_call_credentials.c +3 -2
  4. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  5. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  6. data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
  7. data/src/ruby/lib/grpc/2.4/grpc_c.bundle +0 -0
  8. data/src/ruby/lib/grpc/2.5/grpc_c.bundle +0 -0
  9. data/src/ruby/lib/grpc/2.6/grpc_c.bundle +0 -0
  10. data/src/ruby/lib/grpc/2.7/grpc_c.bundle +0 -0
  11. data/src/ruby/lib/grpc/errors.rb +103 -42
  12. data/src/ruby/lib/grpc/generic/active_call.rb +2 -3
  13. data/src/ruby/lib/grpc/generic/interceptors.rb +4 -4
  14. data/src/ruby/lib/grpc/generic/rpc_server.rb +9 -10
  15. data/src/ruby/lib/grpc/generic/service.rb +5 -4
  16. data/src/ruby/lib/grpc/structs.rb +1 -1
  17. data/src/ruby/lib/grpc/version.rb +1 -1
  18. data/src/ruby/pb/generate_proto_ruby.sh +5 -3
  19. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +11 -0
  20. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +16 -0
  21. data/src/ruby/pb/test/xds_client.rb +213 -0
  22. data/src/ruby/spec/debug_message_spec.rb +134 -0
  23. data/src/ruby/spec/generic/service_spec.rb +2 -0
  24. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +5 -0
  25. data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -0
  26. data/src/ruby/spec/support/services.rb +10 -4
  27. data/src/ruby/spec/testdata/ca.pem +18 -13
  28. data/src/ruby/spec/testdata/client.key +26 -14
  29. data/src/ruby/spec/testdata/client.pem +18 -12
  30. data/src/ruby/spec/testdata/server1.key +26 -14
  31. data/src/ruby/spec/testdata/server1.pem +20 -14
  32. metadata +45 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0308422ea8889b82c2e2d0eef23091a6524c68d2b173f9357475cc0f6461bb49'
4
- data.tar.gz: 3fbeca08ae9f5e3ca9c3f1055ed3b0009b74a887c86b84cda871f9f022a9f5cc
3
+ metadata.gz: b92aea8c31926d86f5d5a32fe0a9b88ff387fafb6bf6a148b0a8b17eb27fd496
4
+ data.tar.gz: 6d8cdc913e58289e211a2a9466e39b821c24f75cbb73aeb8546dbc695d789b45
5
5
  SHA512:
6
- metadata.gz: 387af72455dac62282aaee2c3980860e7436250b593082e4b9ced8b959bfcf84d72829f87ea42dc27fd406941cd261638ae753a8682581cf57a54fbc2ad56714
7
- data.tar.gz: 717db9b882727cdcb4f1fd934e6afe0377ef007d7a3fc2a7bad9abd6806086929ddf186e55cfe212bfcf1bfe042958cda8b0c1d55b9a1c743f2c0d4edbab8039
6
+ metadata.gz: 6ac5dc1e39a7db00e25b5404ec34ef434f0cc579d132803cef7bafae07b08f495646ddd21dc89fe74158cf61de039ba7b3753eacbeb1f1d1c83d3eb6b57e19c4
7
+ data.tar.gz: e8aeaf608f1ea0fd1a39dc5366102ef341073e816dde05f7da9c0a2b47e737d41737b54f93c701bbb2b6cbc9e3e1abcc93356b976b0494f54a240533afd1f491
@@ -620,6 +620,7 @@ typedef struct run_batch_stack {
620
620
  int recv_cancelled;
621
621
  grpc_status_code recv_status;
622
622
  grpc_slice recv_status_details;
623
+ const char* recv_status_debug_error_string;
623
624
  unsigned write_flag;
624
625
  grpc_slice send_status_details;
625
626
  } run_batch_stack;
@@ -729,6 +730,8 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) {
729
730
  &st->recv_status;
730
731
  st->ops[st->op_num].data.recv_status_on_client.status_details =
731
732
  &st->recv_status_details;
733
+ st->ops[st->op_num].data.recv_status_on_client.error_string =
734
+ &st->recv_status_debug_error_string;
732
735
  break;
733
736
  case GRPC_OP_RECV_CLOSE_ON_SERVER:
734
737
  st->ops[st->op_num].data.recv_close_on_server.cancelled =
@@ -780,7 +783,12 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
780
783
  (GRPC_SLICE_START_PTR(st->recv_status_details) == NULL
781
784
  ? Qnil
782
785
  : grpc_rb_slice_to_ruby_string(st->recv_status_details)),
783
- grpc_rb_md_ary_to_h(&st->recv_trailing_metadata), NULL));
786
+ grpc_rb_md_ary_to_h(&st->recv_trailing_metadata),
787
+ st->recv_status_debug_error_string == NULL
788
+ ? Qnil
789
+ : rb_str_new_cstr(st->recv_status_debug_error_string),
790
+ NULL));
791
+ gpr_free((void*)st->recv_status_debug_error_string);
784
792
  break;
785
793
  case GRPC_OP_RECV_CLOSE_ON_SERVER:
786
794
  rb_struct_aset(result, sym_send_close, Qtrue);
@@ -109,6 +109,7 @@ static void grpc_rb_call_credentials_callback_with_gil(void* param) {
109
109
  params->callback(params->user_data, md_ary.metadata, md_ary.count, status,
110
110
  error_details);
111
111
  grpc_rb_metadata_array_destroy_including_entries(&md_ary);
112
+ grpc_auth_metadata_context_reset(&params->context);
112
113
  gpr_free(params);
113
114
  }
114
115
 
@@ -118,9 +119,9 @@ static int grpc_rb_call_credentials_plugin_get_metadata(
118
119
  grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
119
120
  size_t* num_creds_md, grpc_status_code* status,
120
121
  const char** error_details) {
121
- callback_params* params = gpr_malloc(sizeof(callback_params));
122
+ callback_params* params = gpr_zalloc(sizeof(callback_params));
122
123
  params->get_metadata = (VALUE)state;
123
- params->context = context;
124
+ grpc_auth_metadata_context_copy(&context, &params->context);
124
125
  params->user_data = user_data;
125
126
  params->callback = cb;
126
127
 
@@ -135,6 +135,8 @@ grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_cred
135
135
  grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import;
136
136
  grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import;
137
137
  grpc_sts_credentials_create_type grpc_sts_credentials_create_import;
138
+ grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import;
139
+ grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import;
138
140
  grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import;
139
141
  grpc_secure_channel_create_type grpc_secure_channel_create_import;
140
142
  grpc_server_credentials_release_type grpc_server_credentials_release_import;
@@ -407,6 +409,8 @@ void grpc_rb_load_imports(HMODULE library) {
407
409
  grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create");
408
410
  grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create");
409
411
  grpc_sts_credentials_create_import = (grpc_sts_credentials_create_type) GetProcAddress(library, "grpc_sts_credentials_create");
412
+ grpc_auth_metadata_context_copy_import = (grpc_auth_metadata_context_copy_type) GetProcAddress(library, "grpc_auth_metadata_context_copy");
413
+ grpc_auth_metadata_context_reset_import = (grpc_auth_metadata_context_reset_type) GetProcAddress(library, "grpc_auth_metadata_context_reset");
410
414
  grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin");
411
415
  grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create");
412
416
  grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release");
@@ -380,6 +380,12 @@ extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_creat
380
380
  typedef grpc_call_credentials*(*grpc_sts_credentials_create_type)(const grpc_sts_credentials_options* options, void* reserved);
381
381
  extern grpc_sts_credentials_create_type grpc_sts_credentials_create_import;
382
382
  #define grpc_sts_credentials_create grpc_sts_credentials_create_import
383
+ typedef void(*grpc_auth_metadata_context_copy_type)(grpc_auth_metadata_context* from, grpc_auth_metadata_context* to);
384
+ extern grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import;
385
+ #define grpc_auth_metadata_context_copy grpc_auth_metadata_context_copy_import
386
+ typedef void(*grpc_auth_metadata_context_reset_type)(grpc_auth_metadata_context* context);
387
+ extern grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import;
388
+ #define grpc_auth_metadata_context_reset grpc_auth_metadata_context_reset_import
383
389
  typedef grpc_call_credentials*(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void* reserved);
384
390
  extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import;
385
391
  #define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import
@@ -30,18 +30,26 @@ module GRPC
30
30
  # https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/status.h
31
31
  # for detailed descriptions of each status code.
32
32
  class BadStatus < StandardError
33
- attr_reader :code, :details, :metadata
33
+ attr_reader :code, :details, :metadata, :debug_error_string
34
34
 
35
35
  include GRPC::Core::StatusCodes
36
36
 
37
37
  # @param code [Numeric] the status code
38
38
  # @param details [String] the details of the exception
39
39
  # @param metadata [Hash] the error's metadata
40
- def initialize(code, details = 'unknown cause', metadata = {})
41
- super("#{code}:#{details}")
40
+ def initialize(code,
41
+ details = 'unknown cause',
42
+ metadata = {},
43
+ debug_error_string = nil)
44
+ exception_message = "#{code}:#{details}"
45
+ if debug_error_string
46
+ exception_message += ". debug_error_string:#{debug_error_string}"
47
+ end
48
+ super(exception_message)
42
49
  @code = code
43
50
  @details = details
44
51
  @metadata = metadata
52
+ @debug_error_string = debug_error_string
45
53
  end
46
54
 
47
55
  # Converts the exception to a {Struct::Status} for use in the networking
@@ -49,7 +57,7 @@ module GRPC
49
57
  #
50
58
  # @return [Struct::Status] with the same code and details
51
59
  def to_status
52
- Struct::Status.new(code, details, metadata)
60
+ Struct::Status.new(code, details, metadata, debug_error_string)
53
61
  end
54
62
 
55
63
  # Converts the exception to a deserialized {Google::Rpc::Status} object.
@@ -66,8 +74,10 @@ module GRPC
66
74
  nil
67
75
  end
68
76
 
69
- def self.new_status_exception(code, details = 'unknown cause',
70
- metadata = {})
77
+ def self.new_status_exception(code,
78
+ details = 'unknown cause',
79
+ metadata = {},
80
+ debug_error_string = nil)
71
81
  codes = {}
72
82
  codes[OK] = Ok
73
83
  codes[CANCELLED] = Cancelled
@@ -88,129 +98,180 @@ module GRPC
88
98
  codes[DATA_LOSS] = DataLoss
89
99
 
90
100
  if codes[code].nil?
91
- BadStatus.new(code, details, metadata)
101
+ BadStatus.new(code, details, metadata, debug_error_string)
92
102
  else
93
- codes[code].new(details, metadata)
103
+ codes[code].new(details, metadata, debug_error_string)
94
104
  end
95
105
  end
96
106
  end
97
107
 
98
108
  # GRPC status code corresponding to status OK
99
109
  class Ok < BadStatus
100
- def initialize(details = 'unknown cause', metadata = {})
101
- super(Core::StatusCodes::OK, details, metadata)
110
+ def initialize(details = 'unknown cause',
111
+ metadata = {},
112
+ debug_error_string = nil)
113
+ super(Core::StatusCodes::OK,
114
+ details, metadata, debug_error_string)
102
115
  end
103
116
  end
104
117
 
105
118
  # GRPC status code corresponding to status CANCELLED
106
119
  class Cancelled < BadStatus
107
- def initialize(details = 'unknown cause', metadata = {})
108
- super(Core::StatusCodes::CANCELLED, details, metadata)
120
+ def initialize(details = 'unknown cause',
121
+ metadata = {},
122
+ debug_error_string = nil)
123
+ super(Core::StatusCodes::CANCELLED,
124
+ details, metadata, debug_error_string)
109
125
  end
110
126
  end
111
127
 
112
128
  # GRPC status code corresponding to status UNKNOWN
113
129
  class Unknown < BadStatus
114
- def initialize(details = 'unknown cause', metadata = {})
115
- super(Core::StatusCodes::UNKNOWN, details, metadata)
130
+ def initialize(details = 'unknown cause',
131
+ metadata = {},
132
+ debug_error_string = nil)
133
+ super(Core::StatusCodes::UNKNOWN,
134
+ details, metadata, debug_error_string)
116
135
  end
117
136
  end
118
137
 
119
138
  # GRPC status code corresponding to status INVALID_ARGUMENT
120
139
  class InvalidArgument < BadStatus
121
- def initialize(details = 'unknown cause', metadata = {})
122
- super(Core::StatusCodes::INVALID_ARGUMENT, details, metadata)
140
+ def initialize(details = 'unknown cause',
141
+ metadata = {},
142
+ debug_error_string = nil)
143
+ super(Core::StatusCodes::INVALID_ARGUMENT,
144
+ details, metadata, debug_error_string)
123
145
  end
124
146
  end
125
147
 
126
148
  # GRPC status code corresponding to status DEADLINE_EXCEEDED
127
149
  class DeadlineExceeded < BadStatus
128
- def initialize(details = 'unknown cause', metadata = {})
129
- super(Core::StatusCodes::DEADLINE_EXCEEDED, details, metadata)
150
+ def initialize(details = 'unknown cause',
151
+ metadata = {},
152
+ debug_error_string = nil)
153
+ super(Core::StatusCodes::DEADLINE_EXCEEDED,
154
+ details, metadata, debug_error_string)
130
155
  end
131
156
  end
132
157
 
133
158
  # GRPC status code corresponding to status NOT_FOUND
134
159
  class NotFound < BadStatus
135
- def initialize(details = 'unknown cause', metadata = {})
136
- super(Core::StatusCodes::NOT_FOUND, details, metadata)
160
+ def initialize(details = 'unknown cause',
161
+ metadata = {},
162
+ debug_error_string = nil)
163
+ super(Core::StatusCodes::NOT_FOUND,
164
+ details, metadata, debug_error_string)
137
165
  end
138
166
  end
139
167
 
140
168
  # GRPC status code corresponding to status ALREADY_EXISTS
141
169
  class AlreadyExists < BadStatus
142
- def initialize(details = 'unknown cause', metadata = {})
143
- super(Core::StatusCodes::ALREADY_EXISTS, details, metadata)
170
+ def initialize(details = 'unknown cause',
171
+ metadata = {},
172
+ debug_error_string = nil)
173
+ super(Core::StatusCodes::ALREADY_EXISTS,
174
+ details, metadata, debug_error_string)
144
175
  end
145
176
  end
146
177
 
147
178
  # GRPC status code corresponding to status PERMISSION_DENIED
148
179
  class PermissionDenied < BadStatus
149
- def initialize(details = 'unknown cause', metadata = {})
150
- super(Core::StatusCodes::PERMISSION_DENIED, details, metadata)
180
+ def initialize(details = 'unknown cause',
181
+ metadata = {},
182
+ debug_error_string = nil)
183
+ super(Core::StatusCodes::PERMISSION_DENIED,
184
+ details, metadata, debug_error_string)
151
185
  end
152
186
  end
153
187
 
154
188
  # GRPC status code corresponding to status UNAUTHENTICATED
155
189
  class Unauthenticated < BadStatus
156
- def initialize(details = 'unknown cause', metadata = {})
157
- super(Core::StatusCodes::UNAUTHENTICATED, details, metadata)
190
+ def initialize(details = 'unknown cause',
191
+ metadata = {},
192
+ debug_error_string = nil)
193
+ super(Core::StatusCodes::UNAUTHENTICATED,
194
+ details, metadata, debug_error_string)
158
195
  end
159
196
  end
160
197
 
161
198
  # GRPC status code corresponding to status RESOURCE_EXHAUSTED
162
199
  class ResourceExhausted < BadStatus
163
- def initialize(details = 'unknown cause', metadata = {})
164
- super(Core::StatusCodes::RESOURCE_EXHAUSTED, details, metadata)
200
+ def initialize(details = 'unknown cause',
201
+ metadata = {},
202
+ debug_error_string = nil)
203
+ super(Core::StatusCodes::RESOURCE_EXHAUSTED,
204
+ details, metadata, debug_error_string)
165
205
  end
166
206
  end
167
207
 
168
208
  # GRPC status code corresponding to status FAILED_PRECONDITION
169
209
  class FailedPrecondition < BadStatus
170
- def initialize(details = 'unknown cause', metadata = {})
171
- super(Core::StatusCodes::FAILED_PRECONDITION, details, metadata)
210
+ def initialize(details = 'unknown cause',
211
+ metadata = {},
212
+ debug_error_string = nil)
213
+ super(Core::StatusCodes::FAILED_PRECONDITION,
214
+ details, metadata, debug_error_string)
172
215
  end
173
216
  end
174
217
 
175
218
  # GRPC status code corresponding to status ABORTED
176
219
  class Aborted < BadStatus
177
- def initialize(details = 'unknown cause', metadata = {})
178
- super(Core::StatusCodes::ABORTED, details, metadata)
220
+ def initialize(details = 'unknown cause',
221
+ metadata = {},
222
+ debug_error_string = nil)
223
+ super(Core::StatusCodes::ABORTED,
224
+ details, metadata, debug_error_string)
179
225
  end
180
226
  end
181
227
 
182
228
  # GRPC status code corresponding to status OUT_OF_RANGE
183
229
  class OutOfRange < BadStatus
184
- def initialize(details = 'unknown cause', metadata = {})
185
- super(Core::StatusCodes::OUT_OF_RANGE, details, metadata)
230
+ def initialize(details = 'unknown cause',
231
+ metadata = {},
232
+ debug_error_string = nil)
233
+ super(Core::StatusCodes::OUT_OF_RANGE,
234
+ details, metadata, debug_error_string)
186
235
  end
187
236
  end
188
237
 
189
238
  # GRPC status code corresponding to status UNIMPLEMENTED
190
239
  class Unimplemented < BadStatus
191
- def initialize(details = 'unknown cause', metadata = {})
192
- super(Core::StatusCodes::UNIMPLEMENTED, details, metadata)
240
+ def initialize(details = 'unknown cause',
241
+ metadata = {},
242
+ debug_error_string = nil)
243
+ super(Core::StatusCodes::UNIMPLEMENTED,
244
+ details, metadata, debug_error_string)
193
245
  end
194
246
  end
195
247
 
196
248
  # GRPC status code corresponding to status INTERNAL
197
249
  class Internal < BadStatus
198
- def initialize(details = 'unknown cause', metadata = {})
199
- super(Core::StatusCodes::INTERNAL, details, metadata)
250
+ def initialize(details = 'unknown cause',
251
+ metadata = {},
252
+ debug_error_string = nil)
253
+ super(Core::StatusCodes::INTERNAL,
254
+ details, metadata, debug_error_string)
200
255
  end
201
256
  end
202
257
 
203
258
  # GRPC status code corresponding to status UNAVAILABLE
204
259
  class Unavailable < BadStatus
205
- def initialize(details = 'unknown cause', metadata = {})
206
- super(Core::StatusCodes::UNAVAILABLE, details, metadata)
260
+ def initialize(details = 'unknown cause',
261
+ metadata = {},
262
+ debug_error_string = nil)
263
+ super(Core::StatusCodes::UNAVAILABLE,
264
+ details, metadata, debug_error_string)
207
265
  end
208
266
  end
209
267
 
210
268
  # GRPC status code corresponding to status DATA_LOSS
211
269
  class DataLoss < BadStatus
212
- def initialize(details = 'unknown cause', metadata = {})
213
- super(Core::StatusCodes::DATA_LOSS, details, metadata)
270
+ def initialize(details = 'unknown cause',
271
+ metadata = {},
272
+ debug_error_string = nil)
273
+ super(Core::StatusCodes::DATA_LOSS,
274
+ details, metadata, debug_error_string)
214
275
  end
215
276
  end
216
277
  end
@@ -23,13 +23,12 @@ class Struct
23
23
  # is non-nil and not OK.
24
24
  def check_status
25
25
  return nil if status.nil?
26
- fail GRPC::Cancelled if status.code == GRPC::Core::StatusCodes::CANCELLED
27
26
  if status.code != GRPC::Core::StatusCodes::OK
28
27
  GRPC.logger.debug("Failing with status #{status}")
29
28
  # raise BadStatus, propagating the metadata if present.
30
- md = status.metadata
31
29
  fail GRPC::BadStatus.new_status_exception(
32
- status.code, status.details, md)
30
+ status.code, status.details, status.metadata,
31
+ status.debug_error_string)
33
32
  end
34
33
  status
35
34
  end
@@ -38,7 +38,7 @@ module GRPC
38
38
  #
39
39
  # @param [Object] request
40
40
  # @param [GRPC::ActiveCall] call
41
- # @param [Method] method
41
+ # @param [String] method
42
42
  # @param [Hash] metadata
43
43
  #
44
44
  def request_response(request: nil, call: nil, method: nil, metadata: nil)
@@ -52,7 +52,7 @@ module GRPC
52
52
  #
53
53
  # @param [Enumerable] requests
54
54
  # @param [GRPC::ActiveCall] call
55
- # @param [Method] method
55
+ # @param [String] method
56
56
  # @param [Hash] metadata
57
57
  #
58
58
  def client_streamer(requests: nil, call: nil, method: nil, metadata: nil)
@@ -66,7 +66,7 @@ module GRPC
66
66
  #
67
67
  # @param [Object] request
68
68
  # @param [GRPC::ActiveCall] call
69
- # @param [Method] method
69
+ # @param [String] method
70
70
  # @param [Hash] metadata
71
71
  #
72
72
  def server_streamer(request: nil, call: nil, method: nil, metadata: nil)
@@ -80,7 +80,7 @@ module GRPC
80
80
  #
81
81
  # @param [Enumerable] requests
82
82
  # @param [GRPC::ActiveCall] call
83
- # @param [Method] method
83
+ # @param [String] method
84
84
  # @param [Hash] metadata
85
85
  #
86
86
  def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil)
@@ -391,22 +391,21 @@ module GRPC
391
391
  # register signal handlers
392
392
  signals.each do |sig|
393
393
  # input validation
394
- if sig.class == String
395
- sig.upcase!
396
- if sig.start_with?('SIG')
397
- # cut out the SIG prefix to see if valid signal
398
- sig = sig[3..-1]
399
- end
400
- end
394
+ target_sig = if sig.class == String
395
+ # cut out the SIG prefix to see if valid signal
396
+ sig.upcase.start_with?('SIG') ? sig.upcase[3..-1] : sig.upcase
397
+ else
398
+ sig
399
+ end
401
400
 
402
401
  # register signal traps for all valid signals
403
- if valid_signals.value?(sig) || valid_signals.key?(sig)
404
- Signal.trap(sig) do
402
+ if valid_signals.value?(target_sig) || valid_signals.key?(target_sig)
403
+ Signal.trap(target_sig) do
405
404
  @stop_server = true
406
405
  @stop_server_cv.broadcast
407
406
  end
408
407
  else
409
- fail "#{sig} not a valid signal"
408
+ fail "#{target_sig} not a valid signal"
410
409
  end
411
410
  end
412
411