Skip to content

Commit

Permalink
open(): Need to mark the ioreq as complete to prevent hanging.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LIV2 committed Jun 24, 2024
1 parent d1fe9e9 commit fba82e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fba82e5

Please sign in to comment.