summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorstoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68>2002-03-06 02:47:34 +0000
committerstoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68>2002-03-06 02:47:34 +0000
commit80d696c55a7169b12c40fbe96364938f7f0edf91 (patch)
tree2e207e28dc5ce5d1613040664a478221c81b4509 /file_io
parent4b1d308bd3111b7418bc4d17f48dd1f4fa4e2b94 (diff)
downloadlibapr-80d696c55a7169b12c40fbe96364938f7f0edf91.tar.gz
Win32: Fix APR_XTHREAD support. A thread should have its own unique
apr_file_t structure (and its own io event and overlapped structure) when doing cross thread overlapped i/o. The only application using this support that I am aware of is the Apache 2.0 file handle cache. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/win32/open.c8
-rw-r--r--file_io/win32/readwrite.c28
2 files changed, 28 insertions, 8 deletions
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index cf91d106c..6281a3d6e 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -392,14 +392,6 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
(*new)->mutex = NULL;
}
- if (flag & APR_XTHREAD) {
- /* This win32 specific feature is required to pass
- * the current offset for an overlaped file handle.
- */
- (*new)->pOverlapped = (OVERLAPPED*) apr_pcalloc(cont, sizeof(OVERLAPPED));
- (*new)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- }
-
(*new)->pipe = 0;
(*new)->timeout = -1;
(*new)->ungetchar = -1;
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c
index d8c3c3fcf..0ee980466 100644
--- a/file_io/win32/readwrite.c
+++ b/file_io/win32/readwrite.c
@@ -168,6 +168,20 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size
return APR_SUCCESS;
}
+ /* If the file is open for xthread support, allocate and
+ * initialize the overlapped and io completion event (hEvent).
+ * Threads should NOT share an apr_file_t or its hEvent.
+ */
+ if ((thefile->flags & APR_XTHREAD) && !thefile->pOverlapped ) {
+ thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->cntxt,
+ sizeof(OVERLAPPED));
+ thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (!thefile->pOverlapped->hEvent) {
+ rv = apr_get_os_error();
+ return rv;
+ }
+ }
+
/* Handle the ungetchar if there is one */
if (thefile->ungetchar != -1) {
bytes_read = 1;
@@ -239,6 +253,20 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
apr_status_t rv;
DWORD bwrote;
+ /* If the file is open for xthread support, allocate and
+ * initialize the overlapped and io completion event (hEvent).
+ * Threads should NOT share an apr_file_t or its hEvent.
+ */
+ if ((thefile->flags & APR_XTHREAD) && !thefile->pOverlapped ) {
+ thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->cntxt,
+ sizeof(OVERLAPPED));
+ thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (!thefile->pOverlapped->hEvent) {
+ rv = apr_get_os_error();
+ return rv;
+ }
+ }
+
if (thefile->buffered) {
char *pos = (char *)buf;
apr_size_t blocksize;