From fba82e5f7519724c28b4ec66c4276393c34a1710 Mon Sep 17 00:00:00 2001 From: Matthew Harlum Date: Mon, 24 Jun 2024 01:31:43 +0000 Subject: [PATCH] open(): Need to mark the ioreq as complete to prevent hanging. If the IORequest is not marked as complete at open() then CheckIO will consider it as "in-use" and WaitIO will hang. This closes #11 --- driver.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/driver.c b/driver.c index 52de81f..2b6b9aa 100644 --- a/driver.c +++ b/driver.c @@ -550,8 +550,15 @@ static void __attribute__((used, saveds)) open(struct DeviceBase *dev asm("a6"), ioreq->io_Unit = (struct Unit *)unit; - // Set io_Message type to NT_MESSAGE to make sure CheckIO() functions correctly - ioreq->io_Message.mn_Node.ln_Type = NT_MESSAGE; + /* IMPORTANT: Mark IORequest as "complete" or otherwise CheckIO() may + * consider it as "in use" in spite of never having been + * used at all. This also avoids that WaitIO() will hang + * on an IORequest which has never been used. + * + * Source: Olaf Barthel's Trackfile.device + * https://github.com/obarthel/trackfile-device + */ + ioreq->io_Message.mn_Node.ln_Type = NT_REPLYMSG; // Send a TD_CHANGESTATE ioreq for the unit if it is ATAPI and not already open // This will update the media presence & geometry