Martin_Head wrote:This a routine for my IP Network driver. What I am trying to do is to change the network station number/IP Address that the driver is using.
What I want to do is scan the channel table, looking for any open channels that belong to the IP Network driver. If it finds any, then the routine returns an 'in use' error. To tell the user to close them.
That should work with supervisor mode alone.
Martin_Head wrote:
If it does not find any open channels, it then checks to see if the file server (FSERVE) is running. If it is, it then it removes it.
That will not work from supervisor mode, as mentioned above. Killing a job involves the scheduler and entering the scheduler in SV mode is a no-no.
Martin_Head wrote:
It then opens 2 new TCP_ channels, patches part of the IP Network drives Linkage block, and closes 2 old TCP_ channels, that are replaced with the new ones.
That should work from SV mode.
Martin_Head wrote:
While the routine is doing it's thing, I don't want to run the risk that a IP Network channel gets opened by another job, or FSERVE, halfway through changing things.
SV mode only (interrupts enabled) should do the job as long as no ISR is fiddling with the same tables you want to work with. For the QDOS in-built drivers, this is guaranteed.
Martin_Head wrote:
If I remember correctly without looking at the code, I use MT.INF, MT.FRJOB, IO.OPEN, and IO.CLOSE system calls while in supervisor mode.
As said before, MT.INF, IO.OPEN, IO.CLOSE should be fine to call from SV mode, MT.FRJOB isn't.
Martin_Head wrote:
If I cannot remove the FSERVE job while in supervisor mode, could I do the MT.FRJOB, or MT.RJOB right after coming out of supervisor mode. Although this sound slightly dangerous as a channel it uses no longer exists, and I'm not sure what happens if it tries to use it before it shuts down. If push come to shove, I might be able to patch the running FSERVE job with the new channel ID (I think it is just kept in a register) and not need to shut it down. Or alternatively when I check to see if FSERVE is running I could return an 'in use' error, and make the user shut down the file server, like they would have to close any open network channels before restarting the Network driver.
What's wrong with stopping the FSERVE job before you do anything else (maybe after having checked that the new station number is really different from the old one) and re-starting id after you're done? None of the channels the job might have open would be valid after the command has run anyhow. Remind the user in the manual that changing the station number is destructive to any in-transit data. (I think TK2 does the same without a warning in the manual)
Another approach is, as you said, have the user stop the FSERVE job before changing the station number and return with an error in case you find it still running - Hotkey System II does the same by not allowing you to change hotkeys without a HOT_STOP first. If you forget that, you'll get an "IN USE" error. Not the worst solution, because after all, the user might lose data (local or remotely).
Tobias