home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / os2 / programm / 7142 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  48 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!psinntp!openwx!mikel
  3. From: mikel@networx.com (Mike Lempriere)
  4. Subject: Re: How do I flush disk buffer?
  5. Message-ID: <1992Dec19.031015.8974@networx.com>
  6. Sender: usenet@networx.com (Usenet News Account)
  7. Organization: NetWorx
  8. X-Newsreader: TIN [version 1.1 PL6]
  9. References: <1992Dec15.015458.15556@njitgw.njit.edu>
  10. Date: Sat, 19 Dec 1992 03:10:15 GMT
  11. Lines: 35
  12.  
  13. David Charlap (dic5340@hertz.njit.edu) wrote:
  14. : In article <92349.025025DLVGC@CUNYVM.BITNET> DLVGC@CUNYVM.BITNET (Dimitri Vulis) writes:
  15. : >I've had a similar problem (keeping the log file in the event the power
  16. : >goes off) and simply calling fflush(fptr) after every fprintf seems to
  17. : >commit the data to disk right away. (Including writing over a LAN Server
  18. : >to a networked disk).  I even wrote a little function wrlog using stdargs
  19. : >that first passes its args to fprintf(logfptr, then fflush(logfpr)'s.
  20. : >
  21. : >Of course, fflush _may_ work differently under gcc (I tried this with
  22. : >both icc and ms c 6.0)
  23. : If you use OS/2 calls (like DosOpen, DosWrite, DosClose) instead of C
  24. : library calls (like fopen, fwrite, fclose), you'll notice an option on
  25. : DosOpen which tells the system not to cache the file handle.  This may
  26. : do what you want it to.
  27. [.sig deleted]
  28. ------------------------------------------------------------------------------
  29. You must've missed my original posting.
  30.  
  31. I originally wrote the program using fopen(), fwrite(), fflush().
  32. This did not work.
  33.  
  34. I changed it to DosOpen(OPEN_FLAGS_NO_CACHE), DosWrite().  This did not
  35. work either.
  36.  
  37. I tried DosOpen(OPEN_FLAGS_WRITE_THROUGH).  This worked, but is pretty
  38. harsh, I don't want to pound every write directly out to disk, and I
  39. can't allow my program to pend until the write happens.
  40.  
  41. I got it doing what I wanted by checking the time since the last write
  42. every time I go t do a write, and doing a
  43. DosSetFHandState(OPEN_FLAGS_WRITE_THROUGH) if it's been longer than 10
  44. minutes, then setting it back with a DosSetFHandState(0).  This is
  45. exactly the effact that I want, It's just a bit of a nuisance.  I'd
  46. rather if NO_CACHE did what it sounds like it's supposed to do.
  47.