How to AbortPkt() since they removed it?

4 posts / 0 new
Last post
hypex
hypex's picture
Offline
Last seen: 5 days 1 hour 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: 22 hours 14 min 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: 5 days 1 hour 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: 22 hours 14 min 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. }
Log in or register to post comments