diff options
author | Erlang/OTP <[email protected]> | 2019-01-24 09:03:08 +0100 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2019-01-24 09:03:08 +0100 |
commit | 62c915fca28bd521c740340f678a85df76765045 (patch) | |
tree | 3fd3f47e9ebb5cb994869d952bdf846484c0bf66 /erts | |
parent | 3f4b17036bb6dbd302da3c38830512439b146e34 (diff) | |
parent | 51fdf17ef9703692b1de4cec67cc64e84ba1accc (diff) | |
download | otp-62c915fca28bd521c740340f678a85df76765045.tar.gz otp-62c915fca28bd521c740340f678a85df76765045.tar.bz2 otp-62c915fca28bd521c740340f678a85df76765045.zip |
Merge branch 'lukas/erts/fix_inet_multitimer_cleanup/OTP-15536' into maint-21
* lukas/erts/fix_inet_multitimer_cleanup/OTP-15536:
erts: Fix cleanup of the inet MultiTimer
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/drivers/common/inet_drv.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 47eb5df7dd..31c9ce2d0b 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -12956,38 +12956,40 @@ make_noninheritable_handle(SOCKET s) static void fire_multi_timers(tcp_descriptor *desc, ErlDrvPort port, ErlDrvData data) { - ErlDrvTime next_timeout; - MultiTimerData *curr = desc->mtd; - if (!curr) { - ASSERT(0); - return; + ErlDrvTime next_timeout = 0; + if (!desc->mtd) { + ASSERT(0); + return; } #ifdef DEBUG { ErlDrvTime chk = erl_drv_monotonic_time(ERL_DRV_MSEC); - ASSERT(chk >= curr->when); + ASSERT(chk >= desc->mtd->when); } #endif do { - MultiTimerData *save = curr; + MultiTimerData save = *desc->mtd; - (*(save->timeout_function))(data,save->caller); + /* We first remove the timer so that the timeout_functions has + can call clean_multi_timers without breaking anything */ + if (desc->mtd_cache == NULL) { + desc->mtd_cache = desc->mtd; + } else { + FREE(desc->mtd); + } - curr = curr->next; + desc->mtd = save.next; + if (desc->mtd != NULL) + desc->mtd->prev = NULL; - if (desc->mtd_cache == NULL) - desc->mtd_cache = save; - else - FREE(save); + (*(save.timeout_function))(data,save.caller); - if (curr == NULL) { - desc->mtd = NULL; + if (desc->mtd == NULL) return; - } - curr->prev = NULL; - next_timeout = curr->when - erl_drv_monotonic_time(ERL_DRV_MSEC); + + next_timeout = desc->mtd->when - erl_drv_monotonic_time(ERL_DRV_MSEC); } while (next_timeout <= 0); - desc->mtd = curr; + driver_set_timer(port, (unsigned long) next_timeout); } |