Re: fflush and fsync
Date: Tue, 22 Apr 2008 18:29:53 +0200
2008/4/22, Jamie Lokier wrote:
> Reading a file before it's finished being written looks like a bug.
> Isn't this the obvious thing to fix?
Yep, this is the real origin of all this.
As a side note, at this moment, the fflush() + fsync() stuff has gone
out the window, and the small delay for test1001 is back again. Yes
the small delay actually is a workaround :-)
Yes, the real problem is just a matter of synchronizing the 'file
consumer', the runtests.pl, script with the 'file producer' the sws
server. Taking in account that the test harness sometimes runs in very
unfavorable conditions in which lib/curl or even part of the test
harness itself might be broken.
Somehow the producer should 'indicate' that it has completed file
generation. And the consumer should wait a maximum timeout to get the
file generation completed indication.
The timeout is obviously needed due to the fact that the producer
might never complete file generation. In this case the consumer should
consume whatever file amount is available.
For portability sake maybe a token file mechanism could be used. The
file would be created by the sws server once that a client connects,
and deleted once that the client disconnects or is disconnected. The
runtests.pl script, once that the client part has run, should wait a
timeout for the token file to dissapear and read the produced file.
Does it make sense to try out this approach ? Or can someone foresee
new problems this would introduce ?
-- -=[Yang]=-Received on 2008-04-22