Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 44433 invoked by uid 500); 20 Oct 2002 19:49:46 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 44401 invoked from network); 20 Oct 2002 19:49:45 -0000 Date: Sun, 20 Oct 2002 15:49:48 -0400 (EDT) From: rbb@apache.org X-Sender: rbb@shell.ntrnet.net To: Bill Stoddard Cc: APR Development List Subject: Re: [PATCH] Win32: Why explicitly futz with the file pointer? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 -------------------------------------------------------------------------------