You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2001/09/24 07:41:57 UTC

cvs commit: apr/locks/unix crossproc.c locks.c proc_mutex.c

rbb         01/09/23 22:41:57

  Modified:    .        CHANGES
               file_io/unix mktemp.c
               include  apr_file_io.h
               include/arch/unix fileio.h locks.h proc_mutex.h
               locks/unix crossproc.c locks.c proc_mutex.c
  Log:
  Add the apr_file_mktemp function.  This creates and opens a
  temporary file, for use by the program.  This file is created
  delete_on_close.  The initial implementation only works on
  Unix, but Windows is coming soon.
  
  This also modifies all of the process lock functions that need
  a temporary file to use the new apr_file_mktemp function.
  
  Submitted by:	Ryan Bloom
  
  Revision  Changes    Path
  1.160     +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.159
  retrieving revision 1.160
  diff -u -r1.159 -r1.160
  --- CHANGES	2001/09/21 16:14:50	1.159
  +++ CHANGES	2001/09/24 05:41:56	1.160
  @@ -1,5 +1,10 @@
   Changes with APR b1  
   
  +  *) Add the apr_file_mktemp function.  This creates and opens a 
  +     temporary file, for use by the program.  This file is created
  +     delete_on_close.  The initial implementation only works on
  +     Unix, but Windows is coming soon.  [Ryan Bloom]
  +
     *) Make the unix version of apr_proc_wait_all_procs a simple wrapper 
        around apr_proc_wait, and which extracts the exit code from the 
        status returned by waitpid.  
  
  
  
  1.7       +33 -69    apr/file_io/unix/mktemp.c
  
  Index: mktemp.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/mktemp.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mktemp.c	2001/08/22 15:40:29	1.6
  +++ mktemp.c	2001/09/24 05:41:56	1.7
  @@ -31,6 +31,9 @@
    * SUCH DAMAGE.
    */
   
  +#include "apr_private.h"
  +#include "apr_file_io.h" /* prototype of apr_mkstemp() */
  +#include "apr_strings.h" /* prototype of apr_mkstemp() */
   #include "fileio.h" /* prototype of apr_mkstemp() */
   
   #ifndef HAVE_MKSTEMP
  @@ -49,13 +52,6 @@
   #endif
   #define _open(a,b,c) open(a,b,c)
   
  -#if defined(LIBC_SCCS) && !defined(lint)
  -#if 0
  -static char sccsid[] = "@(#)mktemp.c	8.1 (Berkeley) 6/4/93";
  -#endif
  -static const char rcsid[] =
  -  "$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.19.2.1 2001/01/20 09:35:24 kris Exp $";
  -#endif /* LIBC_SCCS and not lint */
   
   #include <sys/types.h>
   #include <sys/stat.h>
  @@ -66,71 +62,12 @@
   #include <string.h>
   #include <ctype.h>
   
  -#ifdef  SVR4
  -/* arrange to compile it on my machine */
  -char *_mktemp(char *);
  -#else
  -char *_mktemp __P((char *));
  -static int _gettemp (char *, int *, int, int);
  -#endif
  -
  -
   static const unsigned char padchar[] =
   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   static uint32_t randseed=0;
   
  -#ifdef APR_STARTS_USING_IT
  -int
  -mkstemps(path, slen)
  -	char *path;
  -	int slen;
  +static int gettemp(char *path, register int *doopen, int domkdir, int slen)
   {
  -	int fd;
  -
  -	return (_gettemp(path, &fd, 0, slen) ? fd : -1);
  -}
  -#endif /* APR_STARTS_USING_IT */
  -
  -int apr_mkstemp(char *path)
  -{
  -	int fd;
  -
  -	return (_gettemp(path, &fd, 0, 0) ? fd : -1);
  -}
  -
  -#ifdef APR_STARTS_USING_IT
  -char *
  -mkdtemp(path)
  -	char *path;
  -{
  -	return(_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
  -}
  -
  -char *
  -_mktemp(path)
  -	char *path;
  -{
  -	return(_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
  -}
  -
  -__warn_references(mktemp,
  -    "warning: mktemp() possibly used unsafely; consider using mkstemp()");
  -
  -char *
  -mktemp(path)
  -	char *path;
  -{
  -	return(_mktemp(path));
  -}
  -#endif /* APR_STARTS_USING_IT */
  -
  -static int
  -_gettemp(path, doopen, domkdir, slen)
  -	char *path;
  -	register int *doopen;
  -	int domkdir;
  -	int slen;
  -{
   	register char *start, *trv, *suffp;
   	char *pad;
   	struct stat sbuf;
  @@ -226,9 +163,36 @@
   #include <unistd.h> /* for mkstemp() - FreeBSD */
   #endif
   
  -int apr_mkstemp(char *template)
  +apr_status_t apr_file_mktemp(apr_file_t **fp, char *template, apr_pool_t *p)
   {
  -    return mkstemp(template);
  +    int fd;
  +#ifndef HAVE_MKSTEMP
  +    int rv;
  +#endif
  +
  +    (*fp) = apr_pcalloc(p, sizeof(**fp));
  +    (*fp)->cntxt = p;
  +    (*fp)->timeout = -1;
  +    (*fp)->blocking = BLK_ON;
  +    (*fp)->flags = APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE;
  +
  +#ifndef HAVE_MKSTEMP
  +    rv = gettemp(path, &fd, 0, 0);
  +    if (rv == 0) {
  +        return errno;
  +    }
  +#else
  +    fd = mkstemp(template);
  +    if (fd == -1) {
  +        return errno;
  +    }
  +#endif
  +    (*fp)->fname = apr_pstrdup(p, template);
  +    (*fp)->filedes = fd;
  +    unlink((*fp)->fname);
  +    apr_pool_cleanup_register((*fp)->cntxt, (void *)(*fp),
  +                              apr_unix_file_cleanup, apr_unix_file_cleanup);
  +    return APR_SUCCESS;
   }
   
   #endif /* !defined(HAVE_MKSTEMP) */
  
  
  
  1.110     +10 -0     apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_io.h,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- apr_file_io.h	2001/08/12 16:10:43	1.109
  +++ apr_file_io.h	2001/09/24 05:41:56	1.110
  @@ -575,6 +575,16 @@
    */
   APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file);
   
  +/**
  + * Open a temporary file
  + * @param fp The apr file to use as a temporary file.
  + * @param template The template to use when creating a temp file.
  + * @param p The pool to allocate the file out of.
  + * @ingroup apr_file_open
  + */
  +APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *tmplt,
  +                                          apr_pool_t *p);
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.36      +0 -2      apr/include/arch/unix/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/fileio.h,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- fileio.h	2001/06/27 19:40:50	1.35
  +++ fileio.h	2001/09/24 05:41:56	1.36
  @@ -153,7 +153,5 @@
   mode_t apr_unix_perms2mode(apr_fileperms_t perms);
   apr_fileperms_t apr_unix_mode2perms(mode_t mode);
   
  -int apr_mkstemp(char *template);
  -
   #endif  /* ! FILE_IO_H */
   
  
  
  
  1.39      +1 -1      apr/include/arch/unix/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/locks.h,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- locks.h	2001/09/19 20:06:43	1.38
  +++ locks.h	2001/09/24 05:41:56	1.39
  @@ -139,7 +139,7 @@
       int curr_locked;
       char *fname;
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    int interproc;
  +    apr_file_t *interproc;
   #endif
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
       pthread_mutex_t *pthread_interproc;
  
  
  
  1.2       +3 -1      apr/include/arch/unix/proc_mutex.h
  
  Index: proc_mutex.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/proc_mutex.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- proc_mutex.h	2001/09/19 20:06:43	1.1
  +++ proc_mutex.h	2001/09/24 05:41:56	1.2
  @@ -62,6 +62,8 @@
   #include "apr_proc_mutex.h"
   #include "apr_pools.h"
   #include "apr_portable.h"
  +#include "apr_file_io.h"
  +#include "fileio.h"
   
   /* System headers required by Locks library */
   #if APR_HAVE_SYS_TYPES_H
  @@ -145,7 +147,7 @@
       int curr_locked;
       char *fname;
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    int interproc;
  +    apr_file_t *interproc;
   #endif
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
       pthread_mutex_t *pthread_interproc;
  
  
  
  1.54      +30 -21    apr/locks/unix/crossproc.c
  
  Index: crossproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/crossproc.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- crossproc.c	2001/08/31 13:07:15	1.53
  +++ crossproc.c	2001/09/24 05:41:57	1.54
  @@ -53,6 +53,7 @@
    */
   
   #include "apr.h"
  +#include "apr_file_io.h"
   #include "apr_strings.h"
   #include "locks.h"
   #include "fileio.h" /* for apr_mkstemp() */
  @@ -77,9 +78,9 @@
       apr_lock_t *lock=lock_;
       union semun ick;
       
  -    if (lock->interproc != -1) {
  +    if (lock->interproc->filedes != -1) {
           ick.val = 0;
  -        semctl(lock->interproc, 0, IPC_RMID, ick);
  +        semctl(lock->interproc->filedes, 0, IPC_RMID, ick);
       }
       return APR_SUCCESS;
   }    
  @@ -89,15 +90,16 @@
       union semun ick;
       apr_status_t stat;
       
  -    new->interproc = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
  +    new->interproc = apr_palloc(new->pool, sizeof(*new->interproc));
  +    new->interproc->filedes = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
   
  -    if (new->interproc < 0) {
  +    if (new->interproc->filedes < 0) {
           stat = errno;
           sysv_cleanup(new);
           return stat;
       }
       ick.val = 1;
  -    if (semctl(new->interproc, 0, SETVAL, ick) < 0) {
  +    if (semctl(new->interproc->filedes, 0, SETVAL, ick) < 0) {
           stat = errno;
           sysv_cleanup(new);
           return stat;
  @@ -113,7 +115,7 @@
       int rc;
   
       do {
  -        rc = semop(lock->interproc, &op_on, 1);
  +        rc = semop(lock->interproc->filedes, &op_on, 1);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -127,7 +129,7 @@
       int rc;
   
       do {
  -        rc = semop(lock->interproc, &op_off, 1);
  +        rc = semop(lock->interproc->filedes, &op_off, 1);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -369,23 +371,25 @@
           if (status != APR_SUCCESS)
               return status;
       }
  -    close(lock->interproc);
       
       return APR_SUCCESS;
   }    
   
   static apr_status_t fcntl_create(apr_lock_t *new, const char *fname)
   {
  +    int rv;
  +
       if (fname) {
           new->fname = apr_pstrdup(new->pool, fname);
  -        new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
  +        rv = apr_file_open(&new->interproc, new->fname, 
  +                           APR_CREATE | APR_WRITE | APR_EXCL, 0644, new->pool);
       }
       else {
           new->fname = apr_pstrdup(new->pool, "/tmp/aprXXXXXX");
  -        new->interproc = apr_mkstemp(new->fname);
  +        rv = apr_file_mktemp(&new->interproc, new->fname, new->pool);
       }
   
  -    if (new->interproc < 0) {
  +    if (rv != APR_SUCCESS) {
           apr_status_t stat = errno;
   
           fcntl_cleanup(new);
  @@ -404,7 +408,7 @@
       int rc;
   
       do {
  -        rc = fcntl(lock->interproc, F_SETLKW, &lock_it);
  +        rc = fcntl(lock->interproc->filedes, F_SETLKW, &lock_it);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -418,7 +422,7 @@
       int rc;
   
       do {
  -        rc = fcntl(lock->interproc, F_SETLKW, &unlock_it);
  +        rc = fcntl(lock->interproc->filedes, F_SETLKW, &unlock_it);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -480,23 +484,26 @@
           if (status != APR_SUCCESS)
               return status;
       }
  -    close(lock->interproc);
  +    apr_file_close(lock->interproc);
       unlink(lock->fname);
       return APR_SUCCESS;
   }    
   
   static apr_status_t flock_create(apr_lock_t *new, const char *fname)
   {
  +    int rv;
  +
       if (fname) {
           new->fname = apr_pstrdup(new->pool, fname);
  -        new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0600);
  +        rv = apr_file_open(&new->interproc, new->fname, 
  +                           APR_CREATE | APR_WRITE | APR_EXCL, 0644, new->pool);
       }
       else {
           new->fname = apr_pstrdup(new->pool, "/tmp/aprXXXXXX");
  -        new->interproc = apr_mkstemp(new->fname);
  +        rv = apr_file_mktemp(&new->interproc, new->fname, new->pool);
       }
   
  -    if (new->interproc < 0) {
  +    if (rv != APR_SUCCESS) {
           apr_status_t stat = errno;
   
           flock_cleanup(new);
  @@ -513,7 +520,7 @@
       int rc;
   
       do {
  -        rc = flock(lock->interproc, LOCK_EX);
  +        rc = flock(lock->interproc->filedes, LOCK_EX);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -527,7 +534,7 @@
       int rc;
   
       do {
  -        rc = flock(lock->interproc, LOCK_UN);
  +        rc = flock(lock->interproc->filedes, LOCK_UN);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -550,14 +557,16 @@
                                        const char *fname)
   {
       apr_lock_t *new;
  +    int rv;
   
       new = (apr_lock_t *)apr_palloc(cont, sizeof(apr_lock_t));
   
       memcpy(new, *lock, sizeof *new);
       new->pool = cont;
       new->fname = apr_pstrdup(cont, fname);
  -    new->interproc = open(new->fname, O_WRONLY, 0600);
  -    if (new->interproc == -1) {
  +    rv = apr_file_open(&new->interproc, new->fname, 
  +                       APR_CREATE | APR_WRITE, 0600, new->pool);
  +    if (rv != APR_SUCCESS) {
           apr_status_t stat = errno;
   
           flock_destroy(new);
  
  
  
  1.63      +3 -3      apr/locks/unix/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/locks.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- locks.c	2001/08/10 21:04:47	1.62
  +++ locks.c	2001/09/24 05:41:57	1.63
  @@ -243,7 +243,7 @@
       new->type  = type;
       new->scope = scope;
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    new->interproc = -1;
  +    new->interproc = NULL;
   #endif
   
       if ((stat = create_lock(new, mech, fname)) != APR_SUCCESS)
  @@ -370,7 +370,7 @@
   APR_DECLARE(apr_status_t) apr_os_lock_get(apr_os_lock_t *oslock, apr_lock_t *lock)
   {
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    oslock->crossproc = lock->interproc;
  +    oslock->crossproc = lock->interproc->filedes;
   #endif
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
       oslock->pthread_interproc = lock->pthread_interproc;
  @@ -395,7 +395,7 @@
           (*lock)->pool = pool;
       }
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    (*lock)->interproc = thelock->crossproc;
  +    apr_os_file_put(&(*lock)->interproc, &thelock->crossproc, pool);
   #endif
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
       (*lock)->pthread_interproc = thelock->pthread_interproc;
  
  
  
  1.3       +38 -27    apr/locks/unix/proc_mutex.c
  
  Index: proc_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proc_mutex.c	2001/09/19 22:10:44	1.2
  +++ proc_mutex.c	2001/09/24 05:41:57	1.3
  @@ -77,9 +77,9 @@
       apr_proc_mutex_t *mutex=mutex_;
       union semun ick;
       
  -    if (mutex->interproc != -1) {
  +    if (mutex->interproc->filedes != -1) {
           ick.val = 0;
  -        semctl(mutex->interproc, 0, IPC_RMID, ick);
  +        semctl(mutex->interproc->filedes, 0, IPC_RMID, ick);
       }
       return APR_SUCCESS;
   }    
  @@ -90,15 +90,16 @@
       union semun ick;
       apr_status_t stat;
       
  -    new_mutex->interproc = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
  +    new_mutex->interproc = apr_palloc(new_mutex->pool, sizeof(*new_mutex->interproc));
  +    new_mutex->interproc->filedes = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
   
  -    if (new_mutex->interproc < 0) {
  +    if (new_mutex->interproc->filedes < 0) {
           stat = errno;
           proc_mutex_sysv_cleanup(new_mutex);
           return stat;
       }
       ick.val = 1;
  -    if (semctl(new_mutex->interproc, 0, SETVAL, ick) < 0) {
  +    if (semctl(new_mutex->interproc->filedes, 0, SETVAL, ick) < 0) {
           stat = errno;
           proc_mutex_sysv_cleanup(new_mutex);
           return stat;
  @@ -115,7 +116,7 @@
       int rc;
   
       do {
  -        rc = semop(mutex->interproc, &proc_mutex_op_on, 1);
  +        rc = semop(mutex->interproc->filedes, &proc_mutex_op_on, 1);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -129,7 +130,7 @@
       int rc;
   
       do {
  -        rc = semop(mutex->interproc, &proc_mutex_op_off, 1);
  +        rc = semop(mutex->interproc->filedes, &proc_mutex_op_off, 1);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -376,7 +377,7 @@
           if (status != APR_SUCCESS)
               return status;
       }
  -    close(mutex->interproc);
  +    apr_file_close(mutex->interproc);
       
       return APR_SUCCESS;
   }    
  @@ -384,23 +385,27 @@
   static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex,
                                               const char *fname)
   {
  +    int rv;
  + 
       if (fname) {
           new_mutex->fname = apr_pstrdup(new_mutex->pool, fname);
  -        new_mutex->interproc = open(new_mutex->fname,
  -                                    O_CREAT | O_WRONLY | O_EXCL, 0644);
  +        rv = apr_file_open(&new_mutex->interproc, new_mutex->fname,
  +                           APR_CREATE | APR_WRITE | APR_EXCL, 0644, 
  +                           new_mutex->pool);
       }
       else {
           new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX");
  -        new_mutex->interproc = apr_mkstemp(new_mutex->fname);
  +        rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, 
  +                             new_mutex->pool);
       }
  -
  -    if (new_mutex->interproc < 0) {
  + 
  +    if (rv != APR_SUCCESS) {
           proc_mutex_fcntl_cleanup(new_mutex);
           return errno;
       }
   
       new_mutex->curr_locked = 0;
  -    unlink(new_mutex->fname);
  +/*    unlink(new_mutex->fname); */
       apr_pool_cleanup_register(new_mutex->pool,
                                 (void*)new_mutex,
                                 proc_mutex_fcntl_cleanup, 
  @@ -413,7 +418,7 @@
       int rc;
   
       do {
  -        rc = fcntl(mutex->interproc, F_SETLKW, &proc_mutex_lock_it);
  +        rc = fcntl(mutex->interproc->filedes, F_SETLKW, &proc_mutex_lock_it);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -427,7 +432,7 @@
       int rc;
   
       do {
  -        rc = fcntl(mutex->interproc, F_SETLKW, &proc_mutex_unlock_it);
  +        rc = fcntl(mutex->interproc->filedes, F_SETLKW, &proc_mutex_unlock_it);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -488,7 +493,7 @@
           if (status != APR_SUCCESS)
               return status;
       }
  -    close(mutex->interproc);
  +    apr_file_close(mutex->interproc);
       unlink(mutex->fname);
       return APR_SUCCESS;
   }    
  @@ -496,17 +501,21 @@
   static apr_status_t proc_mutex_flock_create(apr_proc_mutex_t *new_mutex,
                                               const char *fname)
   {
  +    int rv;
  + 
       if (fname) {
           new_mutex->fname = apr_pstrdup(new_mutex->pool, fname);
  -        new_mutex->interproc = open(new_mutex->fname,
  -                                    O_CREAT | O_WRONLY | O_EXCL, 0600);
  +        rv = apr_file_open(&new_mutex->interproc, new_mutex->fname,
  +                           APR_CREATE | APR_WRITE | APR_EXCL, 0644, 
  +                           new_mutex->pool);
       }
       else {
           new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX");
  -        new_mutex->interproc = apr_mkstemp(new_mutex->fname);
  +        rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, 
  +                             new_mutex->pool);
       }
  -
  -    if (new_mutex->interproc < 0) {
  + 
  +    if (rv != APR_SUCCESS) {
           proc_mutex_flock_cleanup(new_mutex);
           return errno;
       }
  @@ -522,7 +531,7 @@
       int rc;
   
       do {
  -        rc = flock(mutex->interproc, LOCK_EX);
  +        rc = flock(mutex->interproc->filedes, LOCK_EX);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -536,7 +545,7 @@
       int rc;
   
       do {
  -        rc = flock(mutex->interproc, LOCK_UN);
  +        rc = flock(mutex->interproc->filedes, LOCK_UN);
       } while (rc < 0 && errno == EINTR);
       if (rc < 0) {
           return errno;
  @@ -560,14 +569,16 @@
                                                   const char *fname)
   {
       apr_proc_mutex_t *new_mutex;
  +    int rv;
   
       new_mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t));
   
       memcpy(new_mutex, *mutex, sizeof *new_mutex);
       new_mutex->pool = pool;
       new_mutex->fname = apr_pstrdup(pool, fname);
  -    new_mutex->interproc = open(new_mutex->fname, O_WRONLY, 0600);
  -    if (new_mutex->interproc == -1) {
  +    rv = apr_file_open(&new_mutex->interproc, new_mutex->fname,
  +                       APR_CREATE | APR_WRITE, 0600, new_mutex->pool);
  +    if (rv != APR_SUCCESS) {
           proc_mutex_flock_destroy(new_mutex);
           return errno;
       }
  @@ -705,7 +716,7 @@
   
       new_mutex->pool  = pool;
   #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
  -    new_mutex->interproc = -1;
  +    new_mutex->interproc = NULL;
   #endif
   
       if ((stat = proc_mutex_create(new_mutex, mech, fname)) != APR_SUCCESS)