hiredis-client 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aa2f8ffa2883aebac37552a2e128a13bf36e79aa9da6ba9be3cc00369230583
4
- data.tar.gz: d786c010f218c5866db63a5e176438d3aee9d7539d443db034aa2b2f788f67f4
3
+ metadata.gz: 41d0ae1321b4fb22b38c20af34e1e2f67d188ee6fb0afab5322ce39b8ed68ff0
4
+ data.tar.gz: d9c9f964c7e2b06cc709e02f1114e81ade65db7faf9c881552bdc43c32c4715d
5
5
  SHA512:
6
- metadata.gz: 230789e6acf2e3bd62c0050b1d13f58546811be59364cb7fe0281d5f7c05970f111eae67665361f23a403ba60931aad33bda5ddaaaca823a02724b13cca0adbb
7
- data.tar.gz: 5e336e18352fc4698794f7885576256027f6d3deb45df3a88fe3533359a7fc6a0ad66fa7616c617ee462831f0f6696e018df9b477f49beca0574734be13adb4a
6
+ metadata.gz: 26f784d95050d5fd3995082794dd831647d6d5195b2ddde2eff53a347d333ab85f3f39af50015a7ea31d1333de831712f3ef0d4f199c2ce3457c586709ffa6e5
7
+ data.tar.gz: 73b33d2c21c79c262a96d73cbf4e66e5afbd670f3767cf1d2293f7ddb03d522af244d3620b8700957d0bf3c80debcc720e1e5d957fb2ebd10f37666ebdbdc170
@@ -155,6 +155,7 @@ static void *reply_append(const redisReadTask *task, VALUE value) {
155
155
  if (task->idx % 2) {
156
156
  VALUE key = rb_ary_pop(state->stack);
157
157
  rb_hash_aset(parent, key, value);
158
+ RB_GC_GUARD(key);
158
159
  } else {
159
160
  rb_ary_push(state->stack, value);
160
161
  }
@@ -163,8 +164,10 @@ static void *reply_append(const redisReadTask *task, VALUE value) {
163
164
  rb_bug("[hiredis] Unexpected task parent type %d", task->parent->type);
164
165
  break;
165
166
  }
167
+ RB_GC_GUARD(parent);
166
168
  }
167
169
  rb_ary_store(state->stack, task_index, value);
170
+ RB_GC_GUARD(value);
168
171
  return (void*)value;
169
172
  }
170
173
 
@@ -464,6 +467,19 @@ static int hiredis_wait_readable(int fd, const struct timeval *timeout, int *iss
464
467
  return 0;
465
468
  }
466
469
 
470
+ struct fd_select {
471
+ rb_fdset_t *write_fds;
472
+ struct timeval *timeout;
473
+ int max;
474
+ int return_value;
475
+ };
476
+
477
+ static VALUE protected_writable_select(VALUE _args) {
478
+ struct fd_select *args = (struct fd_select *)_args;
479
+ args->return_value = rb_thread_fd_select(args->max, NULL, args->write_fds, NULL, args->timeout);
480
+ return Qnil;
481
+ }
482
+
467
483
  static int hiredis_wait_writable(int fd, const struct timeval *timeout, int *isset) {
468
484
  struct timeval to;
469
485
  struct timeval *toptr = NULL;
@@ -480,7 +496,18 @@ static int hiredis_wait_writable(int fd, const struct timeval *timeout, int *iss
480
496
  toptr = &to;
481
497
  }
482
498
 
483
- if (rb_thread_fd_select(fd + 1, NULL, &fds, NULL, toptr) < 0) {
499
+ struct fd_select args = {
500
+ .max = fd + 1,
501
+ .write_fds = &fds,
502
+ .timeout = toptr,
503
+ };
504
+ int status;
505
+
506
+ (void)rb_protect(protected_writable_select, (VALUE)&args, &status);
507
+
508
+ // Error in case an exception arrives in rb_thread_fd_select()
509
+ // (e.g. from Thread.raise)
510
+ if (status || args.return_value < 0) {
484
511
  rb_fd_term(&fds);
485
512
  return -1;
486
513
  }
@@ -498,7 +525,6 @@ static VALUE hiredis_connect_finish(hiredis_connection_t *connection, redisConte
498
525
  redisFree(context);
499
526
  rb_raise(rb_eRuntimeError, "HiredisConnection is already connected, must be a bug");
500
527
  }
501
- connection->context = context;
502
528
 
503
529
  if (context->err) {
504
530
  redis_raise_error_and_disconnect(context, rb_eRedisClientCannotConnectError);
@@ -533,6 +559,7 @@ static VALUE hiredis_connect_finish(hiredis_connection_t *connection, redisConte
533
559
 
534
560
  context->reader->fn = &reply_functions;
535
561
  redisSetPushCallback(context, NULL);
562
+ connection->context = context;
536
563
  return Qtrue;
537
564
  }
538
565
 
@@ -598,9 +625,14 @@ static VALUE hiredis_reconnect(VALUE self, VALUE is_unix, VALUE ssl_param) {
598
625
  return Qfalse;
599
626
  }
600
627
 
601
- hiredis_reconnect_nogvl(connection->context);
628
+ // Clear context on the connection, since the nogvl call can raise an
629
+ // exception after the redisReconnect() call succeeds and leave the
630
+ // connection in a half-initialized state.
631
+ redisContext *context = connection->context;
632
+ connection->context = NULL;
633
+ hiredis_reconnect_nogvl(context);
602
634
 
603
- VALUE success = hiredis_connect_finish(connection, connection->context);
635
+ VALUE success = hiredis_connect_finish(connection, context);
604
636
 
605
637
  if (RTEST(success)) {
606
638
  if (!RTEST(is_unix)) {
@@ -693,8 +725,9 @@ static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply)
693
725
  // We use that to avoid having to have a `mark` function with write barriers.
694
726
  // Not that it would be too hard, but if we mark the response objects, we'll likely end up
695
727
  // promoting them to the old generation which isn't desirable.
728
+ VALUE stack = rb_ary_new();
696
729
  hiredis_reader_state_t reader_state = {
697
- .stack = rb_ary_new(),
730
+ .stack = stack,
698
731
  .task_index = &connection->context->reader->ridx,
699
732
  };
700
733
  connection->context->reader->privdata = &reader_state;
@@ -759,10 +792,10 @@ static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply)
759
792
 
760
793
  /* Set reply object */
761
794
  if (reply != NULL) {
762
- *reply = (VALUE)redis_reply;
795
+ *reply = rb_ary_entry(stack, 0);
763
796
  }
764
797
 
765
- RB_GC_GUARD(reader_state.stack);
798
+ RB_GC_GUARD(stack);
766
799
 
767
800
  return 0;
768
801
  }
@@ -789,6 +822,7 @@ static VALUE hiredis_read(VALUE self) {
789
822
  // See reply_create_bool
790
823
  reply = Qfalse;
791
824
  }
825
+ RB_GC_GUARD(self);
792
826
  return reply;
793
827
  }
794
828
 
@@ -806,7 +840,7 @@ static inline double diff_timespec_ms(const struct timespec *time1, const struct
806
840
  }
807
841
 
808
842
  static inline int timeval_to_msec(struct timeval duration) {
809
- return duration.tv_sec * 1000 + duration.tv_usec / 1000;
843
+ return (int)(duration.tv_sec * 1000 + duration.tv_usec / 1000);
810
844
  }
811
845
 
812
846
  typedef struct {
@@ -895,8 +929,8 @@ RUBY_FUNC_EXPORTED void Init_hiredis_connection(void) {
895
929
  redisInitOpenSSL();
896
930
 
897
931
  id_parse = rb_intern("parse");
898
- Redis_Qfalse = rb_obj_alloc(rb_cObject);
899
932
  rb_global_variable(&Redis_Qfalse);
933
+ Redis_Qfalse = rb_obj_alloc(rb_cObject);
900
934
 
901
935
  VALUE rb_cRedisClient = rb_const_get(rb_cObject, rb_intern("RedisClient"));
902
936
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Hiredis binding for redis-client"
12
12
  spec.homepage = "https://github.com/redis-rb/redis-client"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.5.0"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
15
 
16
16
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiredis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2024-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.19.0
19
+ version: 0.20.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.19.0
26
+ version: 0.20.0
27
27
  description:
28
28
  email:
29
29
  - jean.boussier@gmail.com
@@ -98,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 2.5.0
101
+ version: 2.6.0
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.4.10
108
+ rubygems_version: 3.5.5
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Hiredis binding for redis-client