diff options
author | Sverker Eriksson <[email protected]> | 2015-06-17 16:49:49 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2015-06-17 16:49:49 +0200 |
commit | 5bb94487ce804f8a075e1c710c447f72d22e3d56 (patch) | |
tree | da0fd7f42e8dc858d2ef3289010c059e71b40351 /erts/emulator/sys/common/erl_check_io.c | |
parent | 00f92e552cb62233ad9dec788f4826b3e1dab4f7 (diff) | |
parent | 7d5f466812b3bc87752ede825ee9d94df730ca54 (diff) | |
download | otp-5bb94487ce804f8a075e1c710c447f72d22e3d56.tar.gz otp-5bb94487ce804f8a075e1c710c447f72d22e3d56.tar.bz2 otp-5bb94487ce804f8a075e1c710c447f72d22e3d56.zip |
Merge branch 'sverk/poll-grow'
* sverk/poll-grow:
erts: Refactor growth of fd tables
Diffstat (limited to 'erts/emulator/sys/common/erl_check_io.c')
-rw-r--r-- | erts/emulator/sys/common/erl_check_io.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/erts/emulator/sys/common/erl_check_io.c b/erts/emulator/sys/common/erl_check_io.c index d1d6696090..3097f7b7dd 100644 --- a/erts/emulator/sys/common/erl_check_io.c +++ b/erts/emulator/sys/common/erl_check_io.c @@ -41,8 +41,7 @@ #define ERTS_WANT_TIMER_WHEEL_API #include "erl_time.h" -#ifdef ERTS_SYS_CONTINOUS_FD_NUMBERS -#else +#ifndef ERTS_SYS_CONTINOUS_FD_NUMBERS # include "safe_hash.h" # define DRV_EV_STATE_HTAB_SIZE 1024 #endif @@ -413,14 +412,16 @@ static void grow_drv_ev_state(int min_ix) { int i; + int old_len; int new_len; - new_len = ERTS_POLL_EXPORT(erts_poll_get_table_len)(min_ix + 1); - if (new_len > max_fds) - new_len = max_fds; - erts_smp_mtx_lock(&drv_ev_state_grow_lock); - if (erts_smp_atomic_read_nob(&drv_ev_state_len) <= min_ix) { + old_len = erts_smp_atomic_read_nob(&drv_ev_state_len); + if (min_ix >= old_len) { + new_len = erts_poll_new_table_len(old_len, min_ix + 1); + if (new_len > max_fds) + new_len = max_fds; + for (i=0; i<DRV_EV_STATE_LOCK_CNT; i++) { /* lock all fd's */ erts_smp_mtx_lock(&drv_ev_state_locks[i].lck); } @@ -430,7 +431,7 @@ grow_drv_ev_state(int min_ix) sizeof(ErtsDrvEventState)*new_len) : erts_alloc(ERTS_ALC_T_DRV_EV_STATE, sizeof(ErtsDrvEventState)*new_len)); - for (i = erts_smp_atomic_read_nob(&drv_ev_state_len); i < new_len; i++) { + for (i = old_len; i < new_len; i++) { drv_ev_state[i].fd = (ErtsSysFdType) i; drv_ev_state[i].driver.select = NULL; #if ERTS_CIO_HAVE_DRV_EVENT |