Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 52087 invoked by uid 500); 1 Oct 2001 19:14:46 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 52076 invoked from network); 1 Oct 2001 19:14:46 -0000 Date: 1 Oct 2001 19:12:49 -0000 Message-ID: <20011001191249.10535.qmail@icarus.apache.org> From: jwoolley@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/file_io/unix mktemp.c open.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jwoolley 01/10/01 12:12:49 Modified: . CHANGES file_io/unix mktemp.c open.c Log: Even though it's not unusual for temporary files to be unlinked as soon as they're open on Unix, it makes the use of those files harder in some cases. For example, the filename we were getting back from apr_file_mktemp() was useless because the file had already been unlinked. Now we defer the unlink until the file is actually closed. This also makes the behavior on Unix somewhat more consistent with other platforms. Revision Changes Path 1.165 +5 -0 apr/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apr/CHANGES,v retrieving revision 1.164 retrieving revision 1.165 diff -u -d -u -r1.164 -r1.165 --- CHANGES 2001/10/01 18:46:40 1.164 +++ CHANGES 2001/10/01 19:12:49 1.165 @@ -1,5 +1,10 @@ Changes with APR b1 + *) Files opened on Unix with the flag APR_DELONCLOSE are now + not unlinked until they are actually closed, rather than as + soon as they're opened. The old approach worked but made + handling temp files harder. [Cliff Woolley] + *) Fix potential segfault when closing a file on Unix. If apr_file_close() was called and it failed, it would not deregister the file cleanup. Therefore the cleanup would 1.11 +0 -1 apr/file_io/unix/mktemp.c Index: mktemp.c =================================================================== RCS file: /home/cvs/apr/file_io/unix/mktemp.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -u -r1.10 -r1.11 --- mktemp.c 2001/09/30 08:13:51 1.10 +++ mktemp.c 2001/10/01 19:12:49 1.11 @@ -196,7 +196,6 @@ (*fp)->filedes = fd; #endif - apr_file_remove((*fp)->fname, p); #ifdef WIN32 apr_pool_cleanup_register((*fp)->cntxt, (void *)(*fp), file_cleanup, file_cleanup); 1.86 +3 -3 apr/file_io/unix/open.c Index: open.c =================================================================== RCS file: /home/cvs/apr/file_io/unix/open.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -u -r1.85 -r1.86 --- open.c 2001/10/01 18:46:40 1.85 +++ open.c 2001/10/01 19:12:49 1.86 @@ -69,6 +69,9 @@ rc = close(file->filedes); if (rc == 0) { file->filedes = -1; + if (file->flags & APR_DELONCLOSE) { + unlink(file->fname); + } #if APR_HAS_THREADS if (file->thlock) { rv = apr_lock_destroy(file->thlock); @@ -156,9 +159,6 @@ return errno; } - if (flag & APR_DELONCLOSE) { - unlink(fname); - } (*new)->pipe = 0; (*new)->timeout = -1; (*new)->ungetchar = -1;