google-protobuf 3.4.0.2 → 3.4.1.1

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

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e649f74ca37cae3e3ee09490452c96fdf8c3b242
4
- data.tar.gz: 0424fa004b99e50c911ede280739ba1013ea1874
3
+ metadata.gz: 3e4923c7d4a55e1b8e1418604e54be9fb09c3a92
4
+ data.tar.gz: 60355d3f9c08007addc21e527aab9a01c1ee7201
5
5
  SHA512:
6
- metadata.gz: 8774e564fcf50096df3b74e93cb68fc3f1da91e45fc6e6d08a2ef9c38d97b9992b1d508467906835027e729eec8748cd53a3e3412ff4a64e741503170cc84ad1
7
- data.tar.gz: c3adaffa91fb5e19e8b23967825ab4062d887d1e724bfb94057f5f6ebda39743163517061fa264baaf86ddd480f9d4d8fe29718fd822ea2ed9bc0f7de1b8dfcd
6
+ metadata.gz: d27851eb2b67978a42516325b758c68ec02713b00cc7fc6342f564bcfd0eba4f4039caca734df5d9a68f1ced5e2f50e7df21fc985143c5f2e7e35d3d037ef3da
7
+ data.tar.gz: 4abdf4a177f2f51ad990b51c772c834d369aa555c55eb83a52672d5c54e7b7c6cc01279034c6b9761bbfe1993a78862130ec3f74c0daffe305ebcfa9cd2a6aa3
@@ -280,11 +280,6 @@ rb_data_type_t MapParseFrame_type = {
280
280
  { MapParseFrame_mark, MapParseFrame_free, NULL },
281
281
  };
282
282
 
283
- // Array of Ruby objects wrapping map_parse_frame_t.
284
- // We don't allow multiple concurrent decodes, so we assume that this global
285
- // variable is specific to the "current" decode.
286
- VALUE map_parse_frames;
287
-
288
283
  static map_parse_frame_t* map_push_frame(VALUE map,
289
284
  const map_handlerdata_t* handlerdata) {
290
285
  map_parse_frame_t* frame = ALLOC(map_parse_frame_t);
@@ -293,16 +288,12 @@ static map_parse_frame_t* map_push_frame(VALUE map,
293
288
  native_slot_init(handlerdata->key_field_type, &frame->key_storage);
294
289
  native_slot_init(handlerdata->value_field_type, &frame->value_storage);
295
290
 
296
- rb_ary_push(map_parse_frames,
291
+ Map_set_frame(map,
297
292
  TypedData_Wrap_Struct(rb_cObject, &MapParseFrame_type, frame));
298
293
 
299
294
  return frame;
300
295
  }
301
296
 
302
- static void map_pop_frame() {
303
- rb_ary_pop(map_parse_frames);
304
- }
305
-
306
297
  // Handler to begin a map entry: allocates a temporary frame. This is the
307
298
  // 'startsubmsg' handler on the msgdef that contains the map field.
308
299
  static void *startmapentry_handler(void *closure, const void *hd) {
@@ -336,7 +327,7 @@ static bool endmap_handler(void *closure, const void *hd, upb_status* s) {
336
327
  &frame->value_storage);
337
328
 
338
329
  Map_index_set(frame->map, key, value);
339
- map_pop_frame();
330
+ Map_set_frame(frame->map, Qnil);
340
331
 
341
332
  return true;
342
333
  }
@@ -775,10 +766,6 @@ VALUE Message_decode(VALUE klass, VALUE data) {
775
766
  msg_rb = rb_class_new_instance(0, NULL, msgklass);
776
767
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
777
768
 
778
- // We generally expect this to be clear already, but clear it in case parsing
779
- // previously got interrupted somehow.
780
- rb_ary_clear(map_parse_frames);
781
-
782
769
  {
783
770
  const upb_pbdecodermethod* method = msgdef_decodermethod(desc);
784
771
  const upb_handlers* h = upb_pbdecodermethod_desthandlers(method);
@@ -823,10 +810,6 @@ VALUE Message_decode_json(VALUE klass, VALUE data) {
823
810
  msg_rb = rb_class_new_instance(0, NULL, msgklass);
824
811
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
825
812
 
826
- // We generally expect this to be clear already, but clear it in case parsing
827
- // previously got interrupted somehow.
828
- rb_ary_clear(map_parse_frames);
829
-
830
813
  {
831
814
  const upb_json_parsermethod* method = msgdef_jsonparsermethod(desc);
832
815
  stackenv se;
@@ -146,6 +146,7 @@ void Map_mark(void* _self) {
146
146
  Map* self = _self;
147
147
 
148
148
  rb_gc_mark(self->value_type_class);
149
+ rb_gc_mark(self->parse_frame);
149
150
 
150
151
  if (self->value_type == UPB_TYPE_STRING ||
151
152
  self->value_type == UPB_TYPE_BYTES ||
@@ -174,6 +175,12 @@ VALUE Map_alloc(VALUE klass) {
174
175
  return TypedData_Wrap_Struct(klass, &Map_type, self);
175
176
  }
176
177
 
178
+ VALUE Map_set_frame(VALUE map, VALUE val) {
179
+ Map* self = ruby_to_Map(map);
180
+ self->parse_frame = val;
181
+ return val;
182
+ }
183
+
177
184
  static bool needs_typeclass(upb_fieldtype_t type) {
178
185
  switch (type) {
179
186
  case UPB_TYPE_MESSAGE:
@@ -227,6 +234,7 @@ VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
227
234
 
228
235
  self->key_type = ruby_to_fieldtype(argv[0]);
229
236
  self->value_type = ruby_to_fieldtype(argv[1]);
237
+ self->parse_frame = Qnil;
230
238
 
231
239
  // Check that the key type is an allowed type.
232
240
  switch (self->key_type) {
@@ -112,6 +112,4 @@ void Init_protobuf_c() {
112
112
 
113
113
  upb_def_to_ruby_obj_map = rb_hash_new();
114
114
  rb_gc_register_address(&upb_def_to_ruby_obj_map);
115
- map_parse_frames = rb_ary_new();
116
- rb_gc_register_address(&map_parse_frames);
117
115
  }
@@ -166,8 +166,6 @@ extern VALUE cBuilder;
166
166
  extern VALUE cError;
167
167
  extern VALUE cParseError;
168
168
 
169
- extern VALUE map_parse_frames;
170
-
171
169
  // We forward-declare all of the Ruby method implementations here because we
172
170
  // sometimes call the methods directly across .c files, rather than going
173
171
  // through Ruby's method dispatching (e.g. during message parse). It's cleaner
@@ -397,6 +395,7 @@ typedef struct {
397
395
  upb_fieldtype_t key_type;
398
396
  upb_fieldtype_t value_type;
399
397
  VALUE value_type_class;
398
+ VALUE parse_frame;
400
399
  upb_strtable table;
401
400
  } Map;
402
401
 
@@ -405,6 +404,7 @@ void Map_free(void* self);
405
404
  VALUE Map_alloc(VALUE klass);
406
405
  VALUE Map_init(int argc, VALUE* argv, VALUE self);
407
406
  void Map_register(VALUE module);
407
+ VALUE Map_set_frame(VALUE self, VALUE val);
408
408
 
409
409
  extern const rb_data_type_t Map_type;
410
410
  extern VALUE cMap;
@@ -96,8 +96,18 @@ module BasicTest
96
96
  optional :d, :enum, 4, "TestEnum"
97
97
  end
98
98
  end
99
+
100
+ add_message "repro.Outer" do
101
+ map :items, :int32, :message, 1, "repro.Inner"
102
+ end
103
+
104
+ add_message "repro.Inner" do
105
+ end
99
106
  end
100
107
 
108
+
109
+ Outer = pool.lookup("repro.Outer").msgclass
110
+ Inner = pool.lookup("repro.Inner").msgclass
101
111
  Foo = pool.lookup("Foo").msgclass
102
112
  Bar = pool.lookup("Bar").msgclass
103
113
  Baz = pool.lookup("Baz").msgclass
@@ -675,6 +685,21 @@ module BasicTest
675
685
  m.map_string_int32['aaa'] = 3
676
686
  end
677
687
 
688
+ def test_concurrent_decoding
689
+ o = Outer.new
690
+ o.items[0] = Inner.new
691
+ raw = Outer.encode(o)
692
+
693
+ thds = 2.times.map do
694
+ Thread.new do
695
+ 100000.times do
696
+ assert_equal o, Outer.decode(raw)
697
+ end
698
+ end
699
+ end
700
+ thds.map(&:join)
701
+ end
702
+
678
703
  def test_map_encode_decode
679
704
  m = MapMessage.new(
680
705
  :map_string_int32 => {"a" => 1, "b" => 2},
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0.2
4
+ version: 3.4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock