Re: [hatari-devel] Code execution on reset within the emulated Atari

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


> On 19/07/2024 11.54, Uwe Seimet wrote:
> >> On Freitag, 19. Juli 2024 11:18:24 CEST Uwe Seimet wrote:
> >>> As a result you run out of external handles.
> >>
> >> BTW, is that real a problem in practise? Yes, if Hatari does not reset the
> >> nf_scsi driver, those handles will be leaked. But how many handles are open
> >> when that happens? Typically, on linux you can have ~1024 file handles open.
> > 
> > nf_scsidrv reserves 32 handles, which usually is sufficient. Increasing
> > the number of handles would just be a work-around, but not a clean solution.
> > 
> > I will check whether customreset() can do the work. Currently
> > nf_scsidrv_reset is called in reset.c, but this only works if you reset the
> > emulation externally I assumeA
> > .
> > @Thomas In case customreset() works, the call in reset.c can probably be
> > removed?
> 
> Yes, I think so.

Looks as if using customreset() works fine. The attached patch contains the
required changes. Can you please review/merge it? Thank you.
diff --git a/src/cpu/hatari-glue.c b/src/cpu/hatari-glue.c
index 5387e0e3..e4b8e90c 100644
--- a/src/cpu/hatari-glue.c
+++ b/src/cpu/hatari-glue.c
@@ -27,6 +27,7 @@ const char HatariGlue_fileid[] = "Hatari hatari-glue.c";
 #include "psg.h"
 #include "mfp.h"
 #include "fdc.h"
+#include "nf_scsidrv.h"
 #include "memorySnapShot.h"
 
 #include "sysdeps.h"
@@ -68,6 +69,11 @@ void customreset(void)
 
 	/* Reset the FDC */
 	FDC_Reset ( false );
+
+#if defined(__linux__)
+	/* Reset the native SCSI Driver */
+	nf_scsidrv_reset();
+#endif
 }
 
 
diff --git a/src/reset.c b/src/reset.c
index bb477c54..0ae38e29 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -42,7 +42,6 @@ const char Reset_fileid[] = "Hatari reset.c";
 #include "falcon/dsp.h"
 #include "debugcpu.h"
 #include "debugdsp.h"
-#include "nf_scsidrv.h"
 
 /*-----------------------------------------------------------------------*/
 /**
@@ -118,10 +117,6 @@ static int Reset_ST(bool bCold)
 
 	Midi_Reset();
 
-#if defined(__linux__)
-        nf_scsidrv_reset();
-#endif
-
 	/* Start HBL, Timer B and VBL interrupts with a 0 cycle delay */
 	Video_StartInterrupts( 0 );
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/