Skip to content
Browse files

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.
  • Loading branch information...
1 parent 8d70fd8 commit 1e282b7b0c092f8f4619383741262583ff99b64c @bufflig bufflig committed
Showing with 4 additions and 4 deletions.
  1. +4 −4 erts/emulator/beam/erl_port_task.c
View
8 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

0 comments on commit 1e282b7

Please sign in to comment.
Something went wrong with that request. Please try again.