hiredis-client 0.18.0 → 0.19.1

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: 75375fb66a9a9bc66b60fcb3c6e3a4236c4906b766d6b94cc493bf6eb052ecf8
4
- data.tar.gz: d691dd864136a1b9dc6973272f58e6d505437ac2949404888b317e66979fd77a
3
+ metadata.gz: 6fca3cf8fc6ec3d278b045025946060403d0ab94f8222a114364afad034ca94b
4
+ data.tar.gz: aa46473c0bbe84c4b279cb9bbab14246b39a74578d55932b602ccca15c79eb51
5
5
  SHA512:
6
- metadata.gz: 7e02442df806f1650ebaf94e75b3e98115387351923802ae13d23f7a2b3e1430cf6fe77a930c64962ddf04c8ce9d914d2ab0d1b01005e10ef0de95d4ddeeb392
7
- data.tar.gz: 2857d4e50cf39ed14dd18f4ce25219056479db8e0f140ce995811e49d24c1021f30dcd5411ef9dd0f52b79ee06a9f8e0f59c204bb1447fb08e1cab85ff9134f1
6
+ metadata.gz: 9944f993c9c111c504a66e5a2a976e3480ed10943732410bf68e6142a0c0b0c01c545133f4e021e08c0c8205113b41170bd1ee3da937ae198ef0c9ab768c6a1b
7
+ data.tar.gz: efa20c614f0224f8ea72fbe5bee26a9a260a12b8ee0b4dac4f9a0bd6a2c1e9146e0dbb273419f24c1abc2cf141d0d8272d021e64d55a62db21ac5b7068b45b26
@@ -47,7 +47,7 @@ class HiredisConnectionExtconf
47
47
 
48
48
  env_args = env.map { |k, v| "#{k}=#{v}" }
49
49
  Dir.chdir(hiredis_dir) do
50
- unless system(make_program, "static", *env_args)
50
+ unless system(*Shellwords.split(make_program), "static", *env_args)
51
51
  raise "Building hiredis failed"
52
52
  end
53
53
  end
@@ -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
 
@@ -592,18 +619,23 @@ static VALUE hiredis_connect(VALUE self, VALUE path, VALUE host, VALUE port, VAL
592
619
  return success;
593
620
  }
594
621
 
595
- static VALUE hiredis_reconnect(VALUE self, VALUE unix, VALUE ssl_param) {
622
+ static VALUE hiredis_reconnect(VALUE self, VALUE is_unix, VALUE ssl_param) {
596
623
  CONNECTION(self, connection);
597
624
  if (!connection->context) {
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
- if (!RTEST(unix)) {
638
+ if (!RTEST(is_unix)) {
607
639
  redisEnableKeepAlive(connection->context);
608
640
  }
609
641
 
@@ -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
 
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.18.0
4
+ version: 0.19.1
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-10-26 00:00:00.000000000 Z
11
+ date: 2023-12-21 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.18.0
19
+ version: 0.19.1
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.18.0
26
+ version: 0.19.1
27
27
  description:
28
28
  email:
29
29
  - jean.boussier@gmail.com