From 1e282b7b0c092f8f4619383741262583ff99b64c Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Thu, 4 Apr 2013 17:46:17 +0200 Subject: Make port close not be delayed Drivers are dereferenced when the port is completely gone, in the operation scheduled with erts_schedule_thr_prgr_later_op. If we use erts_schedule_thr_prgr_later_cleanup_op, it may not happen for a long time and the driver can not be unloaded. We can not dereference the driver before the thread_progress_later thing, because references to the driver may exist in other threads, so the unloading of the driver may free locks held by other schedulers and whatnot. --- erts/emulator/beam/erl_port_task.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'erts') diff --git a/erts/emulator/beam/erl_port_task.c b/erts/emulator/beam/erl_port_task.c index 23000391ec..0ed08bee01 100644 --- a/erts/emulator/beam/erl_port_task.c +++ b/erts/emulator/beam/erl_port_task.c @@ -2001,10 +2001,10 @@ begin_port_cleanup(Port *pp, ErtsPortTask **execqp, int *processing_busy_q_p) * Schedule cleanup of port structure... */ #ifdef ERTS_SMP - erts_schedule_thr_prgr_later_cleanup_op(release_port, - (void *) pp, - &pp->common.u.release, - sizeof(Port)); + /* Has to be more or less immediate to release any driver */ + erts_schedule_thr_prgr_later_op(release_port, + (void *) pp, + &pp->common.u.release); #else pp->cleanup = 1; #endif -- cgit v1.2.3