aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common/inet_drv.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2019-01-23 10:29:19 +0100
committerLukas Larsson <[email protected]>2019-01-23 10:29:19 +0100
commit1d2d2aef118db24e478a57a73e1dcd15e699a29a (patch)
treefb2b1dc4ca3a18897410701419b5afd062a7d876 /erts/emulator/drivers/common/inet_drv.c
parent3601418c73a4b17c16489bf734591c1f6e63dc7e (diff)
parentaba6a2c2b5ae9dca21c5e14f5c25b175c6b67782 (diff)
downloadotp-1d2d2aef118db24e478a57a73e1dcd15e699a29a.tar.gz
otp-1d2d2aef118db24e478a57a73e1dcd15e699a29a.tar.bz2
otp-1d2d2aef118db24e478a57a73e1dcd15e699a29a.zip
Merge branch 'maint'
Diffstat (limited to 'erts/emulator/drivers/common/inet_drv.c')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c40
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 207bef4044..1c7aa56199 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -12960,38 +12960,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);
}