aboutsummaryrefslogtreecommitdiff
path: root/file_io/os2/open.c
diff options
context:
space:
mode:
authorBrian Havard <bjh@apache.org>2000-04-18 14:53:29 +0000
committerBrian Havard <bjh@apache.org>2000-04-18 14:53:29 +0000
commitabead49b4a73bebd325afe0d96b3b5d3d5611244 (patch)
tree874269ad09eba3a4f8b49b67e1aa60d72030464c /file_io/os2/open.c
parentc1830c8c259db1e4f1eadeb7c6b9e395d1944de8 (diff)
downloadapr-abead49b4a73bebd325afe0d96b3b5d3d5611244.tar.gz
apr-abead49b4a73bebd325afe0d96b3b5d3d5611244.zip
OS/2: Switch from using critical sections to mutex semaphores for making
the buffering code thread safe. It's the more subtle approach and is actually faster too. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@59884 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/os2/open.c')
-rw-r--r--file_io/os2/open.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/file_io/os2/open.c b/file_io/os2/open.c
index f59913e9b..791073f14 100644
--- a/file_io/os2/open.c
+++ b/file_io/os2/open.c
@@ -97,6 +97,14 @@ ap_status_t ap_open(ap_file_t **new, const char *fname, ap_int32_t flag, ap_fil
dafile->buffered = (flag & APR_BUFFERED) > 0;
+ if (dafile->buffered) {
+ dafile->buffer = ap_palloc(cntxt, APR_FILE_BUFSIZE);
+ rv = ap_create_lock(&dafile->mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, cntxt);
+
+ if (rv)
+ return APR_OS2_STATUS(rv);
+ }
+
if (flag & APR_CREATE) {
oflags |= OPEN_ACTION_CREATE_IF_NEW;
if (!(flag & APR_EXCL)) {
@@ -136,9 +144,6 @@ ap_status_t ap_open(ap_file_t **new, const char *fname, ap_int32_t flag, ap_fil
dafile->dataRead = 0;
dafile->direction = 0;
- if (dafile->buffered)
- dafile->buffer = ap_palloc(cntxt, APR_FILE_BUFSIZE);
-
ap_register_cleanup(dafile->cntxt, dafile, apr_file_cleanup, ap_null_cleanup);
return APR_SUCCESS;
}
@@ -166,6 +171,9 @@ ap_status_t ap_close(ap_file_t *file)
}
}
+ if (file->buffered)
+ ap_destroy_lock(file->mutex);
+
return APR_SUCCESS;
}