You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2005/07/09 09:07:19 UTC
svn commit: r209931 - in /apr/apr/trunk: CHANGES file_io/unix/filedup.c
file_io/unix/open.c file_io/unix/pipe.c support/unix/waitio.c
Author: brianp
Date: Sat Jul 9 00:07:17 2005
New Revision: 209931
URL: http://svn.apache.org/viewcvs?rev=209931&view=rev
Log:
Added lazy evaluation of the pollset that's used within apr_file_t
on platforms where apr_wait_for_io_or_timeout does not use poll(2).
This is a performance fix for httpd-2.x running on OS X, where the
creation of an unused, kqueue-based apr_pollset_t on every file
open and every file setaside was consuming a noticeable amount
of CPU time.
Modified:
apr/apr/trunk/CHANGES
apr/apr/trunk/file_io/unix/filedup.c
apr/apr/trunk/file_io/unix/open.c
apr/apr/trunk/file_io/unix/pipe.c
apr/apr/trunk/support/unix/waitio.c
Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?rev=209931&r1=209930&r2=209931&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Sat Jul 9 00:07:17 2005
@@ -1,5 +1,11 @@
Changes for APR 1.2.0
+ *) 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]
+
*) Fix Pollset corruption on Solaris 10. [Paul Querna]
*) Add %pt support to apr_snprintf() for printing an apr_os_thread_t
Modified: apr/apr/trunk/file_io/unix/filedup.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/filedup.c?rev=209931&r1=209930&r2=209931&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/filedup.c (original)
+++ apr/apr/trunk/file_io/unix/filedup.c Sat Jul 9 00:07:17 2005
@@ -93,9 +93,10 @@
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_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;
}
Modified: apr/apr/trunk/file_io/unix/open.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/open.c?rev=209931&r1=209930&r2=209931&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/open.c (original)
+++ apr/apr/trunk/file_io/unix/open.c Sat Jul 9 00:07:17 2005
@@ -49,6 +49,17 @@
/* Are there any error conditions other than EINTR or EBADF? */
rv = errno;
}
+#ifndef WAITIO_USES_POLL
+ if (file->pollset != NULL) {
+ int 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 @@
(*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 @@
(*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) {
Modified: apr/apr/trunk/file_io/unix/pipe.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/pipe.c?rev=209931&r1=209930&r2=209931&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/pipe.c (original)
+++ apr/apr/trunk/file_io/unix/pipe.c Sat Jul 9 00:07:17 2005
@@ -161,9 +161,10 @@
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 @@
(*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 @@
(*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);
Modified: apr/apr/trunk/support/unix/waitio.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/support/unix/waitio.c?rev=209931&r1=209930&r2=209931&view=diff
==============================================================================
--- apr/apr/trunk/support/unix/waitio.c (original)
+++ apr/apr/trunk/support/unix/waitio.c Sat Jul 9 00:07:17 2005
@@ -61,7 +61,7 @@
}
}
-#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 @@
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 {