hiredis-client 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/redis_client/hiredis/extconf.rb +76 -49
- data/ext/redis_client/hiredis/hiredis_connection.c +9 -7
- data/ext/redis_client/hiredis/vendor/hiredis.c +1 -1
- data/ext/redis_client/hiredis/vendor/hiredis.h +1 -0
- data/ext/redis_client/hiredis/vendor/net.c +6 -6
- data/ext/redis_client/hiredis/vendor/net.h +1 -1
- metadata +5 -7
- data/ext/redis_client/hiredis/export.clang +0 -1
- data/ext/redis_client/hiredis/export.gcc +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc000cc925b26584a60d6a74360cf9b39db974e718c6be6af4f19f7e4ac77051
|
4
|
+
data.tar.gz: f54b30ef2a1310200d60d76e310a1ea750001affe145c0994a59e262934e6865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d386889884c0a22a1e44ed346f659aa8f95e74be3363ba891b2ac372efb3b02f18bc14e6ccbe347a6e6f3daae3d48cf376dcb10793272db96574233108157177
|
7
|
+
data.tar.gz: e5264e89206c6d5d723cc1b814867c0e9420ec1f904ca6596a23b840bcc2a0ffe3ae5e2ff9e1069e841eb61d3040d5e916a325a8bb1b325a6b7508261a2df224
|
@@ -2,72 +2,99 @@
|
|
2
2
|
|
3
3
|
require "mkmf"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
class HiredisConnectionExtconf
|
6
|
+
def configure
|
7
|
+
if RUBY_ENGINE == "ruby" && !RUBY_PLATFORM.match?(/mswin/)
|
8
|
+
configure_extension
|
9
|
+
create_makefile("redis_client/hiredis_connection")
|
10
|
+
else
|
11
|
+
File.write("Makefile", dummy_makefile($srcdir).join)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure_extension
|
16
|
+
build_hiredis
|
7
17
|
|
8
|
-
|
18
|
+
have_func("rb_hash_new_capa", "ruby.h")
|
9
19
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
20
|
+
$CFLAGS = concat_flags($CFLAGS, "-I#{hiredis_dir}", "-std=c99", "-fvisibility=hidden")
|
21
|
+
$CFLAGS = if ENV["EXT_PEDANTIC"]
|
22
|
+
concat_flags($CFLAGS, "-Werror", "-g")
|
23
|
+
else
|
24
|
+
concat_flags($CFLAGS, "-O3")
|
25
|
+
end
|
26
|
+
|
27
|
+
append_cflags("-Wno-declaration-after-statement") # Older compilers
|
28
|
+
append_cflags("-Wno-compound-token-split-by-macro") # Older rubies on macos
|
16
29
|
end
|
17
30
|
|
18
|
-
|
31
|
+
def build_hiredis
|
32
|
+
env = {
|
33
|
+
"USE_SSL" => 1,
|
34
|
+
"CFLAGS" => concat_flags(ENV["CFLAGS"], "-fvisibility=hidden"),
|
35
|
+
}
|
36
|
+
env["OPTIMIZATION"] = "-g" if ENV["EXT_PEDANTIC"]
|
19
37
|
|
20
|
-
|
21
|
-
&.split(File::PATH_SEPARATOR)
|
22
|
-
&.detect { |dir| dir.include?("openssl") }
|
38
|
+
env = configure_openssl(env)
|
23
39
|
|
24
|
-
|
25
|
-
|
26
|
-
|
40
|
+
env_args = env.map { |k, v| "#{k}=#{v}" }
|
41
|
+
Dir.chdir(hiredis_dir) do
|
42
|
+
unless system(make_program, "static", *env_args)
|
43
|
+
raise "Building hiredis failed"
|
44
|
+
end
|
45
|
+
end
|
27
46
|
|
28
|
-
|
29
|
-
|
30
|
-
"prefix where OpenSSL is installed."
|
47
|
+
$LDFLAGS = concat_flags($LDFLAGS, "-lssl", "-lcrypto")
|
48
|
+
$libs = concat_flags($libs, "#{hiredis_dir}/libhiredis.a", "#{hiredis_dir}/libhiredis_ssl.a")
|
31
49
|
end
|
32
50
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
51
|
+
def configure_openssl(original_env)
|
52
|
+
original_env.dup.tap do |env|
|
53
|
+
config = dir_config("openssl")
|
54
|
+
if config.none?
|
55
|
+
config = dir_config("opt").map { |c| detect_openssl_dir(c) }
|
56
|
+
end
|
38
57
|
|
39
|
-
|
58
|
+
unless have_header("openssl/ssl.h")
|
59
|
+
message = "ERROR: OpenSSL library could not be found."
|
60
|
+
if config.none?
|
61
|
+
message += "\nUse --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed."
|
62
|
+
end
|
63
|
+
abort message
|
64
|
+
end
|
40
65
|
|
41
|
-
|
42
|
-
|
66
|
+
if config.any?
|
67
|
+
env["CFLAGS"] = concat_flags(env["CFLAGS"], "-I#{config.first}")
|
68
|
+
env["SSL_LDFLAGS"] = "-L#{config.last}"
|
69
|
+
end
|
43
70
|
end
|
44
71
|
end
|
45
72
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
$CFLAGS << " -g "
|
53
|
-
else
|
54
|
-
$CFLAGS << " -O3 "
|
73
|
+
private
|
74
|
+
|
75
|
+
def detect_openssl_dir(paths)
|
76
|
+
paths
|
77
|
+
&.split(File::PATH_SEPARATOR)
|
78
|
+
&.detect { |dir| dir.include?("openssl") }
|
55
79
|
end
|
56
80
|
|
57
|
-
|
58
|
-
|
59
|
-
$LDFLAGS << ' -Wl,-exported_symbols_list,"' << File.join(__dir__, 'export.clang') << '"'
|
60
|
-
if RUBY_VERSION >= "3.2" && RUBY_PATCHLEVEL < 0
|
61
|
-
$LDFLAGS << " -Wl,-exported_symbol,_ruby_abi_version"
|
62
|
-
end
|
63
|
-
elsif cc_version.match?(/gcc/i)
|
64
|
-
$LDFLAGS << ' -Wl,--version-script="' << File.join(__dir__, 'export.gcc') << '"'
|
81
|
+
def concat_flags(*args)
|
82
|
+
args.compact.join(" ")
|
65
83
|
end
|
66
84
|
|
67
|
-
|
68
|
-
|
85
|
+
def hiredis_dir
|
86
|
+
File.expand_path('vendor', __dir__)
|
87
|
+
end
|
69
88
|
|
70
|
-
|
71
|
-
|
72
|
-
|
89
|
+
def make_program
|
90
|
+
with_config("make-prog", ENV["MAKE"]) ||
|
91
|
+
case RUBY_PLATFORM
|
92
|
+
when /(bsd|solaris)/
|
93
|
+
'gmake'
|
94
|
+
else
|
95
|
+
'make'
|
96
|
+
end
|
97
|
+
end
|
73
98
|
end
|
99
|
+
|
100
|
+
HiredisConnectionExtconf.new.configure
|
@@ -64,8 +64,6 @@ typedef struct {
|
|
64
64
|
rb_raise(rb_eArgError, "NULL found for " # name " when shouldn't be."); \
|
65
65
|
}
|
66
66
|
|
67
|
-
void hiredis_ssl_context_mark(void *ptr) { }
|
68
|
-
|
69
67
|
void hiredis_ssl_context_free(void *ptr) {
|
70
68
|
hiredis_ssl_context_t *ssl_context = (hiredis_ssl_context_t *)ptr;
|
71
69
|
if (ssl_context->context) {
|
@@ -83,14 +81,14 @@ static size_t hiredis_ssl_context_memsize(const void *ptr) {
|
|
83
81
|
static const rb_data_type_t hiredis_ssl_context_data_type = {
|
84
82
|
.wrap_struct_name = "redis-client:hiredis_ssl_context",
|
85
83
|
.function = {
|
86
|
-
.dmark =
|
84
|
+
.dmark = NULL,
|
87
85
|
.dfree = hiredis_ssl_context_free,
|
88
86
|
.dsize = hiredis_ssl_context_memsize,
|
89
87
|
#ifdef HAS_GC_COMPACT
|
90
88
|
.dcompact = NULL
|
91
89
|
#endif
|
92
90
|
},
|
93
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
91
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
|
94
92
|
};
|
95
93
|
|
96
94
|
static VALUE hiredis_ssl_context_alloc(VALUE klass) {
|
@@ -482,7 +480,11 @@ static VALUE hiredis_connect_tcp(VALUE self, VALUE host, VALUE port) {
|
|
482
480
|
redisFree(connection->context);
|
483
481
|
connection->context = NULL;
|
484
482
|
}
|
485
|
-
|
483
|
+
redisContext *context = redisConnectNonBlock(StringValuePtr(host), NUM2INT(port));
|
484
|
+
if (context) {
|
485
|
+
redisEnableKeepAlive(context);
|
486
|
+
}
|
487
|
+
return hiredis_connect_finish(connection, context);
|
486
488
|
}
|
487
489
|
|
488
490
|
static VALUE hiredis_connect_unix(VALUE self, VALUE path) {
|
@@ -706,7 +708,7 @@ static VALUE hiredis_read(VALUE self) {
|
|
706
708
|
case HIREDIS_CLIENT_TIMEOUT:
|
707
709
|
// The timeout might have been expected (e.g. `PubSub#next_event`).
|
708
710
|
// we let the caller decide if the connection should be closed.
|
709
|
-
rb_raise(rb_eRedisClientReadTimeoutError, "Unknown Error");
|
711
|
+
rb_raise(rb_eRedisClientReadTimeoutError, "Unknown Error (hiredis_read)");
|
710
712
|
break;
|
711
713
|
}
|
712
714
|
|
@@ -726,7 +728,7 @@ static VALUE hiredis_close(VALUE self) {
|
|
726
728
|
return Qnil;
|
727
729
|
}
|
728
730
|
|
729
|
-
void Init_hiredis_connection(void) {
|
731
|
+
RUBY_FUNC_EXPORTED void Init_hiredis_connection(void) {
|
730
732
|
#ifdef RUBY_ASSERT
|
731
733
|
// Qfalse == NULL, so we can't return Qfalse in `reply_create_bool()`
|
732
734
|
RUBY_ASSERT((void *)Qfalse == NULL);
|
@@ -913,7 +913,7 @@ int redisSetTimeout(redisContext *c, const struct timeval tv) {
|
|
913
913
|
|
914
914
|
/* Enable connection KeepAlive. */
|
915
915
|
int redisEnableKeepAlive(redisContext *c) {
|
916
|
-
if (redisKeepAlive(c, REDIS_KEEPALIVE_INTERVAL) != REDIS_OK)
|
916
|
+
if (redisKeepAlive(c, REDIS_KEEPALIVE_TTL, REDIS_KEEPALIVE_INTERVAL) != REDIS_OK)
|
917
917
|
return REDIS_ERR;
|
918
918
|
return REDIS_OK;
|
919
919
|
}
|
@@ -87,6 +87,7 @@ typedef long long ssize_t;
|
|
87
87
|
#define REDIS_NO_AUTO_FREE 0x200
|
88
88
|
|
89
89
|
#define REDIS_KEEPALIVE_INTERVAL 15 /* seconds */
|
90
|
+
#define REDIS_KEEPALIVE_TTL 120 /* seconds */
|
90
91
|
|
91
92
|
/* number of times we retry to connect in the case of EADDRNOTAVAIL and
|
92
93
|
* SO_REUSEADDR is being used. */
|
@@ -162,7 +162,7 @@ static int redisSetBlocking(redisContext *c, int blocking) {
|
|
162
162
|
return REDIS_OK;
|
163
163
|
}
|
164
164
|
|
165
|
-
int redisKeepAlive(redisContext *c, int interval) {
|
165
|
+
int redisKeepAlive(redisContext *c, int ttl, int interval) {
|
166
166
|
int val = 1;
|
167
167
|
redisFD fd = c->fd;
|
168
168
|
|
@@ -171,28 +171,28 @@ int redisKeepAlive(redisContext *c, int interval) {
|
|
171
171
|
return REDIS_ERR;
|
172
172
|
}
|
173
173
|
|
174
|
-
val = interval;
|
175
|
-
|
176
174
|
#if defined(__APPLE__) && defined(__MACH__)
|
175
|
+
val = ttl;
|
177
176
|
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) {
|
178
177
|
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
|
179
178
|
return REDIS_ERR;
|
180
179
|
}
|
181
180
|
#else
|
182
181
|
#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__)
|
182
|
+
val = interval;
|
183
183
|
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
|
184
184
|
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
|
185
185
|
return REDIS_ERR;
|
186
186
|
}
|
187
187
|
|
188
|
-
val = interval
|
189
|
-
if (val == 0) val = 1;
|
188
|
+
val = interval;
|
190
189
|
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
|
191
190
|
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
|
192
191
|
return REDIS_ERR;
|
193
192
|
}
|
194
193
|
|
195
|
-
val =
|
194
|
+
val = (ttl / interval) - 1;
|
195
|
+
if (val <= 0) val = 1;
|
196
196
|
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof(val)) < 0) {
|
197
197
|
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
|
198
198
|
return REDIS_ERR;
|
@@ -48,7 +48,7 @@ int redisContextConnectBindTcp(redisContext *c, const char *addr, int port,
|
|
48
48
|
const struct timeval *timeout,
|
49
49
|
const char *source_addr);
|
50
50
|
int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout);
|
51
|
-
int redisKeepAlive(redisContext *c, int interval);
|
51
|
+
int redisKeepAlive(redisContext *c, int ttl, int interval);
|
52
52
|
int redisCheckConnectDone(redisContext *c, int *completed);
|
53
53
|
|
54
54
|
int redisSetTcpNoDelay(redisContext *c);
|
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.
|
4
|
+
version: 0.13.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-
|
11
|
+
date: 2023-02-28 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
|
+
version: 0.13.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.
|
26
|
+
version: 0.13.0
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- jean.boussier@gmail.com
|
@@ -33,8 +33,6 @@ extensions:
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- README.md
|
36
|
-
- ext/redis_client/hiredis/export.clang
|
37
|
-
- ext/redis_client/hiredis/export.gcc
|
38
36
|
- ext/redis_client/hiredis/extconf.rb
|
39
37
|
- ext/redis_client/hiredis/hiredis_connection.c
|
40
38
|
- ext/redis_client/hiredis/vendor/.gitignore
|
@@ -107,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
105
|
- !ruby/object:Gem::Version
|
108
106
|
version: '0'
|
109
107
|
requirements: []
|
110
|
-
rubygems_version: 3.4.
|
108
|
+
rubygems_version: 3.4.6
|
111
109
|
signing_key:
|
112
110
|
specification_version: 4
|
113
111
|
summary: Hiredis binding for redis-client
|
@@ -1 +0,0 @@
|
|
1
|
-
_Init_hiredis_connection
|