ruby/ext/socket
KJ Tsanaktsidis f8effa209a Change the semantics of rb_postponed_job_register
Our current implementation of rb_postponed_job_register suffers from
some safety issues that can lead to interpreter crashes (see bug #1991).
Essentially, the issue is that jobs can be called with the wrong
arguments.

We made two attempts to fix this whilst keeping the promised semantics,
but:
  * The first one involved masking/unmasking when flushing jobs, which
    was believed to be too expensive
  * The second one involved a lock-free, multi-producer, single-consumer
    ringbuffer, which was too complex

The critical insight behind this third solution is that essentially the
only user of these APIs are a) internal, or b) profiling gems.

For a), none of the usages actually require variable data; they will
work just fine with the preregistration interface.

For b), generally profiling gems only call a single callback with a
single piece of data (which is actually usually just zero) for the life
of the program. The ringbuffer is complex because it needs to support
multi-word inserts of job & data (which can't be atomic); but nobody
actually even needs that functionality, really.

So, this comit:
  * Introduces a pre-registration API for jobs, with a GVL-requiring
    rb_postponed_job_prereigster, which returns a handle which can be
    used with an async-signal-safe rb_postponed_job_trigger.
  * Deprecates rb_postponed_job_register (and re-implements it on top of
    the preregister function for compatability)
  * Moves all the internal usages of postponed job register
    pre-registration
2023-12-10 15:00:37 +09:00
..
lib Remove require 'io/wait' where it's no longer necessary. (#6932) 2022-12-15 11:37:01 +13:00
.document
addrinfo.h Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
ancdata.c BasicSocket#recv* return nil rather than an empty packet 2023-08-30 10:07:18 +02:00
basicsocket.c Try nil as default for 'default timeout'. (#6509) 2022-10-08 14:02:34 +13:00
constants.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
depend Change the semantics of rb_postponed_job_register 2023-12-10 15:00:37 +09:00
extconf.rb Set AI_ADDRCONFIG when making getaddrinfo(3) calls for outgoing conns (#7295) 2023-12-07 17:55:15 +09:00
getaddrinfo.c Don't check for null pointer in calls to free 2023-06-30 09:13:31 -04:00
getnameinfo.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
ifaddr.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
init.c Adjust indent [ci skip] 2023-11-30 13:32:53 +09:00
ipsocket.c Set AI_ADDRCONFIG when making getaddrinfo(3) calls for outgoing conns (#7295) 2023-12-07 17:55:15 +09:00
mkconstants.rb sockopt adding Linux constants, SO_INCOMING_CPU/SO_INCOMING_NAPI_ID. 2022-09-21 17:15:54 +09:00
option.c Add support for sockaddr_un on Windows. (#6513) 2022-11-17 14:50:25 -08:00
raddrinfo.c Rename rsock_raise_socket_error to rsock_raise_resolution_error 2023-11-30 13:27:19 +09:00
rubysocket.h Rename rsock_raise_socket_error to rsock_raise_resolution_error 2023-11-30 13:27:19 +09:00
socket.c Rename rsock_raise_socket_error to rsock_raise_resolution_error 2023-11-30 13:27:19 +09:00
sockport.h
sockssocket.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
tcpserver.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
tcpsocket.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
udpsocket.c Set AI_ADDRCONFIG when making getaddrinfo(3) calls for outgoing conns (#7295) 2023-12-07 17:55:15 +09:00
unixserver.c Add support for sockaddr_un on Windows. (#6513) 2022-11-17 14:50:25 -08:00
unixsocket.c fix typo in comments / autodoc 2023-01-16 08:00:03 +09:00