Skip to content

Commit

Permalink
Make port close not be delayed
Browse files Browse the repository at this point in the history
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
bufflig committed Apr 4, 2013
1 parent 8d70fd8 commit 1e282b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions erts/emulator/beam/erl_port_task.c
Expand Up @@ -2001,10 +2001,10 @@ begin_port_cleanup(Port *pp, ErtsPortTask **execqp, int *processing_busy_q_p)
* Schedule cleanup of port structure... * Schedule cleanup of port structure...
*/ */
#ifdef ERTS_SMP #ifdef ERTS_SMP
erts_schedule_thr_prgr_later_cleanup_op(release_port, /* Has to be more or less immediate to release any driver */
(void *) pp, erts_schedule_thr_prgr_later_op(release_port,
&pp->common.u.release, (void *) pp,
sizeof(Port)); &pp->common.u.release);
#else #else
pp->cleanup = 1; pp->cleanup = 1;
#endif #endif
Expand Down

0 comments on commit 1e282b7

Please sign in to comment.