diff options
author | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 13:26:11 +0000 |
---|---|---|
committer | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 13:26:11 +0000 |
commit | 764cb56c0ad3b1b7919fe00665fc9a0b9289e9d2 (patch) | |
tree | 2a9bee9f41ecc159bfa200595dbdae93c0fee505 | |
parent | 4124694191d6a36240cc91b3ae68ce5a144ae2f8 (diff) | |
download | libapr-764cb56c0ad3b1b7919fe00665fc9a0b9289e9d2.tar.gz |
Fix core on win32 when using wakeable pollset
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@743730 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | file_io/win32/pipe.c | 36 | ||||
-rw-r--r-- | poll/unix/select.c | 17 |
3 files changed, 41 insertions, 16 deletions
@@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes for APR 1.4.0 + *) apr_pollset_wakeup() on Windows: Fix core caused by closing the + file_socket_pipe with standard file_close. + [Arsen Chaloyan, Mladen Turk] + *) apr_socket_sendfile() on Solaris: Fix handling of files truncated after the sender determines the length. (This fixes a busy loop in httpd when a file being served is truncated.) [Jeff Trawick] diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c index 5598acdf8..4ee629d9f 100644 --- a/file_io/win32/pipe.c +++ b/file_io/win32/pipe.c @@ -349,22 +349,9 @@ static apr_status_t socket_pipe_cleanup(void *thefile) return APR_SUCCESS; } -#if 0 -/* XXX Do we need this as public API or APR private ? - * It's main usage is for interrupting pollset because - * of !APR_FILES_AS_SOCKETS. - * Duplicating sockets in child requires WSADuplicateSocket - * and passing WSAPROTOCOL_INFO data to the child, so we - * would need some sort of IPC instead DuplicateHandle used - * for files and pipes. - */ -APR_DECLARE(apr_status_t) -#else -apr_status_t -#endif -apr_file_socket_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *p) +apr_status_t apr_file_socket_pipe_create(apr_file_t **in, + apr_file_t **out, + apr_pool_t *p) { apr_status_t rv; SOCKET rd; @@ -408,3 +395,20 @@ apr_file_socket_pipe_create(apr_file_t **in, return rv; } + +apr_status_t apr_file_socket_pipe_close(apr_file_t *file) +{ + apr_status_t stat; + if (!file->pipe) + return apr_file_close(file); + if ((stat = socket_pipe_cleanup(file)) == APR_SUCCESS) { + apr_pool_cleanup_kill(file->pool, file, socket_pipe_cleanup); + + if (file->mutex) { + apr_thread_mutex_destroy(file->mutex); + } + + return APR_SUCCESS; + } + return stat; +} diff --git a/poll/unix/select.c b/poll/unix/select.c index 4780665b0..c3ad8cd7b 100644 --- a/poll/unix/select.c +++ b/poll/unix/select.c @@ -195,6 +195,9 @@ apr_file_socket_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *p); +extern apr_status_t +apr_file_socket_pipe_close(apr_file_t *file); + /* Create a dummy wakeup socket pipe for interrupting the poller */ static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) @@ -218,6 +221,12 @@ static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) { return APR_ENOTIMPL; } + +static apr_status_t apr_file_socket_pipe_close(apr_file_t *file) +{ + return APR_ENOTIMPL; +} + #endif /* WIN32 */ #else /* APR_FILES_AS_SOCKETS */ @@ -265,11 +274,19 @@ static apr_status_t wakeup_pipe_cleanup(void *p) if (pollset->flags & APR_POLLSET_WAKEABLE) { /* Close both sides of the wakeup pipe */ if (pollset->wakeup_pipe[0]) { +#if APR_FILES_AS_SOCKETS apr_file_close(pollset->wakeup_pipe[0]); +#else + apr_file_socket_pipe_close(pollset->wakeup_pipe[0]); +#endif pollset->wakeup_pipe[0] = NULL; } if (pollset->wakeup_pipe[1]) { +#if APR_FILES_AS_SOCKETS apr_file_close(pollset->wakeup_pipe[1]); +#else + apr_file_socket_pipe_close(pollset->wakeup_pipe[1]); +#endif pollset->wakeup_pipe[1] = NULL; } } |