summary refs log tree commit diff
path: root/socket/getpeername.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2018-02-01 17:57:56 -0200
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2018-02-22 16:43:59 -0300
commit27761a1042daf01987e7d79636d0c41511c6df3c (patch)
tree184aa94def7e3dcc462acfed41ee2ab5197eefbc /socket/getpeername.c
parent92aabad9b20be814f9dad4e7f39999605741366d (diff)
downloadglibc-27761a1042daf01987e7d79636d0c41511c6df3c.tar.gz
glibc-27761a1042daf01987e7d79636d0c41511c6df3c.tar.xz
glibc-27761a1042daf01987e7d79636d0c41511c6df3c.zip
Refactor atfork handlers
Current implementation (sysdeps/nptl/fork.c) replicates the atfork
handlers list backward to invoke the child handlers after fork/clone
syscall.

The internal atfork handlers is implemented as a single-linked list
so a lock-free algorithm can be used, trading fork mulithread call
performance for some code complexity and dynamic stack allocation
(since the backwards list should not fail).

This patch refactor it to use a dynarary instead of a linked list.
It simplifies the external variables need to be exported and also
the internal atfork handler member definition.

The downside is a serialization of fork call in multithread, since to
operate on the dynarray the internal lock should be used.  However
as noted by Florian, it already acquires external locks for malloc
and libio so it is already hitting some lock contention.  Besides,
posix_spawn should be faster and more scalable to run external programs
in multithread environments.

Checked on x86_64-linux-gnu.

	* nptl/Makefile (routines): Remove unregister-atfork.
	* nptl/register-atfork.c (fork_handler_pool): Remove variable.
	(fork_handler_alloc): Remove function.
	(fork_handlers, fork_handler_init): New variables.
	(__fork_lock): Rename to atfork_lock.
	(__register_atfork, __unregister_atfork, libc_freeres_fn): Rewrite
	to use a dynamic array to add/remove atfork handlers.
	* sysdeps/nptl/fork.c (__libc_fork): Likewise.
	* sysdeps/nptl/fork.h (__fork_lock, __fork_handlers, __linkin_atfork):
	Remove declaration.
	(fork_handler): Remove next, refcntr, and need_signal member.
	(__run_fork_handler_type): New enum.
	(__run_fork_handlers): New prototype.
	* sysdeps/nptl/libc-lockP.h (__libc_atfork): Remove declaration.
Diffstat (limited to 'socket/getpeername.c')
0 files changed, 0 insertions, 0 deletions