summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2005-07-20 05:50:31 +0000
committerbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2005-07-20 05:50:31 +0000
commit733ff74866c3463548dc7b1b0abab5b0910bdf69 (patch)
treea4b1566026e51a2300eb1aa822d5422e06488857
parent7913cf997a14e28cb5cb8367ac34e1526032ac84 (diff)
downloadlibapr-733ff74866c3463548dc7b1b0abab5b0910bdf69.tar.gz
lazy initialization of the pollset within apr_file_t (backport from 1.2)
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.1.x@219843 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES6
-rw-r--r--STATUS10
-rw-r--r--file_io/unix/filedup.c11
-rw-r--r--file_io/unix/open.c25
-rw-r--r--file_io/unix/pipe.c11
-rw-r--r--support/unix/waitio.c9
6 files changed, 44 insertions, 28 deletions
diff --git a/CHANGES b/CHANGES
index dbcd95149..47bbb4958 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,11 @@
Changes for APR 1.1.1
+ *) Switch to lazy initialization of the pollset that's used within
+ apr_file_t on platforms where apr_wait_for_io_or_timeout() doesn't
+ use poll(2). (This fixes a performance problem observed in httpd-2.x
+ on OS X due to the use of poll now being disabled by default on that
+ platform.) [Brian Pane]
+
*) Support APR_SO_SNDBUF and APR_SO_RCVBUF on Windows. PR 32177.
[Sim <sgobbi datamanagement.it>, Jeff Trawick]
diff --git a/STATUS b/STATUS
index 3f0fa15a3..e733777f6 100644
--- a/STATUS
+++ b/STATUS
@@ -30,16 +30,6 @@ RELEASE 1.0.1 SHOWSTOPPERS:
CURRENT VOTES:
- *) Backport r209931 from 1.2 development trunk:
- "Switch to lazy initialization of the pollset that's used within
- apr_file_t on platforms where apr_wait_for_io_or_timeout() doesn't
- use poll(2). (This fixes a performance problem observed in httpd-2.x
- on OS X due to the use of poll now being disabled by default on that
- platform.)"
- +1: brianp
- 0:
- -1:
-
CURRENT test/testall -v EXCEPTIONS:
Please add any platform anomilies to the following exception list.
diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c
index fe792258e..fdc0358e0 100644
--- a/file_io/unix/filedup.c
+++ b/file_io/unix/filedup.c
@@ -93,9 +93,10 @@ static apr_status_t file_dup(apr_file_t **new_file,
apr_unix_file_cleanup,
apr_unix_file_cleanup);
#ifndef WAITIO_USES_POLL
- /* Create a pollset with room for one descriptor. */
- /* ### check return codes */
- (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
+ /* Start out with no pollset. apr_wait_for_io_or_timeout() will
+ * initialize the pollset if needed.
+ */
+ (*new_file)->pollset = NULL;
#endif
return APR_SUCCESS;
}
@@ -150,9 +151,7 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file,
apr_pool_cleanup_kill(old_file->pool, (void *)old_file,
apr_unix_file_cleanup);
#ifndef WAITIO_USES_POLL
- /* Create a pollset with room for one descriptor. */
- /* ### check return codes */
- (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
+ (*new_file)->pollset = NULL;
#endif
return APR_SUCCESS;
}
diff --git a/file_io/unix/open.c b/file_io/unix/open.c
index 55b986302..589c85314 100644
--- a/file_io/unix/open.c
+++ b/file_io/unix/open.c
@@ -49,6 +49,17 @@ apr_status_t apr_unix_file_cleanup(void *thefile)
/* Are there any error conditions other than EINTR or EBADF? */
rv = errno;
}
+#ifndef WAITIO_USES_POLL
+ if (file->pollset != NULL) {
+ apr_status_t pollset_rv = apr_pollset_destroy(file->pollset);
+ /* If the file close failed, return its error value,
+ * not apr_pollset_destroy()'s.
+ */
+ if (rv == APR_SUCCESS) {
+ rv = pollset_rv;
+ }
+ }
+#endif /* !WAITIO_USES_POLL */
return rv != APR_SUCCESS ? rv : flush_rv;
}
@@ -159,9 +170,10 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new,
(*new)->dataRead = 0;
(*new)->direction = 0;
#ifndef WAITIO_USES_POLL
- /* Create a pollset with room for one descriptor. */
- /* ### check return codes */
- (void) apr_pollset_create(&(*new)->pollset, 1, pool, 0);
+ /* Start out with no pollset. apr_wait_for_io_or_timeout() will
+ * initialize the pollset if needed.
+ */
+ (*new)->pollset = NULL;
#endif
if (!(flag & APR_FILE_NOCLEANUP)) {
apr_pool_cleanup_register((*new)->pool, (void *)(*new),
@@ -220,9 +232,10 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file,
(*file)->buffered = (flags & APR_BUFFERED) > 0;
#ifndef WAITIO_USES_POLL
- /* Create a pollset with room for one descriptor. */
- /* ### check return codes */
- (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0);
+ /* Start out with no pollset. apr_wait_for_io_or_timeout() will
+ * initialize the pollset if needed.
+ */
+ (*file)->pollset = NULL;
#endif
if ((*file)->buffered) {
diff --git a/file_io/unix/pipe.c b/file_io/unix/pipe.c
index ec54432f7..d8e52495c 100644
--- a/file_io/unix/pipe.c
+++ b/file_io/unix/pipe.c
@@ -161,9 +161,10 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file,
apr_pool_cleanup_null);
}
#ifndef WAITIO_USES_POLL
- /* Create a pollset with room for one descriptor. */
- /* ### check return codes */
- (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0);
+ /* Start out with no pollset. apr_wait_for_io_or_timeout() will
+ * initialize the pollset if needed.
+ */
+ (*file)->pollset = NULL;
#endif
return APR_SUCCESS;
}
@@ -197,7 +198,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out
(*in)->thlock = NULL;
#endif
#ifndef WAITIO_USES_POLL
- (void) apr_pollset_create(&(*in)->pollset, 1, pool, 0);
+ (*in)->pollset = NULL;
#endif
(*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
(*out)->pool = pool;
@@ -212,7 +213,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out
(*out)->thlock = NULL;
#endif
#ifndef WAITIO_USES_POLL
- (void) apr_pollset_create(&(*out)->pollset, 1, pool, 0);
+ (*out)->pollset = NULL;
#endif
apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup,
apr_pool_cleanup_null);
diff --git a/support/unix/waitio.c b/support/unix/waitio.c
index 81fea536b..167ad6d08 100644
--- a/support/unix/waitio.c
+++ b/support/unix/waitio.c
@@ -61,7 +61,7 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
}
}
-#else
+#else /* !WAITIO_USES_POLL */
apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
int for_read)
@@ -78,6 +78,13 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
pfd.desc.f = f;
pollset = f->pollset;
+ if (pollset == NULL) {
+ status = apr_pollset_create(&(f->pollset), 1, f->pool, 0);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+ pollset = f->pollset;
+ }
timeout = f->timeout;
}
else {