Re: Writing Files asynchronously



In article <1124730377.140157.50750@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
grice@xxxxxxxxxxxx wrote:

> I have a classic app that uses FSWrite to store text into a file.
> Ocassionally the app hangs when FSWrite is referencing a file on a
> remote volume (Sun Unix disk with an AppleTalk stack installed). The
> app will hang indefinitely (or until the user restarts the machine).
>
> The problem is probably someplace in the Unix driver code and the
> company that produced that code is gone.
>
> I would like to work around the hang condition so I thought I'd convert
> the FSWrite call to a PBWriteAsync call so I could monitor the
> operation and kill off the write operation if it exceeded some
> reasonable threshold. I coded the call up.
>
> I got the PBWriteAsync call to work to a point. If the call completes
> successfully, all is good. But when the call fails to complete, the
> code then proceeds to close the file without change and then the app
> abruptly crashes.
>
> I suspect that the PBWrite request is actually completing after the
> file is closed and writing over something that should remain untouched
> by errant applications.
>
> So I went looking for a way to kill off the pending I/O request.
>
> KillIO seemed like an obvious choice at first but I soon discovered it
> was intended to be used at the device driver level rather then the file
> I/O level.

In Classic, you should be able to use KillIO to kill a PBWriteAsync,
even if it is to a file.

Just don't re-use the same parameter block for the KillIO that you used
for the PBWriteAsync.

Just a guess. I have no direct knowledge.

--
David Phillip Oster
.



Relevant Pages

  • Writing Files asynchronously
    ... I have a classic app that uses FSWrite to store text into a file. ... I would like to work around the hang condition so I thought I'd convert ... I got the PBWriteAsync call to work to a point. ...
    (comp.sys.mac.programmer.codewarrior)
  • Re: Writing Files asynchronously
    ... > I have a classic app that uses FSWrite to store text into a file. ... > app will hang indefinitely. ... > So I went looking for a way to kill off the pending I/O request. ...
    (comp.sys.mac.programmer.codewarrior)
  • Where to get updated wininet.pas/dll?
    ... Have an app in D7 that downloads a file every N minutes. ... Since in some rare cases the download will just hang and resulting in my app ... BlockWrite(f, Buffer, BufferLen); ...
    (alt.comp.lang.borland-delphi)
  • Re: Can a user app hang a *IX system?
    ... > I have a situation where our programcompletely hang the system. ... > OS is MontaVista Embedded Linux on a xscale big-endian cpu. ... > Our app starts and hangs, and also hangs the system, can't ctrl-brk the ... driver hang the motherboard. ...
    (comp.unix.programmer)
  • Re: Where to get updated wininet.pas/dll?
    ... Have an app in D7 that downloads a file every N minutes. ... Since in some rare cases the download will just hang and resulting in my app to hang, i'm trying to implement a timeout in the filedownload. ... the jam up could be in a socket session and not in response ...
    (alt.comp.lang.borland-delphi)