From cvs-return-22141-apmail-httpd-cvs-archive=httpd.apache.org@httpd.apache.org Sat Jun 11 00:26:25 2005 Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 69962 invoked from network); 11 Jun 2005 00:26:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jun 2005 00:26:24 -0000 Received: (qmail 14666 invoked by uid 500); 11 Jun 2005 00:26:24 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 14614 invoked by uid 500); 11 Jun 2005 00:26:23 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 14597 invoked by uid 99); 11 Jun 2005 00:26:22 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 10 Jun 2005 17:26:22 -0700 Received: (qmail 69936 invoked by uid 65534); 11 Jun 2005 00:26:21 -0000 Message-ID: <20050611002621.69935.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r190043 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_disk_cache.c Date: Sat, 11 Jun 2005 00:26:20 -0000 To: cvs@httpd.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: pquerna Date: Fri Jun 10 17:26:19 2005 New Revision: 190043 URL: http://svn.apache.org/viewcvs?rev=3D190043&view=3Drev Log: - Use apr_file_mktemp() and rename the header data file to its final locati= on, instead of opening it and then writing it out as we go. Should prevent= race conditions on busy servers. Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/modules/cache/mod_disk_cache.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?rev=3D190043&r= 1=3D190042&r2=3D190043&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/httpd/trunk/CHANGES (original) +++ httpd/httpd/trunk/CHANGES Fri Jun 10 17:26:19 2005 @@ -2,6 +2,8 @@ =20 [Remove entries to the current 2.0 section below, when backported] =20 + *) mod_disk_cache: Atomically create the header data file. [Paul Querna] + *) mod_cache: Fix 'Vary: *' behavior to be RFC compliant. PR 16125.=20 [Paul Querna] =20 Modified: httpd/httpd/trunk/modules/cache/mod_disk_cache.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/mod_disk= _cache.c?rev=3D190043&r1=3D190042&r2=3D190043&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/httpd/trunk/modules/cache/mod_disk_cache.c (original) +++ httpd/httpd/trunk/modules/cache/mod_disk_cache.c Fri Jun 10 17:26:19 20= 05 @@ -535,21 +535,14 @@ /* This is flaky... we need to manage the cache_info differently */ h->cache_obj->info =3D *info; =20 - /* Remove old file with the same name. If remove fails, then - * perhaps we need to create the directory tree where we are - * about to write the new headers file. - */ - rv =3D apr_file_remove(dobj->hdrsfile, r->pool); - if (rv !=3D APR_SUCCESS) { - mkdir_structure(conf, dobj->hdrsfile, r->pool); - } + rv =3D apr_file_mktemp(&dobj->hfd, dobj->tempfile, + APR_CREATE | APR_WRITE | APR_BINARY | + APR_BUFFERED | APR_EXCL, r->pool); =20 - rv =3D apr_file_open(&dobj->hfd, dobj->hdrsfile, - APR_WRITE | APR_CREATE | APR_EXCL, - APR_OS_DEFAULT, r->pool); if (rv !=3D APR_SUCCESS) { return rv; } + dobj->name =3D h->cache_obj->key; =20 disk_info.format =3D DISK_FORMAT_VERSION; @@ -606,6 +599,26 @@ } =20 apr_file_close(dobj->hfd); /* flush and close */ + + /* Remove old file with the same name. If remove fails, then + * perhaps we need to create the directory tree where we are + * about to write the new headers file. + */ + rv =3D apr_file_remove(dobj->hdrsfile, r->pool); + if (rv !=3D APR_SUCCESS) { + mkdir_structure(conf, dobj->hdrsfile, r->pool); + } + =20 + rv =3D apr_file_rename(dobj->tempfile, dobj->hdrsfile, r->pool); + + if (rv !=3D APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, + "disk_cache: rename tempfile to hdrsfile failed: %s -= > %s", + dobj->tempfile, dobj->hdrsfile); + return rv; + } + + dobj->tempfile =3D apr_pstrcat(r->pool, conf->cache_root, AP_TEMPFILE,= NULL); =20 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: Stored headers for URL %s", dobj->name);