summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2002-07-11 05:19:45 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2002-07-11 05:19:45 +0000
commit34f1483d9a2ee8fa3e627d99a3c4456354c2d3ac (patch)
tree72288d0faedb43aff1c83e23e85c3813e5826ce2 /file_io
parentd2a28b5fcbcd051a2c20d86c3eb817fe4f5aa578 (diff)
downloadlibapr-34f1483d9a2ee8fa3e627d99a3c4456354c2d3ac.tar.gz
Reimplement apr_poll() on Unix. This improves performance by giving the
user back control over the memory in the pollset. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63601 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/unix/readwrite.c42
1 files changed, 3 insertions, 39 deletions
diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c
index 3963840a3..fc283240d 100644
--- a/file_io/unix/readwrite.c
+++ b/file_io/unix/readwrite.c
@@ -55,6 +55,7 @@
#include "fileio.h"
#include "apr_strings.h"
#include "apr_thread_mutex.h"
+#include "apr_support.h"
/* The only case where we don't use wait_for_io_or_timeout is on
* pre-BONE BeOS, so this check should be sufficient and simpler */
@@ -62,43 +63,6 @@
#define USE_WAIT_FOR_IO
#endif
-#ifdef USE_WAIT_FOR_IO
-static apr_status_t wait_for_io_or_timeout(apr_file_t *file, int for_read)
-{
- struct timeval tv, *tvptr;
- fd_set fdset;
- int srv;
-
- /* TODO - timeout should be less each time through this loop */
-
- do {
- FD_ZERO(&fdset);
- FD_SET(file->filedes, &fdset);
- if (file->timeout >= 0) {
- tv.tv_sec = apr_time_sec(file->timeout);
- tv.tv_usec = apr_time_usec(file->timeout);
- tvptr = &tv;
- }
- else {
- tvptr = NULL;
- }
- srv = select(file->filedes + 1,
- for_read ? &fdset : NULL,
- for_read ? NULL : &fdset,
- NULL,
- tvptr);
- } while (srv == -1 && errno == EINTR);
-
- if (srv == 0) {
- return APR_TIMEUP;
- }
- else if (srv < 0) {
- return errno;
- }
- return APR_SUCCESS;
-}
-#endif
-
/* problems:
* 1) ungetchar not used for buffered files
*/
@@ -193,7 +157,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size
if (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
thefile->timeout != 0) {
- apr_status_t arv = wait_for_io_or_timeout(thefile, 1);
+ apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 1);
if (arv != APR_SUCCESS) {
*nbytes = bytes_read;
return arv;
@@ -272,7 +236,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
if (rv == (apr_size_t)-1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
thefile->timeout != 0) {
- apr_status_t arv = wait_for_io_or_timeout(thefile, 0);
+ apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 0);
if (arv != APR_SUCCESS) {
*nbytes = 0;
return arv;