This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR48298 - [F03] User-Defined Derived-Type IO (DTIO)


On 08/22/2016 11:20 AM, Jerry DeLisle wrote:


I am thinking that the parent is holding the mutex lock on the unit. When the
child tries to access, it is blocked.

I will see if I can reproduce it here and then try to find a solution. Thanks
for the report.


The following patchlet steers clear of the locking for child IO since the parent is in control.

We are going to have to see if we can test this in some sort of multi-threaded situation, but I think it should be OK.

Dominiq, please test on your system.

Regards,

Jerry

diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index e0e7b09f..3ab3f81d 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -348,7 +348,7 @@ retry:
     }

 found:
-  if (p != NULL)
+  if (p != NULL && (p->child_dtio == 0))
     {
       /* Fast path.  */
       if (! __gthread_mutex_trylock (&p->lock))
@@ -363,7 +363,7 @@ found:

   __gthread_mutex_unlock (&unit_lock);

-  if (p != NULL)
+  if (p != NULL && (p->child_dtio == 0))
     {
       __gthread_mutex_lock (&p->lock);
       if (p->closed)

Should we move these discussions to the PR48298?

Jerry



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]