aaron 01/11/20 20:21:04
Modified: file_io/unix filedup.c open.c readwrite.c
include/arch/unix fileio.h
Log:
Conversion of the file_io routines from INTRAPROCESS apr_lock_t
types to the new apr_thread_mutex_t. All calls to the lock API
are protected with APR_HAS_THREADS. Tested on each of Linux,
Solaris, and most importantly in this case FreeBSD.
Revision Changes Path
1.35 +3 -2 apr/file_io/unix/filedup.c
Index: filedup.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filedup.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- filedup.c 2001/07/18 19:41:20 1.34
+++ filedup.c 2001/11/21 04:21:03 1.35
@@ -55,6 +55,7 @@
#include "fileio.h"
#include "apr_strings.h"
#include "apr_portable.h"
+#include "apr_thread_mutex.h"
#include "inherit.h"
apr_status_t apr_file_dup(apr_file_t **new_file, apr_file_t *old_file,
apr_pool_t *p)
@@ -81,8 +82,8 @@
(*new_file)->buffered = old_file->buffered;
if ((*new_file)->buffered) {
#if APR_HAS_THREADS
- apr_lock_create(&((*new_file)->thlock), APR_MUTEX, APR_INTRAPROCESS,
NULL,
- p);
+ apr_thread_mutex_create(&((*new_file)->thlock),
+ APR_THREAD_MUTEX_DEFAULT, p);
#endif
(*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE);
}
1.88 +4 -3 apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/open.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- open.c 2001/10/02 00:55:45 1.87
+++ open.c 2001/11/21 04:21:03 1.88
@@ -55,6 +55,7 @@
#include "fileio.h"
#include "apr_strings.h"
#include "apr_portable.h"
+#include "apr_thread_mutex.h"
#include "inherit.h"
apr_status_t apr_unix_file_cleanup(void *thefile)
@@ -74,7 +75,7 @@
}
#if APR_HAS_THREADS
if (file->thlock) {
- rv = apr_lock_destroy(file->thlock);
+ rv = apr_thread_mutex_destroy(file->thlock);
}
#endif
}
@@ -118,8 +119,8 @@
if ((*new)->buffered) {
(*new)->buffer = apr_palloc(cont, APR_FILE_BUFSIZE);
#if APR_HAS_THREADS
- rv = apr_lock_create(&((*new)->thlock), APR_MUTEX, APR_INTRAPROCESS,
- NULL, cont);
+ rv = apr_thread_mutex_create(&((*new)->thlock),
+ APR_THREAD_MUTEX_DEFAULT, cont);
if (rv) {
return rv;
}
1.74 +5 -5 apr/file_io/unix/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/readwrite.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- readwrite.c 2001/11/11 16:32:10 1.73
+++ readwrite.c 2001/11/21 04:21:03 1.74
@@ -54,7 +54,7 @@
#include "fileio.h"
#include "apr_strings.h"
-#include "apr_lock.h"
+#include "apr_thread_mutex.h"
/* The only case where we don't use wait_for_io_or_timeout is on
* pre-BONE BeOS, so this check should be sufficient and simpler */
@@ -118,7 +118,7 @@
apr_uint64_t size = *nbytes;
#if APR_HAS_THREADS
- apr_lock_acquire(thefile->thlock);
+ apr_thread_mutex_lock(thefile->thlock);
#endif
if (thefile->direction == 1) {
@@ -164,7 +164,7 @@
rv = 0;
}
#if APR_HAS_THREADS
- apr_lock_release(thefile->thlock);
+ apr_thread_mutex_unlock(thefile->thlock);
#endif
return rv;
}
@@ -223,7 +223,7 @@
int size = *nbytes;
#if APR_HAS_THREADS
- apr_lock_acquire(thefile->thlock);
+ apr_thread_mutex_lock(thefile->thlock);
#endif
if ( thefile->direction == 0 ) {
@@ -251,7 +251,7 @@
}
#if APR_HAS_THREADS
- apr_lock_release(thefile->thlock);
+ apr_thread_mutex_unlock(thefile->thlock);
#endif
return rv;
}
1.37 +2 -1 apr/include/arch/unix/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/fileio.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- fileio.h 2001/09/24 05:41:56 1.36
+++ fileio.h 2001/11/21 04:21:04 1.37
@@ -63,6 +63,7 @@
#include "apr_file_info.h"
#include "apr_errno.h"
#include "apr_lib.h"
+#include "apr_thread_mutex.h"
/* System headers the file I/O library needs */
#if APR_HAVE_FCNTL_H
@@ -137,7 +138,7 @@
int direction; /* buffer being used for 0 = read, 1 = write */
unsigned long filePtr; /* position in file of handle */
#if APR_HAS_THREADS
- struct apr_lock_t *thlock;
+ struct apr_thread_mutex_t *thlock;
#endif
};