diff options
author | Sverker Eriksson <[email protected]> | 2016-10-21 17:01:55 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-11-28 18:35:08 +0100 |
commit | c3cefc3ac9c0487832fecb4eb1eadf1e49e4fa77 (patch) | |
tree | 724d5cc1391e1ff6b19a6b4c23dbe5ad76d71e79 /erts/emulator | |
parent | a85a45b5a384deae60f8020d0805a93df141a7c3 (diff) | |
download | otp-c3cefc3ac9c0487832fecb4eb1eadf1e49e4fa77.tar.gz otp-c3cefc3ac9c0487832fecb4eb1eadf1e49e4fa77.tar.bz2 otp-c3cefc3ac9c0487832fecb4eb1eadf1e49e4fa77.zip |
erts: Refactor add_active_fd
to not inline cold reallocation code.
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/sys/common/erl_check_io.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/erts/emulator/sys/common/erl_check_io.c b/erts/emulator/sys/common/erl_check_io.c index 146f6ae5a1..e6c05faa4c 100644 --- a/erts/emulator/sys/common/erl_check_io.c +++ b/erts/emulator/sys/common/erl_check_io.c @@ -807,6 +807,24 @@ check_cleanup_active_fds(erts_aint_t current_cio_time) erts_smp_atomic32_set_relb(&pollset.active_fd.no, no); } +static void grow_active_fds(void) +{ + ASSERT(pollset.active_fd.six == pollset.active_fd.eix); + pollset.active_fd.six = 0; + pollset.active_fd.eix = pollset.active_fd.size; + pollset.active_fd.size += ERTS_ACTIVE_FD_INC; + pollset.active_fd.array = erts_realloc(ERTS_ALC_T_ACTIVE_FD_ARR, + pollset.active_fd.array, + pollset.active_fd.size*sizeof(ErtsSysFdType)); +#ifdef DEBUG + { + int i; + for (i = pollset.active_fd.eix + 1; i < pollset.active_fd.size; i++) + pollset.active_fd.array[i] = ERTS_SYS_FD_INVALID; + } +#endif +} + static ERTS_INLINE void add_active_fd(ErtsSysFdType fd) { @@ -823,25 +841,11 @@ add_active_fd(ErtsSysFdType fd) eix++; if (eix >= size) eix = 0; - if (pollset.active_fd.six == eix) { - pollset.active_fd.six = 0; - eix = size; - size += ERTS_ACTIVE_FD_INC; - pollset.active_fd.array = erts_realloc(ERTS_ALC_T_ACTIVE_FD_ARR, - pollset.active_fd.array, - sizeof(ErtsSysFdType)*size); - pollset.active_fd.size = size; -#ifdef DEBUG - { - int i; - for (i = eix + 1; i < size; i++) - pollset.active_fd.array[i] = ERTS_SYS_FD_INVALID; - } -#endif + pollset.active_fd.eix = eix; + if (pollset.active_fd.six == eix) { + grow_active_fds(); } - - pollset.active_fd.eix = eix; } int |