hiredis-client 0.12.1 → 0.12.2

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: f8361d7ff360c08fcd386d85ba0cb951fcf6dd978119a078f122a75e13e55751
4
- data.tar.gz: bf47f6f6e20b9fd24da10b1139a1ccea9e735b6a2c83848e0f223ee929c18ca0
3
+ metadata.gz: 53a09904c2b65564f3ae0f0d6b3291bdba8d45e1a374fde3ddef66bbeb5b18d6
4
+ data.tar.gz: f33ba8e3ac24c1f56e4a5986f386f7b69dda768f4ce6e57ad7f0c83038ea2340
5
5
  SHA512:
6
- metadata.gz: cb6761fff1950fbd32a56e576158e5ddff00cdc36bec6e4f04d6fd7e919be885f6c5d88e2e26a8d758e430e94bb78cb9e77cb0dbc651335e4833ab3eaeec1d0c
7
- data.tar.gz: 5055f395e2b4495f525ffe0db632622f6ea359ed4e86b4f79e08dac844f41645446598aa0014bca35b296a8bd1b2f0a6e71d062c71399bc73c6a3d5533e66845
6
+ metadata.gz: 2bc1dc250b4c8f3c94b3524f56f0331b13fabf39588a866fb47fc63c05beb5ac86902f477df76ccd6414305173eb99a0a554d8869096dd549c75c5cb7c2dcf7d
7
+ data.tar.gz: '029fe0fb5da33e2e6a9df5751354863f62abc70bab15ca4ed7132705fbe082333f56268a8c3ca82145c0465ed6a44ff069f7b05c932f47228672e1a84858730f'
@@ -2,72 +2,99 @@
2
2
 
3
3
  require "mkmf"
4
4
 
5
- if RUBY_ENGINE == "ruby" && !RUBY_PLATFORM.match?(/mswin/)
6
- have_func("rb_hash_new_capa", "ruby.h")
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
- hiredis_dir = File.expand_path('vendor', __dir__)
18
+ have_func("rb_hash_new_capa", "ruby.h")
9
19
 
10
- make_program = with_config("make-prog", ENV["MAKE"])
11
- make_program ||= case RUBY_PLATFORM
12
- when /(bsd|solaris)/
13
- 'gmake'
14
- else
15
- 'make'
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
- openssl_include, openssl_lib = dir_config("openssl")
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
- openssl_include ||= dir_config("opt").first
21
- &.split(File::PATH_SEPARATOR)
22
- &.detect { |dir| dir.include?("openssl") }
38
+ env = configure_openssl(env)
23
39
 
24
- openssl_lib ||= dir_config("opt").last
25
- &.split(File::PATH_SEPARATOR)
26
- &.detect { |dir| dir.include?("openssl") }
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
- if (!openssl_include || !openssl_lib) && !have_header("openssl/ssl.h")
29
- raise "OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the " \
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
- Dir.chdir(hiredis_dir) do
34
- flags = ["static", "USE_SSL=1"]
35
- if openssl_lib
36
- flags << %(CFLAGS="-I#{openssl_include}") << %(SSL_LDFLAGS="-L#{openssl_lib}")
37
- end
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
- flags << "OPTIMIZATION=-g" if ENV["EXT_PEDANTIC"]
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
- unless system(make_program, *flags)
42
- raise "Building hiredis failed"
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
- $CFLAGS << " -I#{hiredis_dir}"
47
- $LDFLAGS << " -lssl -lcrypto"
48
- $libs << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a "
49
- $CFLAGS << " -std=c99 "
50
- if ENV["EXT_PEDANTIC"]
51
- $CFLAGS << " -Werror"
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
- cc_version = `#{RbConfig.expand("$(CC) --version".dup)}`
58
- if cc_version.match?(/clang/i) && RUBY_PLATFORM =~ /darwin/
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
- $CFLAGS << " -Wno-declaration-after-statement" # Older compilers
68
- $CFLAGS << " -Wno-compound-token-split-by-macro" # Older rubies on macos
85
+ def hiredis_dir
86
+ File.expand_path('vendor', __dir__)
87
+ end
69
88
 
70
- create_makefile("redis_client/hiredis_connection")
71
- else
72
- File.write("Makefile", dummy_makefile($srcdir).join)
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 = hiredis_ssl_context_mark,
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) {
@@ -706,7 +704,7 @@ static VALUE hiredis_read(VALUE self) {
706
704
  case HIREDIS_CLIENT_TIMEOUT:
707
705
  // The timeout might have been expected (e.g. `PubSub#next_event`).
708
706
  // we let the caller decide if the connection should be closed.
709
- rb_raise(rb_eRedisClientReadTimeoutError, "Unknown Error");
707
+ rb_raise(rb_eRedisClientReadTimeoutError, "Unknown Error (hiredis_read)");
710
708
  break;
711
709
  }
712
710
 
@@ -726,7 +724,7 @@ static VALUE hiredis_close(VALUE self) {
726
724
  return Qnil;
727
725
  }
728
726
 
729
- void Init_hiredis_connection(void) {
727
+ RUBY_FUNC_EXPORTED void Init_hiredis_connection(void) {
730
728
  #ifdef RUBY_ASSERT
731
729
  // Qfalse == NULL, so we can't return Qfalse in `reply_create_bool()`
732
730
  RUBY_ASSERT((void *)Qfalse == NULL);
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.12.1
4
+ version: 0.12.2
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-01-16 00:00:00.000000000 Z
11
+ date: 2023-02-16 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.12.1
19
+ version: 0.12.2
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.12.1
26
+ version: 0.12.2
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
@@ -1 +0,0 @@
1
- _Init_hiredis_connection
@@ -1,7 +0,0 @@
1
- hiredis_connection_1.0 {
2
- global:
3
- Init_hiredis_connection;
4
- ruby_abi_version;
5
- local:
6
- *;
7
- };