From 23444302d9200bcc41ce279a529f73cad63c3f05 Mon Sep 17 00:00:00 2001 From: normal Date: Fri, 4 Jan 2019 13:14:11 +0000 Subject: introduce rb_nogvl C-API to mark ubf as async-signal-safe zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/zlib/zlib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/zlib') diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 1b48bb2677..f1fd2b5c8a 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1011,6 +1011,7 @@ zstream_run_func(void *ptr) /* * There is no safe way to interrupt z->run->func(). + * async-signal-safe */ static void zstream_unblock_func(void *ptr) @@ -1053,8 +1054,9 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush) } loop: - err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)&args, - zstream_unblock_func, (void *)&args); + err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)&args, + zstream_unblock_func, (void *)&args, + RB_NOGVL_UBF_ASYNC_SAFE); if (flush != Z_FINISH && err == Z_BUF_ERROR && z->stream.avail_out > 0) { -- cgit v1.2.3