[EMAIL PROTECTED] wrote:
Here is the patch to use apr_poll instead of select.  This is just being
posted for completeness, not because I believe it will actually perform as
well as the standard poll() implementation.  Bill offered to benchmark it,
so I am posting it.  I will re-implement apr_poll() tomorrow to offer much
better performance, and I will post a new patch based on that sometime
tomorrow.

Once we have actual numbers for all three implementations of
wait_for_io_or_timeout, we can have an intelligent conversation about the
best one to use, based on code complexity and performance.

is there any way to remove the need for the pool create and pcallocs that the socket-add does?


Ryan
Index: network_io/unix/sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.85
diff -u -d -b -w -u -r1.85 sendrecv.c
--- network_io/unix/sendrecv.c 2 Jul 2002 21:33:43 -0000 1.85
+++ network_io/unix/sendrecv.c 5 Jul 2002 08:39:44 -0000
@@ -65,36 +65,33 @@
apr_status_t apr_wait_for_io_or_timeout(apr_socket_t *sock, int for_read)
{
- struct timeval tv, *tvptr;
- fd_set fdset;
int srv;
+ int n = 1;
+ apr_pool_t *p;
+ apr_pollfd_t *pollset;
+ int type = for_read ? APR_POLLIN : APR_POLLOUT;
+ apr_pool_create(&p, sock->cntxt);
+ apr_poll_setup(&pollset, 1, p);
do {
- FD_ZERO(&fdset);
- FD_SET(sock->socketdes, &fdset);
- if (sock->timeout < 0) {
- tvptr = NULL;
+ apr_int16_t result;
+ apr_poll_socket_add(pollset, sock, type);
+ srv = apr_poll(pollset, &n, sock->timeout);
+
+ if (srv != APR_SUCCESS && APR_STATUS_IS_EINTR(srv)) {
+ continue;
}
- else {
- tv.tv_sec = sock->timeout / APR_USEC_PER_SEC;
- tv.tv_usec = sock->timeout % APR_USEC_PER_SEC;
- tvptr = &tv;
+ apr_poll_revents_get(&result, sock, pollset);
+ if ((result & type) || APR_STATUS_IS_TIMEUP(srv)) {
+ break;
}
- srv = select(sock->socketdes + 1,
- for_read ? &fdset : NULL,
- for_read ? NULL : &fdset,
- NULL,
- tvptr);
+
/* TODO - timeout should be smaller on repeats of this loop */
- } while (srv == -1 && errno == EINTR);
+ } while (1);
- if (srv == 0) {
- return APR_TIMEUP;
- }
- else if (srv < 0) {
- return errno;
- }
- return APR_SUCCESS;
+ apr_pool_destroy(p);
+
+ return srv;
}
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)


_______________________________________________________________________________
Ryan Bloom                              [EMAIL PROTECTED]
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------






Reply via email to