diff options
author | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2003-11-17 01:41:18 +0000 |
---|---|---|
committer | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2003-11-17 01:41:18 +0000 |
commit | 4825d7e302a225991dec3d211c9ff42ba90b5039 (patch) | |
tree | 3a246b886518c4c5ac54eb4381929d7cd4d6659f /support | |
parent | 5703b123e764ea25f6c02096bca7ad701126c22d (diff) | |
download | libapr-4825d7e302a225991dec3d211c9ff42ba90b5039.tar.gz |
With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
needed to be rebuilt. Specifically, it needs a pollset, but we don't want
to allocate that all the time. Thus, we need to create it once at socket
or file creation time, and then reuse that pollset.
NOTE: this makes the library compile, but some of the test programs may
not. I have also not verified this work yet (in favor of just getting it
to at least compile...)
For the apr_arch_*.h files, I added a pollset member to the file and
socket structures.
For the various open/dup/etc functions, I added the creation of that
pollset whenever a file or socket is created.
(I may have missed some and will verify further)
For the socket create and sendrecv function, I added the creation of the
pollset.
(again, may have missed some, but if everybody uses alloc_socket, then we
should be okay)
* support/unix/waitio.c: rebuild in terms of the pollset
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64759 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support')
-rw-r--r-- | support/unix/waitio.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/support/unix/waitio.c b/support/unix/waitio.c index de72b7e9c..84a8483c7 100644 --- a/support/unix/waitio.c +++ b/support/unix/waitio.c @@ -65,38 +65,54 @@ #endif #ifdef USE_WAIT_FOR_IO + apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, - int for_read) + int for_read) { apr_interval_time_t timeout; - apr_pollfd_t pollset; - int srv, n; + apr_pollfd_t pfd; int type = for_read ? APR_POLLIN : APR_POLLOUT; + apr_pollset_t *pollset; + apr_status_t status; /* TODO - timeout should be less each time through this loop */ if (f) { - pollset.desc_type = APR_POLL_FILE; - pollset.desc.f = f; - pollset.p = f->pool; + pfd.desc_type = APR_POLL_FILE; + pfd.desc.f = f; + + pollset = f->pollset; timeout = f->timeout; } else { - pollset.desc_type = APR_POLL_SOCKET; - pollset.desc.s = s; - pollset.p = s->cntxt; + pfd.desc_type = APR_POLL_SOCKET; + pfd.desc.s = s; + + pollset = s->pollset; timeout = s->timeout; } - pollset.reqevents = type; + pfd.reqevents = type; + + /* Remove the object if it was in the pollset, then add in the new + * object with the correct reqevents value. Ignore the status result + * on the remove, because it might not be in there (yet). + */ + (void) apr_pollset_remove(pollset, &pfd); + + /* ### check status code */ + (void) apr_pollset_add(pollset, &pfd); do { - srv = apr_poll(&pollset, 1, &n, timeout); + int numdesc; + const apr_pollfd_t *pdesc; + + status = apr_pollset_poll(pollset, timeout, &numdesc, &pdesc); - if (n == 1 && pollset.rtnevents & type) { + if (numdesc == 1 && (pdesc[0].rtnevents & type) != 0) { return APR_SUCCESS; } - } while (APR_STATUS_IS_EINTR(srv)); + } while (APR_STATUS_IS_EINTR(status)); - return srv; + return status; } -#endif +#endif /* USE_WAIT_FOR_IO */ |