[uae] [PATCH] Fix for race condition when closing a hardfile

  • From: Richard Drummond <evilrich@xxxxxxxxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Tue, 24 Jul 2007 00:04:41 -0400

Hi All

A race condition exists in the hardfile code after closing a hardfile device. 
You can see this problem particularly when trying to install an RDB hardfile 
with hdtoolbox (hdtoolbox can hang when scanning for disks).

The attached patch fixes this.

Cheers,
Rich
-- 
Richard Drummond

Web:  http://www.rcdrummond.net/
Mail: mailto:evilrich@xxxxxxxxxxxxxx
Index: src/hardfile.c
===================================================================
RCS file: /cvsroot/uaedev/uae/src/hardfile.c,v
retrieving revision 1.11
diff -u -r1.11 hardfile.c
--- src/hardfile.c      12 Mar 2007 13:00:15 -0000      1.11
+++ src/hardfile.c      24 Jul 2007 03:59:05 -0000
@@ -432,8 +432,12 @@
     if (!hfpd->opencount)
        return 0;
     hfpd->opencount--;
-    if (hfpd->opencount == 0)
+
+    if (hfpd->opencount == 0) {
        write_comm_pipe_u32 (&hfpd->requests, 0, 1);
+       uae_sem_wait (&hfpd->sync_sem);
+    }
+
     put_word (m68k_areg (&context->regs, 6) + 32, get_word (m68k_areg 
(&context->regs, 6) + 32) - 1);
     return 0;
 }

Other related posts:

  • » [uae] [PATCH] Fix for race condition when closing a hardfile