ffi 1.17.0 → 1.17.1

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: 482fe808cf14286b91be92938712e98f6332021d2773268f96ac583b5c264fc9
4
- data.tar.gz: f89f881dd5e337ec5ec815e9977158b54ead3a2480bc03fd2591477c7872d29e
3
+ metadata.gz: 3a6a87ee152caf4030d9a90bedcefece7f4717639dc96443727b1e1c492db617
4
+ data.tar.gz: 722b6e07fb23b25c2ad2c2e426040e2fb3f929e6dda3c00c26ac7fbc7c7820aa
5
5
  SHA512:
6
- metadata.gz: 877625d5994e1b456e8cf12a68647ce4e9d64efac2239c7a4e1806406b803fad5c1138ba0ad7e8b34ac6b8ebfeaed9f469381291f394527c523c4db8f36bd976
7
- data.tar.gz: 8d78610fc0c110ad7d6da40158dab176d815c8008a1276865b9112a44b46e1d43816db7430f9ab991671e4e8fad4dec0880fa259e2e2c83afaf916f59b7bb5c9
6
+ metadata.gz: a4b65f1f9f9852a7d74c0739eb940f487a85354466b998caf4e637b20046c91a4338c389992de8d42118536624db2bbab4b4de799477af3591701e823355a69c
7
+ data.tar.gz: 6877266da6f47d6d921b8535ee63737caefeb89a937489a1c4756273b87bdcfec93f13e5c9a4dd7c7c56a680d0b1822aecf0197b9b92f778778732cf9fa6556e
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ 1.17.1 / 2024-12-30
2
+ -------------------
3
+
4
+ Fixed:
5
+ * #1117 Restart async callback dispatcher thread after fork.
6
+ * #1133 Add ruby-3.4 native gem.
7
+ * #1134 Fix FFI::DataConverter non-generic usage in RBS files.
8
+
9
+
1
10
  1.17.0 / 2024-06-02
2
11
  -------------------
3
12
 
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ group :development do
5
5
  gem 'bundler', '>= 1.16', '< 3'
6
6
  gem 'rake', '~> 13.0'
7
7
  gem 'rake-compiler', '~> 1.1'
8
- gem 'rake-compiler-dock', '~> 1.0.pre'
8
+ gem 'rake-compiler-dock', '~> 1.7.0'
9
9
  gem 'rspec', '~> 3.0'
10
10
  end
11
11
 
data/Rakefile CHANGED
@@ -136,7 +136,7 @@ namespace "gem" do
136
136
  desc "Build the native gem for #{plat}"
137
137
  task plat => ['prepare', 'build'] do
138
138
  RakeCompilerDock.sh <<-EOT, platform: plat
139
- #{ "sudo apt-get update && sudo apt-get install -y libltdl-dev &&" if plat !~ /linux/ }
139
+ sudo apt-get update && sudo apt-get install -y libltdl-dev &&
140
140
  bundle --local &&
141
141
  rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.4.0/}
142
142
  EOT
data/ext/ffi_c/Function.c CHANGED
@@ -215,6 +215,52 @@ async_cb_dispatcher_set(struct async_cb_dispatcher *ctx)
215
215
  async_cb_dispatcher = ctx;
216
216
  }
217
217
  #endif
218
+
219
+ static void
220
+ async_cb_dispatcher_initialize(struct async_cb_dispatcher *ctx)
221
+ {
222
+ ctx->async_cb_list = NULL;
223
+
224
+ #if !defined(_WIN32)
225
+ /* n.b. we _used_ to try and destroy the mutex/cond before initializing here,
226
+ * but it's undefined what happens if you try and destory an unitialized cond.
227
+ * glibc in particular seems to wait for any concurrent waiters to finish before
228
+ * destroying a condvar, trying to destroy a condvar after fork that someone was
229
+ * waiting on pre-fork won't work. Just re-init he memory directly. */
230
+ pthread_mutex_init(&ctx->async_cb_mutex, NULL);
231
+ pthread_cond_init(&ctx->async_cb_cond, NULL);
232
+ #else
233
+ InitializeCriticalSection(&ctx->async_cb_lock);
234
+ ctx->async_cb_cond = CreateEvent(NULL, FALSE, FALSE, NULL);
235
+ #endif
236
+ ctx->thread = rb_thread_create(async_cb_event, ctx);
237
+
238
+ /* Name thread, for better debugging */
239
+ rb_funcall(ctx->thread, rb_intern("name="), 1, rb_str_new2("FFI Callback Dispatcher"));
240
+ }
241
+
242
+ static struct async_cb_dispatcher *
243
+ async_cb_dispatcher_ensure_created(void)
244
+ {
245
+ struct async_cb_dispatcher *ctx = async_cb_dispatcher_get();
246
+ if (ctx == NULL) {
247
+ ctx = (struct async_cb_dispatcher*)ALLOC(struct async_cb_dispatcher);
248
+ async_cb_dispatcher_initialize(ctx);
249
+ async_cb_dispatcher_set(ctx);
250
+ }
251
+ return ctx;
252
+ }
253
+
254
+
255
+ static VALUE
256
+ async_cb_dispatcher_atfork_child(VALUE self)
257
+ {
258
+ struct async_cb_dispatcher *ctx = async_cb_dispatcher_get();
259
+ if (ctx) {
260
+ async_cb_dispatcher_initialize(ctx);
261
+ }
262
+ return Qnil;
263
+ }
218
264
  #endif
219
265
 
220
266
  static VALUE
@@ -391,15 +437,6 @@ rbffi_Function_ForProc(VALUE rbFunctionInfo, VALUE proc)
391
437
  return callback;
392
438
  }
393
439
 
394
- #if !defined(_WIN32) && defined(DEFER_ASYNC_CALLBACK)
395
- static void
396
- after_fork_callback(void)
397
- {
398
- /* Ensure that a new dispatcher thread is started in a forked process */
399
- async_cb_dispatcher_set(NULL);
400
- }
401
- #endif
402
-
403
440
  static VALUE
404
441
  function_init(VALUE self, VALUE rbFunctionInfo, VALUE rbProc)
405
442
  {
@@ -426,31 +463,7 @@ function_init(VALUE self, VALUE rbFunctionInfo, VALUE rbProc)
426
463
  }
427
464
 
428
465
  #if defined(DEFER_ASYNC_CALLBACK)
429
- {
430
- struct async_cb_dispatcher *ctx = async_cb_dispatcher_get();
431
- if (ctx == NULL) {
432
- ctx = (struct async_cb_dispatcher*)ALLOC(struct async_cb_dispatcher);
433
- ctx->async_cb_list = NULL;
434
-
435
- #if !defined(_WIN32)
436
- pthread_mutex_init(&ctx->async_cb_mutex, NULL);
437
- pthread_cond_init(&ctx->async_cb_cond, NULL);
438
- if( pthread_atfork(NULL, NULL, after_fork_callback) ){
439
- rb_warn("FFI: unable to register fork callback");
440
- }
441
- #else
442
- InitializeCriticalSection(&ctx->async_cb_lock);
443
- ctx->async_cb_cond = CreateEvent(NULL, FALSE, FALSE, NULL);
444
- #endif
445
- ctx->thread = rb_thread_create(async_cb_event, ctx);
446
-
447
- /* Name thread, for better debugging */
448
- rb_funcall(ctx->thread, rb_intern("name="), 1, rb_str_new2("FFI Callback Dispatcher"));
449
-
450
- async_cb_dispatcher_set(ctx);
451
- }
452
- fn->dispatcher = ctx;
453
- }
466
+ fn->dispatcher = async_cb_dispatcher_ensure_created();
454
467
  #endif
455
468
 
456
469
  fn->closure = rbffi_Closure_Alloc(fn->info->closurePool);
@@ -1060,4 +1073,9 @@ rbffi_Function_Init(VALUE moduleFFI)
1060
1073
  #if defined(DEFER_ASYNC_CALLBACK) && defined(HAVE_RB_EXT_RACTOR_SAFE)
1061
1074
  async_cb_dispatcher_key = rb_ractor_local_storage_ptr_newkey(&async_cb_dispatcher_key_type);
1062
1075
  #endif
1076
+ #ifdef DEFER_ASYNC_CALLBACK
1077
+ /* Ruby code will call this method in a Process._fork patch */
1078
+ rb_define_singleton_method(moduleFFI, "_async_cb_dispatcher_atfork_child",
1079
+ async_cb_dispatcher_atfork_child, 0);
1080
+ #endif
1063
1081
  }