apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject Re: [PATCH] Win32: Why explicitly futz with the file pointer?
Date Sun, 20 Oct 2002 19:49:48 GMT
On Sun, 20 Oct 2002, Bill Stoddard wrote:

> Why do we need to call SetFilePointer to each call of apr_file_write()? In
> the common case where only threads in a single process write to a file,
> calling SetFilePointer is a waste of cycles. If threads from multiple
> processes are writing to a file, then we are broken unless the application
> explicitly serializes access to apr_file_write()

We only make that call if it we opened the file in append mode.  The rule
for append is that all data is written to the end of the
file.  Unfortunately, Windows doesn't have this concept, so we have to
hack it in.  While the app may serialize access to the file, that won't do
anything, unless the app also seeks to the end of the file.  However, this
is only a problem on Windows, which is why APR_APPEND is an option.  So,
IMNSHO, Windows is totally borked when it comes to having threads share
write access to a file, and this is the best solution we have for fixing
it.  BTW, removing this will almost definately break the web server on
Windows, if you ever get multiple processes serving data at the same time.

As for having the app serialize and seek to the end of the file, that is
generally a much larger waste of cycles for non-windows platforms.  If you
want to remove the cycles from your app, the best thing you can do, is to
stop opening the file for append mode on Windows.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------


Mime
View raw message