How to AbortPkt() since they removed it?

5 posts / 0 new
Last post
hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
How to AbortPkt() since they removed it?

Hello.

So I have a case where I have a sent packet and need to abort it. But I cannot on OS4 since they removed the function to do so. Good effort.

My use case is that I am waiting for a set of signals and also for a key press on the CLI. As my main code waits in a loop and then processes each signal case. So it would multitask I set up a DOS packet that I send off to read a character which is collected when the signal comes in.

I've found in one situation that the program will need to quit, but the packet is still hanging in there. And I can't abort it. Is there any way to abort a DOS packet?

I tried sending my input channel a character to satisfy the packet. But this just resulted in a character being printed. And when it quit the CON handler crashed indicating the packet wasn't sent back.

Is there another way to check for and clear a key press read without polling?

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Re: How to AbortPkt() since they removed it?

It was removed because it was never working in the first place.

If you look at the BUGS section in the 3.9 NDK autodoc you can see that it's written that the function was implemented as a no-op since V37 (AmigaOS 2.04).

hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to AbortPkt() since they removed it?

Yes I read that. In fact I had to search for it since I was sure it existed but could not find it. Then I wonder why it wasn't fixed up and implemented? A lot of other stuff was fixed up. This just leaves us high and dry.

I can try and flush the file handle or set FH_EndStream to true in an attempt send the packet back with EOF error.

Or I could try a ReplyPkt() to myself to see if it removes it. :-P

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Re: How to AbortPkt() since they removed it?

Then I wonder why it wasn't fixed up and implemented?

Because it's not possible to implement it in a reliable way. Aborting a packet that is already in the process of being handled by the file system would require co-operation from the file system and unlike for device drivers there is no AbortIO() vector to make use of (sending another packet will not work since the file system won't get to it before it has dealt with all the ones that it already has).

The best that you could do is to remove the packet if it's still in the message port queue. If it's already removed then all you can do is wait until it has finished.

  1. BOOL AbortPacket(struct MsgPort *fsport, struct DosPacket *pkt)
  2. {
  3. BOOL aborted = FALSE;
  4.  
  5. Forbid();
  6.  
  7. /* Go through file system msg queue */
  8. for (msg = fsport->mp_MsgList.lh_Head; msg->mn_Node.ln_Succ; msg = (struct Message *)msg->mn_Node.ln_Succ)
  9. {
  10. /* Is this our packet? */
  11. if ((struct DosPacket *)msg->ln_Name == pkt)
  12. {
  13. /* Remove it */
  14. Remove(&msg->mn_Node);
  15. aborted = TRUE;
  16. break;
  17. }
  18. }
  19.  
  20. Permit();
  21.  
  22. return aborted;
  23. }
hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
Re: How to AbortPkt() since they removed it?

Because it's not possible to implement it in a reliable way. Aborting a packet that is already in the process of being handled by the file system would require co-operation from the file system and unlike for device drivers there is no AbortIO() vector to make use of (sending another packet will not work since the file system won't get to it before it has dealt with all the ones that it already has).

AbortIO() was exactly what I was thinking of as that has an abort mechanism and is of a lower level than a filesystem handler. A packet already being processed would be a different case. In my case the packet is sitting there and not dealt with so I need to revoke the packet.

I tried all the ones I suggested myself. That was fun to try. I did a ReplyPkt() to myself which worked and came back. Then the console handler crashed when my program made an exit. LOL. :-)

The best that you could do is to remove the packet if it's still in the message port queue. If it's already removed then all you can do is wait until it has finished.

I'll try this later. Thanks. Though this is lower level than I would like.

This is one of those AmigaOS things that needs better attention. In my case I just wanted to multitask my code so I would get a signal on keypress. Rather than poll for it every now and then. but doing simple things like this in AmigaOS is hard. They really should have looked into this years ago. I mean for years now even reading the keyboard without a window attached was considered a low level function which looks rather silly since the OS should know what keys are being pressed at any given time.

The way I was doing this was slightly complicated. Creating a packet and sending it off. Adding the signal to my signal waiting list for later processing in my main loop. Just to get a signal on keypress. I could also have done a WaitForChar() or similar packet and just wait for timeout if I need to abort. This would work just as well I suppose. Just need to keep sending it on no keypress.

It gets annoying that there isn't a simple way of waiting for a keypress in a console window. Intuition window you just wait for a signal and message with barely any setup. Console window which is supposedly of a higher level is more complicated for such a simple task.

Log in or register to post comments