ds9 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52aad43c3fbf23dbd113f2ee815a52bc06c22f1582adeaa791c9a9087cdd7b79
4
- data.tar.gz: 2c17b45894d4414f76b6389fcdfcc7b61e830e9ba0f12a1c02e40ce23880a7a8
3
+ metadata.gz: e8b2fb157e8388f8d381c77c4676c9d179217648a1712a96e036eebfe1fdd17d
4
+ data.tar.gz: 73283b1afcac1e5703a1d121c0dbe76c17b965b950eae9207ec0d62cf03bcecb
5
5
  SHA512:
6
- metadata.gz: ad3ad16ea6421c40d25a305627df176ca6cb1c718d20214dbabd44567761058987473097781e4560f8ee1a19f47250d117d2435f4ec523c1bb5b86c99e73dfd8
7
- data.tar.gz: 2ac3a5df1c662ff375e07c1a527151c5135a9b3b0647b8fd236ce685f3a26fbfbbc7c48ec12cba44414ab84712b237fcc028db2e36163de50412da98648fc87e
6
+ metadata.gz: 8df87ef9a3b64d895c28f73c102cf4269ef5018b338e873d1f990142deaeca2ec94f6a429610f9ba45d2f3c86807c5009290abe79ee88e46adc77dd8ff86fbbb
7
+ data.tar.gz: ab524840e37027405339a7e9a64c58503322b82ce56893237abe818507229ad3930adaabfbc4cf29e4ab57238f98bb6cf3a0dfb24a32893b588d4bcac77bac86
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake test
data/ext/ds9/ds9.c CHANGED
@@ -23,7 +23,8 @@ ID id_on_header,
23
23
  id_on_stream_close,
24
24
  id_on_data_chunk_recv,
25
25
  id_on_data_source_read,
26
- id_before_frame_send;
26
+ id_before_frame_send,
27
+ id_eof_p;
27
28
 
28
29
  #define CheckSelf(ptr) \
29
30
  if (NULL == (ptr)) \
@@ -157,7 +158,7 @@ static ssize_t recv_callback(nghttp2_session *session, uint8_t *buf,
157
158
  VALUE ret;
158
159
  ssize_t len;
159
160
 
160
- ret = rb_funcall(self, id_recv_event, 1, INT2NUM(length));
161
+ ret = rb_funcall(self, id_recv_event, 1, ULONG2NUM(length));
161
162
 
162
163
  if (FIXNUM_P(ret)) {
163
164
  return NUM2INT(ret);
@@ -270,7 +271,7 @@ static ssize_t rb_data_read_callback(nghttp2_session *session,
270
271
  ssize_t len;
271
272
 
272
273
  ret = rb_funcall(self, id_on_data_source_read, 2, INT2NUM(stream_id),
273
- INT2NUM(length));
274
+ ULONG2NUM(length));
274
275
 
275
276
  if (NIL_P(ret)) {
276
277
  *data_flags |= NGHTTP2_DATA_FLAG_EOF;
@@ -320,8 +321,9 @@ struct hash_copy_ctx {
320
321
  };
321
322
 
322
323
  static int
323
- hash_copy_i(VALUE name, VALUE value, struct hash_copy_ctx * ctx)
324
+ hash_copy_i(VALUE name, VALUE value, VALUE arg)
324
325
  {
326
+ struct hash_copy_ctx *ctx = (struct hash_copy_ctx *)arg;
325
327
  nghttp2_nv * head = ctx->head;
326
328
 
327
329
  head->name = (uint8_t *)StringValuePtr(name);
@@ -341,7 +343,7 @@ static void copy_hash_to_nv(VALUE hash, nghttp2_nv * head, size_t niv)
341
343
  struct hash_copy_ctx copy_ctx;
342
344
  copy_ctx.head = head;
343
345
 
344
- rb_hash_foreach(hash, hash_copy_i, &copy_ctx);
346
+ rb_hash_foreach(hash, hash_copy_i, (VALUE)&copy_ctx);
345
347
  }
346
348
 
347
349
  static VALUE allocate_session(VALUE klass)
@@ -489,6 +491,7 @@ static VALUE session_submit_trailer(VALUE self, VALUE stream_id, VALUE trailers)
489
491
  break;
490
492
  default:
491
493
  Check_Type(trailers, T_ARRAY);
494
+ UNREACHABLE;
492
495
  }
493
496
 
494
497
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -540,7 +543,7 @@ static VALUE session_receive(VALUE self)
540
543
 
541
544
  static VALUE session_mem_receive(VALUE self, VALUE buf)
542
545
  {
543
- int rv;
546
+ ssize_t rv;
544
547
  nghttp2_session *session;
545
548
 
546
549
  TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
@@ -548,10 +551,10 @@ static VALUE session_mem_receive(VALUE self, VALUE buf)
548
551
 
549
552
  rv = nghttp2_session_mem_recv(session, (const uint8_t *)StringValuePtr(buf), RSTRING_LEN(buf));
550
553
  if (rv < 0) {
551
- explode(rv);
554
+ explode((int)rv);
552
555
  }
553
556
 
554
- return INT2NUM(rv);
557
+ return ULONG2NUM(rv);
555
558
  }
556
559
 
557
560
  static VALUE session_mem_send(VALUE self)
@@ -570,7 +573,7 @@ static VALUE session_mem_send(VALUE self)
570
573
  }
571
574
 
572
575
  if (rv < 0) {
573
- explode(rv);
576
+ explode((int)rv);
574
577
  }
575
578
 
576
579
  return rb_str_new((const char *)data, rv);
@@ -583,27 +586,33 @@ static VALUE session_outbound_queue_size(VALUE self)
583
586
  TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
584
587
  CheckSelf(session);
585
588
 
586
- return INT2NUM(nghttp2_session_get_outbound_queue_size(session));
589
+ return ULONG2NUM(nghttp2_session_get_outbound_queue_size(session));
587
590
  }
588
591
 
589
592
  static ssize_t
590
593
  ruby_read(nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t length,
591
594
  uint32_t *data_flags, nghttp2_data_source *source, void *user_data)
592
595
  {
593
- VALUE ret = rb_funcall(source->ptr, rb_intern("read"), 1, INT2NUM(length));
596
+ VALUE body = (VALUE)source->ptr;
597
+ VALUE ret = rb_funcall(body, rb_intern("read"), 1, ULONG2NUM(length));
594
598
 
595
- if (NIL_P(ret)) {
596
- VALUE self = (VALUE)user_data;
597
- rb_funcall(self, rb_intern("remove_post_buffer"), 1, INT2NUM(stream_id));
598
- *data_flags |= NGHTTP2_DATA_FLAG_EOF;
599
- return 0;
600
- } else if (FIXNUM_P(ret)) {
599
+ if (FIXNUM_P(ret)) {
601
600
  ssize_t err = NUM2INT(ret);
602
601
  if (err == NGHTTP2_ERR_DEFERRED) {
603
602
  return err;
604
603
  }
605
604
  }
606
605
 
606
+ if (NIL_P(ret) || (rb_respond_to(body, id_eof_p) && RTEST(rb_funcall(body, id_eof_p, 0)))) {
607
+ VALUE self = (VALUE)user_data;
608
+ rb_funcall(self, rb_intern("remove_post_buffer"), 1, INT2NUM(stream_id));
609
+ *data_flags |= NGHTTP2_DATA_FLAG_EOF;
610
+ }
611
+
612
+ if (NIL_P(ret)) {
613
+ return 0;
614
+ }
615
+
607
616
  Check_Type(ret, T_STRING);
608
617
  memcpy(buf, RSTRING_PTR(ret), RSTRING_LEN(ret));
609
618
  return RSTRING_LEN(ret);
@@ -635,8 +644,8 @@ file_read(nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t leng
635
644
 
636
645
  static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
637
646
  {
638
- size_t niv, i;
639
- nghttp2_nv *nva, *head;
647
+ size_t niv;
648
+ nghttp2_nv *nva;
640
649
  nghttp2_session *session;
641
650
  nghttp2_data_provider provider;
642
651
  int rv;
@@ -657,6 +666,7 @@ static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
657
666
  break;
658
667
  default:
659
668
  Check_Type(settings, T_ARRAY);
669
+ UNREACHABLE;
660
670
  }
661
671
 
662
672
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -673,7 +683,7 @@ static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
673
683
  provider.source.ptr = rb_file;
674
684
  provider.read_callback = file_read;
675
685
  } else {
676
- provider.source.ptr = body;
686
+ provider.source.ptr = (void *)body;
677
687
  provider.read_callback = ruby_read;
678
688
  }
679
689
 
@@ -828,7 +838,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
828
838
  {
829
839
  nghttp2_session *session;
830
840
  size_t niv;
831
- nghttp2_nv *nva, *head;
841
+ nghttp2_nv *nva;
832
842
  nghttp2_data_provider provider;
833
843
  int rv;
834
844
  copy_header_func_t copy_func;
@@ -848,6 +858,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
848
858
  break;
849
859
  default:
850
860
  Check_Type(headers, T_ARRAY);
861
+ UNREACHABLE;
851
862
  }
852
863
 
853
864
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -870,7 +881,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
870
881
  static VALUE server_submit_headers(VALUE self, VALUE stream_id, VALUE headers) {
871
882
  nghttp2_session *session;
872
883
  size_t niv;
873
- nghttp2_nv *nva, *head;
884
+ nghttp2_nv *nva;
874
885
  int rv;
875
886
  copy_header_func_t copy_func;
876
887
 
@@ -889,6 +900,7 @@ static VALUE server_submit_headers(VALUE self, VALUE stream_id, VALUE headers) {
889
900
  break;
890
901
  default:
891
902
  Check_Type(headers, T_ARRAY);
903
+ UNREACHABLE;
892
904
  }
893
905
 
894
906
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -1043,7 +1055,7 @@ void Init_ds9(void)
1043
1055
 
1044
1056
  rb_define_singleton_method(mDS9, "nghttp_version", rb_nghttp_version, 0);
1045
1057
 
1046
- cDS9Callbacks = rb_define_class_under(mDS9, "Callbacks", rb_cData);
1058
+ cDS9Callbacks = rb_define_class_under(mDS9, "Callbacks", rb_cObject);
1047
1059
 
1048
1060
  cDS9Session = rb_define_class_under(mDS9, "Session", rb_cObject);
1049
1061
  cDS9Client = rb_define_class_under(mDS9, "Client", cDS9Session);
@@ -1093,6 +1105,7 @@ void Init_ds9(void)
1093
1105
  id_on_data_chunk_recv = rb_intern("on_data_chunk_recv");
1094
1106
  id_before_frame_send = rb_intern("before_frame_send");
1095
1107
  id_on_data_source_read = rb_intern("on_data_source_read");
1108
+ id_eof_p = rb_intern("eof?");
1096
1109
  }
1097
1110
 
1098
1111
  /* vim: set noet sws=4 sw=4: */
data/ext/ds9/ds9_frames.c CHANGED
@@ -45,7 +45,7 @@ VALUE WrapDS9FrameHeader(const nghttp2_frame_hd *hd)
45
45
  {
46
46
  VALUE klass = rb_const_get(cDS9FramesFrame, rb_intern("Header"));
47
47
  return rb_funcall(klass, rb_intern("new"), 4,
48
- INT2NUM(hd->length),
48
+ ULONG2NUM(hd->length),
49
49
  INT2NUM(hd->stream_id),
50
50
  INT2NUM(hd->type),
51
51
  INT2NUM(hd->flags));
@@ -127,7 +127,7 @@ static VALUE goaway_error_code(VALUE self)
127
127
  void Init_ds9_frames(VALUE mDS9)
128
128
  {
129
129
  mDS9Frames = rb_define_module_under(mDS9, "Frames");
130
- cDS9FramesFrame = rb_define_class_under(mDS9Frames, "Frame", rb_cData);
130
+ cDS9FramesFrame = rb_define_class_under(mDS9Frames, "Frame", rb_cObject);
131
131
 
132
132
  mDS9FramesFlags = rb_define_module_under(cDS9FramesFrame, "Flags");
133
133
 
data/ext/ds9/ds9_option.c CHANGED
@@ -122,6 +122,30 @@ static VALUE option_set_user_recv_extension_type(VALUE self, VALUE size)
122
122
  return self;
123
123
  }
124
124
 
125
+ #if NGHTTP2_VERSION_NUM >= 0x012800 /* 1.40.0 */
126
+ static VALUE option_set_max_outbound_ack(VALUE self, VALUE size)
127
+ {
128
+ nghttp2_option *option;
129
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
130
+
131
+ nghttp2_option_set_max_outbound_ack(option, NUM2INT(size));
132
+
133
+ return self;
134
+ }
135
+ #endif
136
+
137
+ #if NGHTTP2_VERSION_NUM >= 0x012900 /* 1.41.0 */
138
+ static VALUE option_set_max_settings(VALUE self, VALUE size)
139
+ {
140
+ nghttp2_option *option;
141
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
142
+
143
+ nghttp2_option_set_max_settings(option, NUM2INT(size));
144
+
145
+ return self;
146
+ }
147
+ #endif
148
+
125
149
  nghttp2_option* UnwrapDS9Option(VALUE opt)
126
150
  {
127
151
  nghttp2_option* option = NULL;
@@ -135,7 +159,7 @@ nghttp2_option* UnwrapDS9Option(VALUE opt)
135
159
 
136
160
  void Init_ds9_option(VALUE mDS9)
137
161
  {
138
- cDS9Option = rb_define_class_under(mDS9, "Option", rb_cData);
162
+ cDS9Option = rb_define_class_under(mDS9, "Option", rb_cObject);
139
163
  rb_define_alloc_func(cDS9Option, allocate_option);
140
164
 
141
165
  rb_define_method(cDS9Option, "set_no_auto_ping_ack", option_set_no_auto_ping_ack, 0);
@@ -150,4 +174,10 @@ void Init_ds9_option(VALUE mDS9)
150
174
  rb_define_method(cDS9Option, "set_max_reserved_remote_streams", option_set_max_reserved_remote_streams, 1);
151
175
  rb_define_method(cDS9Option, "set_peer_max_concurrent_streams", option_set_peer_max_concurrent_streams, 1);
152
176
  rb_define_method(cDS9Option, "set_user_recv_extension_type", option_set_user_recv_extension_type, 1);
177
+ #if NGHTTP2_VERSION_NUM >= 0x012800 /* 1.40.0 */
178
+ rb_define_method(cDS9Option, "set_max_outbound_ack", option_set_max_outbound_ack, 1);
179
+ #endif
180
+ #if NGHTTP2_VERSION_NUM >= 0x012900 /* 1.41.0 */
181
+ rb_define_method(cDS9Option, "set_max_settings", option_set_max_settings, 1);
182
+ #endif
153
183
  }
data/ext/ds9/extconf.rb CHANGED
@@ -23,12 +23,12 @@ else
23
23
  message "Building nghttp2\n"
24
24
  require 'rubygems'
25
25
  require 'mini_portile2'
26
- recipe = MiniPortile.new('nghttp2', 'v1.34.0')
27
- recipe.configure_options = recipe.configure_options + ['--with-pic', '--disable-python-bindings']
26
+ recipe = MiniPortile.new('nghttp2', 'v1.43.0')
27
+ recipe.configure_options = recipe.configure_options + ['--with-pic', '--enable-lib-only']
28
28
 
29
29
  recipe.files << {
30
- url: 'https://github.com/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.gz',
31
- sha1: '2d0ad93a254a7a6e6c737f2fd2e10e4810a41f74',
30
+ url: 'https://github.com/nghttp2/nghttp2/releases/download/v1.43.0/nghttp2-1.43.0.tar.gz',
31
+ sha1: '8686c8ceee769de8b9e304739b223981df9df104',
32
32
  }
33
33
  recipe.cook
34
34
 
data/lib/ds9/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DS9
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
data/test/helper.rb CHANGED
@@ -12,7 +12,7 @@ trap("INFO") {
12
12
  puts k.backtrace
13
13
  puts "#" * 90
14
14
  end
15
- }
15
+ } if Signal.list.key?("INFO")
16
16
 
17
17
  module DS9
18
18
  class TestCase < Minitest::Test
@@ -84,4 +84,24 @@ class TestMeme < Minitest::Test
84
84
  assert @option.set_user_recv_extension_type('invalid')
85
85
  end
86
86
  end
87
+
88
+ def test_set_max_outbound_ack
89
+ assert @option.set_max_outbound_ack(100)
90
+ end
91
+
92
+ def test_set_max_outbound_ack_with_not_num
93
+ assert_raises TypeError do
94
+ assert @option.set_max_outbound_ack('invalid')
95
+ end
96
+ end
97
+
98
+ def test_set_max_settings
99
+ assert @option.set_max_settings(16)
100
+ end
101
+
102
+ def test_set_max_settings_with_not_num
103
+ assert_raises TypeError do
104
+ assert @option.set_max_settings('invalid')
105
+ end
106
+ end
87
107
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ds9
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  - Yuta Iwama
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2015-07-06 00:00:00.000000000 Z
@@ -95,6 +95,7 @@ extra_rdoc_files:
95
95
  - README.md
96
96
  files:
97
97
  - ".autotest"
98
+ - ".github/workflows/ruby.yml"
98
99
  - ".gitignore"
99
100
  - CHANGELOG.md
100
101
  - Gemfile
@@ -118,7 +119,7 @@ homepage: https://github.com/tenderlove/ds9
118
119
  licenses:
119
120
  - MIT
120
121
  metadata: {}
121
- post_install_message:
122
+ post_install_message:
122
123
  rdoc_options:
123
124
  - "--main"
124
125
  - README.md
@@ -135,8 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  requirements: []
138
- rubygems_version: 3.0.3
139
- signing_key:
139
+ rubygems_version: 3.2.14
140
+ signing_key:
140
141
  specification_version: 4
141
142
  summary: This library allows you to write HTTP/2 clients and servers
142
143
  test_files: []