diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2021-05-02 18:16:17 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2021-05-02 18:16:17 +0200 |
commit | a13a50047ef1814a7bda2392f728bf28f81b17ce (patch) | |
tree | b4c130466f28a5837bbd162afb72779ad513ba37 /libgfortran/io/transfer.c | |
parent | 7911a905276781c20f704f5a91b5125e0184d072 (diff) | |
download | gcc-a13a50047ef1814a7bda2392f728bf28f81b17ce.zip gcc-a13a50047ef1814a7bda2392f728bf28f81b17ce.tar.gz gcc-a13a50047ef1814a7bda2392f728bf28f81b17ce.tar.bz2 |
Fortran: Async I/O - avoid unlocked unlocking [PR100352]
Follow up to PR100352, which moved unit unlocking to st_*_done_worker to
avoid lock order reversal; however, as async_io uses a different lock,
the (unlocked locked) unit lock shall not be unlocked there.
libgfortran/ChangeLog:
PR libgomp/100352
* io/transfer.c (st_read_done_worker, st_write_done_worker): Add new
arg whether to unlock unit.
(st_read_done, st_write_done): Call it with true.
* io/async.c (async_io): Call it with false.
* io/io.h (st_write_done_worker, st_read_done_worker): Update prototype.
Diffstat (limited to 'libgfortran/io/transfer.c')
-rw-r--r-- | libgfortran/io/transfer.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 71a9356..36e35b4 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -4337,7 +4337,7 @@ extern void st_read_done (st_parameter_dt *); export_proto(st_read_done); void -st_read_done_worker (st_parameter_dt *dtp) +st_read_done_worker (st_parameter_dt *dtp, bool unlock) { bool free_newunit = false; finalize_transfer (dtp); @@ -4367,7 +4367,8 @@ st_read_done_worker (st_parameter_dt *dtp) free_format (dtp); } } - unlock_unit (dtp->u.p.current_unit); + if (unlock) + unlock_unit (dtp->u.p.current_unit); if (free_newunit) { /* Avoid inverse lock issues by placing after unlock_unit. */ @@ -4394,7 +4395,7 @@ st_read_done (st_parameter_dt *dtp) unlock_unit (dtp->u.p.current_unit); } else - st_read_done_worker (dtp); /* Calls unlock_unit. */ + st_read_done_worker (dtp, true); /* Calls unlock_unit. */ } library_end (); @@ -4412,7 +4413,7 @@ st_write (st_parameter_dt *dtp) void -st_write_done_worker (st_parameter_dt *dtp) +st_write_done_worker (st_parameter_dt *dtp, bool unlock) { bool free_newunit = false; finalize_transfer (dtp); @@ -4463,7 +4464,8 @@ st_write_done_worker (st_parameter_dt *dtp) free_format (dtp); } } - unlock_unit (dtp->u.p.current_unit); + if (unlock) + unlock_unit (dtp->u.p.current_unit); if (free_newunit) { /* Avoid inverse lock issues by placing after unlock_unit. */ @@ -4496,7 +4498,7 @@ st_write_done (st_parameter_dt *dtp) unlock_unit (dtp->u.p.current_unit); } else - st_write_done_worker (dtp); /* Calls unlock_unit. */ + st_write_done_worker (dtp, true); /* Calls unlock_unit. */ } library_end (); |