summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2019-05-27 07:27:59 +0000
committerIvan Zhakov <ivan@apache.org>2019-05-27 07:27:59 +0000
commit944bfb5d1b282ea5ccdf023f7341641343da5a16 (patch)
tree921876e93a219a1eff6174d1f1b7716cdf13e64a
parentcc1441276000e5bb8bfc116f505f69361c39a357 (diff)
downloadapr-944bfb5d1b282ea5ccdf023f7341641343da5a16.tar.gz
Use manual reset events for OVERLAPPED I/O on Windows: I/O operations reset
provided event to non-signaled state automatically [1]. Using automatic reset events is not recommended: [[[ Functions such as ReadFile and WriteFile set this handle to the nonsignaled state before they begin an I/O operation. When the operation has completed, the handle is set to the signaled state. Functions such as GetOverlappedResult and the synchronization wait functions reset auto-reset events to the nonsignaled state. Therefore, you should use a manual reset event; if you use an auto-reset event, your application can stop responding if you wait for the operation to complete and then call GetOverlappedResult with the bWait parameter set to TRUE. ]]] [1] https://docs.microsoft.com/en-gb/windows/desktop/api/minwinbase/ns-minwinbase-_overlapped git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860110 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/win32/pipe.c4
-rw-r--r--file_io/win32/readwrite.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c
index b13507a91..8de7822af 100644
--- a/file_io/win32/pipe.c
+++ b/file_io/win32/pipe.c
@@ -146,7 +146,7 @@ static apr_status_t file_pipe_create(apr_file_t **in,
dwOpenMode |= FILE_FLAG_OVERLAPPED;
(*in)->pOverlapped =
(OVERLAPPED*) apr_pcalloc((*in)->pool, sizeof(OVERLAPPED));
- (*in)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ (*in)->pOverlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
(*in)->timeout = 0;
}
dwPipeMode = 0;
@@ -181,7 +181,7 @@ static apr_status_t file_pipe_create(apr_file_t **in,
dwOpenMode |= FILE_FLAG_OVERLAPPED;
(*out)->pOverlapped =
(OVERLAPPED*) apr_pcalloc((*out)->pool, sizeof(OVERLAPPED));
- (*out)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ (*out)->pOverlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
(*out)->timeout = 0;
}
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c
index 31c14fcbb..23d2358e7 100644
--- a/file_io/win32/readwrite.c
+++ b/file_io/win32/readwrite.c
@@ -247,7 +247,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size
if ((thefile->flags & APR_FOPEN_XTHREAD) && !thefile->pOverlapped ) {
thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool,
sizeof(OVERLAPPED));
- thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ thefile->pOverlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!thefile->pOverlapped->hEvent) {
rv = apr_get_os_error();
return rv;
@@ -394,7 +394,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
if ((thefile->flags & APR_FOPEN_XTHREAD) && !thefile->pOverlapped ) {
thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool,
sizeof(OVERLAPPED));
- thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ thefile->pOverlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!thefile->pOverlapped->hEvent) {
rv = apr_get_os_error();
return rv;
@@ -630,7 +630,7 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile)
if ((thefile->flags & APR_FOPEN_XTHREAD) && !thefile->pOverlapped) {
thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool,
sizeof(OVERLAPPED));
- thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ thefile->pOverlapped->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!thefile->pOverlapped->hEvent) {
rv = apr_get_os_error();
return rv;