hiredis-client 0.10.0 → 0.11.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: 8ab993c8bd2fc54e8817b047d657409ee3cf3ab8256884c052358cf4178d2835
4
- data.tar.gz: 49298a0eedee98b454ece01d08de52d68291383ceccc5146f129cab4f2d87095
3
+ metadata.gz: 0f8f2c48819ebcd284e5de3249de6d76779f9d7914aa964eb78f630d846412ad
4
+ data.tar.gz: 9fa6140bf1d26b2f9a81df883c4242f73d519b274530379ec485f7babde9d99f
5
5
  SHA512:
6
- metadata.gz: 1994b4d87d9b0ca699f4ab9a1b35d7f58834e1186ce8df4dbb57958b4a3a4e7db5379efa9e27c62ab01245c8d354babdd9a173234eaebfbb6e2187b8910ad419
7
- data.tar.gz: 8bdfe9124ab8b8b491bd90b5effef54465bcf512c18fefe84c8af83dad396306d5cbd88e02ce84fd9db6835766bdbbcb055a2b3cc52a33cf149decbd802736f6
6
+ metadata.gz: 7a117bd47809ba3c8b1433607d240fd6dacf39fa253589b56506bee2435342afed569e45ef418880600cab67c231e1bc7a50cab62c135e9c1f834f824de9c0e0
7
+ data.tar.gz: 82d7ef4754a544649d1f999e196851ddea81e3a72ac418fc2a0bf3516301be5ef0b1b23cf9ab5bdb7d19958db483c4ba54dd973094800951e394ce0710868b4b
@@ -1,2 +1 @@
1
1
  _Init_hiredis_connection
2
- _ruby_abi_version
@@ -54,9 +54,13 @@ if RUBY_ENGINE == "ruby" && !RUBY_PLATFORM.match?(/mswin/)
54
54
  $CFLAGS << " -O3 "
55
55
  end
56
56
 
57
- if `cc --version`.match?(/ clang /i) || RbConfig::CONFIG['CC'].match?(/clang/i)
57
+ cc_version = `#{RbConfig.expand("$(CC) --version".dup)}`
58
+ if cc_version.match?(/clang/i)
58
59
  $LDFLAGS << ' -Wl,-exported_symbols_list,"' << File.join(__dir__, 'export.clang') << '"'
59
- elsif RbConfig::CONFIG['CC'].match?(/gcc/i)
60
+ if RUBY_VERSION >= "3.2"
61
+ $LDFLAGS << " -Wl,-exported_symbol,_ruby_abi_version"
62
+ end
63
+ elsif cc_version.match?(/gcc/i)
60
64
  $LDFLAGS << ' -Wl,--version-script="' << File.join(__dir__, 'export.gcc') << '"'
61
65
  end
62
66
 
@@ -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.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: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-11-04 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.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.10.0
26
+ version: 0.11.1
27
27
  description:
28
28
  email:
29
29
  - jean.boussier@gmail.com