hiredis-client 0.10.0 → 0.11.0

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: 8ab993c8bd2fc54e8817b047d657409ee3cf3ab8256884c052358cf4178d2835
4
- data.tar.gz: 49298a0eedee98b454ece01d08de52d68291383ceccc5146f129cab4f2d87095
3
+ metadata.gz: 4c30e3ee9498ead669c8f956cdd01a5f5c461af38a8eedaca5726622663d5284
4
+ data.tar.gz: '086288891e30a5b1966b60279af5eb7b3573a5cbb35ce64b974ca289a9eedbf1'
5
5
  SHA512:
6
- metadata.gz: 1994b4d87d9b0ca699f4ab9a1b35d7f58834e1186ce8df4dbb57958b4a3a4e7db5379efa9e27c62ab01245c8d354babdd9a173234eaebfbb6e2187b8910ad419
7
- data.tar.gz: 8bdfe9124ab8b8b491bd90b5effef54465bcf512c18fefe84c8af83dad396306d5cbd88e02ce84fd9db6835766bdbbcb055a2b3cc52a33cf149decbd802736f6
6
+ metadata.gz: be4dd95865da29525ee3a6ce4b1cc8c7c3813e6589a3dc97a6270dc8bdbe99803cfe46c581ab4f255d2b9e8470e3dc9557d30061870c266197974703da5447f7
7
+ data.tar.gz: 17015559919a8008b8ad66cf743134f16cb91c19be7c97685faa0bb8a02b49dabdb66986eadc00269af61ace4e9ce62a0b336d0619d64fb56beccaa1364b75ff
@@ -618,14 +618,17 @@ static VALUE hiredis_flush(VALUE self) {
618
618
  return Qtrue;
619
619
  }
620
620
 
621
+
622
+ #define HIREDIS_FATAL_CONNECTION_ERROR -1
623
+ #define HIREDIS_CLIENT_TIMEOUT -2
624
+
621
625
  static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply) {
622
626
  void *redis_reply = NULL;
623
627
  int wdone = 0;
624
628
 
625
629
  /* Try to read pending replies */
626
630
  if (redisGetReplyFromReader(connection->context, &redis_reply) == REDIS_ERR) {
627
- /* Protocol error */
628
- return -1;
631
+ return HIREDIS_FATAL_CONNECTION_ERROR; // Protocol error
629
632
  }
630
633
 
631
634
  if (redis_reply == NULL) {
@@ -634,20 +637,19 @@ static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply)
634
637
  errno = 0;
635
638
 
636
639
  if (hiredis_buffer_write_nogvl(connection->context, &wdone) == REDIS_ERR) {
637
- /* Socket error */
638
- return -1;
640
+ return HIREDIS_FATAL_CONNECTION_ERROR; // Socket error
639
641
  }
640
642
 
641
643
  if (errno == EAGAIN) {
642
644
  int writable = 0;
643
645
 
644
646
  if (hiredis_wait_writable(connection->context->fd, &connection->write_timeout, &writable) < 0) {
645
- return -2;
647
+ return HIREDIS_CLIENT_TIMEOUT;
646
648
  }
647
649
 
648
650
  if (!writable) {
649
651
  errno = EAGAIN;
650
- return -2;
652
+ return HIREDIS_CLIENT_TIMEOUT;
651
653
  }
652
654
  }
653
655
  }
@@ -657,20 +659,19 @@ static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply)
657
659
  errno = 0;
658
660
 
659
661
  if (hiredis_buffer_read_nogvl(connection->context) == REDIS_ERR) {
660
- /* Socket error */
661
- return -1;
662
+ return HIREDIS_FATAL_CONNECTION_ERROR; // Socket error
662
663
  }
663
664
 
664
665
  if (errno == EAGAIN) {
665
666
  int readable = 0;
666
667
 
667
668
  if (hiredis_wait_readable(connection->context->fd, &connection->read_timeout, &readable) < 0) {
668
- return -2;
669
+ return HIREDIS_CLIENT_TIMEOUT;
669
670
  }
670
671
 
671
672
  if (!readable) {
672
673
  errno = EAGAIN;
673
- return -2;
674
+ return HIREDIS_CLIENT_TIMEOUT;
674
675
  }
675
676
 
676
677
  /* Retry */
@@ -678,8 +679,7 @@ static int hiredis_read_internal(hiredis_connection_t *connection, VALUE *reply)
678
679
  }
679
680
 
680
681
  if (redisGetReplyFromReader(connection->context, &redis_reply) == REDIS_ERR) {
681
- /* Protocol error */
682
- return -1;
682
+ return HIREDIS_FATAL_CONNECTION_ERROR; // Protocol error
683
683
  }
684
684
  }
685
685
  }
@@ -697,9 +697,19 @@ static VALUE hiredis_read(VALUE self) {
697
697
  ENSURE_CONNECTED(connection);
698
698
 
699
699
  VALUE reply = Qnil;
700
- if (hiredis_read_internal(connection, &reply)) {
701
- hiredis_raise_error_and_disconnect(connection, rb_eRedisClientReadTimeoutError);
700
+ switch (hiredis_read_internal(connection, &reply)) {
701
+ case HIREDIS_FATAL_CONNECTION_ERROR:
702
+ // The error is unrecoverable, we eagerly close the connection to ensure
703
+ // it won't be re-used.
704
+ hiredis_raise_error_and_disconnect(connection, rb_eRedisClientReadTimeoutError);
705
+ break;
706
+ case HIREDIS_CLIENT_TIMEOUT:
707
+ // The timeout might have been expected (e.g. `PubSub#next_event`).
708
+ // we let the caller decide if the connection should be closed.
709
+ rb_raise(rb_eRedisClientReadTimeoutError, "Unknown Error");
710
+ break;
702
711
  }
712
+
703
713
  if (reply == Redis_Qfalse) {
704
714
  // See reply_create_bool
705
715
  reply = Qfalse;
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.10.0
4
+ version: 0.11.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: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-11-01 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.10.0
19
+ version: 0.11.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.10.0
26
+ version: 0.11.0
27
27
  description:
28
28
  email:
29
29
  - jean.boussier@gmail.com