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/23 06:18:53 UTC
svn commit: r224440 - in /apr/apr/branches/1.0.x: CHANGES STATUS
file_io/unix/filedup.c file_io/unix/open.c file_io/unix/pipe.c
support/unix/waitio.c
Author: brianp
Date: Fri Jul 22 21:18:50 2005
New Revision: 224440
URL: http://svn.apache.org/viewcvs?rev=224440&view=rev
Log:
lazy initialization of the pollset within apr_file_t (backport from 1.2)
Modified:
apr/apr/branches/1.0.x/CHANGES
apr/apr/branches/1.0.x/STATUS
apr/apr/branches/1.0.x/file_io/unix/filedup.c
apr/apr/branches/1.0.x/file_io/unix/open.c
apr/apr/branches/1.0.x/file_io/unix/pipe.c
apr/apr/branches/1.0.x/support/unix/waitio.c
Modified: apr/apr/branches/1.0.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/CHANGES?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/CHANGES (original)
+++ apr/apr/branches/1.0.x/CHANGES Fri Jul 22 21:18:50 2005
@@ -1,5 +1,11 @@
Changes for APR 1.0.2
+ *) 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]
Modified: apr/apr/branches/1.0.x/STATUS
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/STATUS?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/STATUS (original)
+++ apr/apr/branches/1.0.x/STATUS Fri Jul 22 21:18:50 2005
@@ -28,16 +28,6 @@
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.
Modified: apr/apr/branches/1.0.x/file_io/unix/filedup.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/file_io/unix/filedup.c?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/file_io/unix/filedup.c (original)
+++ apr/apr/branches/1.0.x/file_io/unix/filedup.c Fri Jul 22 21:18:50 2005
@@ -1,4 +1,5 @@
-/* Copyright 2000-2004 The Apache Software Foundation
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,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;
}
@@ -149,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/branches/1.0.x/file_io/unix/open.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/file_io/unix/open.c?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/file_io/unix/open.c (original)
+++ apr/apr/branches/1.0.x/file_io/unix/open.c Fri Jul 22 21:18:50 2005
@@ -1,4 +1,5 @@
-/* Copyright 2000-2004 The Apache Software Foundation
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,6 +49,17 @@
/* 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;
}
@@ -158,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),
@@ -219,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/branches/1.0.x/file_io/unix/pipe.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/file_io/unix/pipe.c?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/file_io/unix/pipe.c (original)
+++ apr/apr/branches/1.0.x/file_io/unix/pipe.c Fri Jul 22 21:18:50 2005
@@ -1,4 +1,5 @@
-/* Copyright 2000-2004 The Apache Software Foundation
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +43,7 @@
fd_flags &= ~O_NONBLOCK;
# elif defined(O_NDELAY)
fd_flags &= ~O_NDELAY;
-# elif defined(FNDELAY)
+# elif defined(O_FNDELAY)
fd_flags &= ~O_FNDELAY;
# else
/* XXXX: this breaks things, but an alternative isn't obvious...*/
@@ -77,7 +78,7 @@
fd_flags |= O_NONBLOCK;
# elif defined(O_NDELAY)
fd_flags |= O_NDELAY;
-# elif defined(FNDELAY)
+# elif defined(O_FNDELAY)
fd_flags |= O_FNDELAY;
# else
/* XXXX: this breaks things, but an alternative isn't obvious...*/
@@ -160,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;
}
@@ -196,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;
@@ -211,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/branches/1.0.x/support/unix/waitio.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/support/unix/waitio.c?rev=224440&r1=224439&r2=224440&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/support/unix/waitio.c (original)
+++ apr/apr/branches/1.0.x/support/unix/waitio.c Fri Jul 22 21:18:50 2005
@@ -1,4 +1,5 @@
-/* Copyright 2000-2004 The Apache Software Foundation
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,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)
@@ -77,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 {