jerenkrantz 2002/07/11 11:47:45
Modified: flood CHANGES flood_net.c flood_net.h flood_net_ssl.c
Log:
Switch to using the new apr_poll() API.
Revision Changes Path
1.38 +2 -0 httpd-test/flood/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-test/flood/CHANGES,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- CHANGES 9 Apr 2002 08:03:16 -0000 1.37
+++ CHANGES 11 Jul 2002 18:47:45 -0000 1.38
@@ -1,5 +1,7 @@
Changes since milestone-03:
+* Switch to new apr_poll() API. [Justin Erenkrantz]
+
* Stop using the apr_lock.h API and start using apr_thread_mutex.h
instead. [Aaron Bannert]
1.10 +17 -17 httpd-test/flood/flood_net.c
Index: flood_net.c
===================================================================
RCS file: /home/cvs/httpd-test/flood/flood_net.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- flood_net.c 31 May 2002 08:00:23 -0000 1.9
+++ flood_net.c 11 Jul 2002 18:47:45 -0000 1.10
@@ -103,10 +103,11 @@
}
apr_setsocketopt(fs->socket, APR_SO_TIMEOUT, LOCAL_SOCKET_TIMEOUT);
-
- apr_poll_setup(&fs->poll, 1, pool);
- apr_poll_socket_add(fs->poll, fs->socket, APR_POLLIN);
-
+ fs->read_pollset.desc_type = APR_POLL_SOCKET;
+ fs->read_pollset.desc.s = fs->socket;
+ fs->read_pollset.reqevents = APR_POLLIN;
+ fs->read_pollset.p = pool;
+
return fs;
}
@@ -120,9 +121,9 @@
apr_status_t read_socket(flood_socket_t *s, char *buf, int *buflen)
{
apr_status_t e;
- int socketsRead = 1;
+ apr_int32_t socketsRead;
- e = apr_poll(s->poll, &socketsRead, LOCAL_SOCKET_TIMEOUT);
+ e = apr_poll(&s->read_pollset, 1, &socketsRead, LOCAL_SOCKET_TIMEOUT);
if (e != APR_SUCCESS)
return e;
return apr_recv(s->socket, buf, buflen);
@@ -147,19 +148,18 @@
apr_status_t check_socket(flood_socket_t *s, apr_pool_t *pool)
{
apr_status_t e;
- int socketsRead = 1;
- apr_pollfd_t *pout;
+ apr_int32_t socketsRead;
+ apr_pollfd_t pout;
apr_int16_t event;
- apr_poll_setup(&pout, 1, pool);
- apr_poll_socket_add(pout, s->socket, APR_POLLIN | APR_POLLPRI |
APR_POLLERR | APR_POLLHUP | APR_POLLNVAL);
-
- e = apr_poll(pout, &socketsRead, 1000);
- if (socketsRead) {
- apr_poll_revents_get(&event, s->socket, pout);
- if (event) {
- return APR_EGENERAL;
- }
+ pout.desc_type = APR_POLL_SOCKET;
+ pout.desc.s = s->socket;
+ pout.reqevents = APR_POLLIN | APR_POLLPRI | APR_POLLERR | APR_POLLHUP |
APR_POLLNVAL;
+ pout.p = pool;
+
+ e = apr_poll(&pout, 1, &socketsRead, 1000);
+ if (socketsRead && pout.rtnevents) {
+ return APR_EGENERAL;
}
return APR_SUCCESS;
1.7 +2 -1 httpd-test/flood/flood_net.h
Index: flood_net.h
===================================================================
RCS file: /home/cvs/httpd-test/flood/flood_net.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- flood_net.h 27 Mar 2002 21:38:03 -0000 1.6
+++ flood_net.h 11 Jul 2002 18:47:45 -0000 1.7
@@ -58,13 +58,14 @@
#define __flood_socket_h
#include <apr_network_io.h> /* apr_socket_t */
+#include <apr_poll.h> /* apr_pollfd_t */
#include <apr_pools.h> /* apr_pool_t */
#include "flood_profile.h"
typedef struct flood_socket_t {
apr_socket_t *socket;
- apr_pollfd_t *poll;
+ apr_pollfd_t read_pollset;
} flood_socket_t;
flood_socket_t* open_socket(apr_pool_t *pool, request_t *r);
1.20 +7 -5 httpd-test/flood/flood_net_ssl.c
Index: flood_net_ssl.c
===================================================================
RCS file: /home/cvs/httpd-test/flood/flood_net_ssl.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- flood_net_ssl.c 31 May 2002 07:59:27 -0000 1.19
+++ flood_net_ssl.c 11 Jul 2002 18:47:45 -0000 1.20
@@ -277,12 +277,13 @@
apr_status_t ssl_read_socket(ssl_socket_t *s, char *buf, int *buflen)
{
apr_status_t e;
- int sslError, socketsRead;
+ int sslError;
+ apr_int32_t socketsRead;
/* Wait until there is something to read. */
if (SSL_pending(s->ssl_connection) < *buflen) {
- socketsRead = 1;
- e = apr_poll(s->socket->poll, &socketsRead, LOCAL_SOCKET_TIMEOUT);
+ e = apr_poll(&s->socket->read_pollset, 1, &socketsRead,
+ LOCAL_SOCKET_TIMEOUT);
if (socketsRead != 1)
return APR_TIMEUP;
@@ -319,9 +320,10 @@
char buf[1];
int buflen = 1;
/* Wait until there is something to read. */
- int socketsRead = 1;
+ apr_int32_t socketsRead;
apr_status_t e;
- e = apr_poll(s->socket->poll, &socketsRead, LOCAL_SOCKET_TIMEOUT);
+ e = apr_poll(&s->socket->read_pollset, 1, &socketsRead,
+ LOCAL_SOCKET_TIMEOUT);
e = SSL_read(s->ssl_connection, buf, buflen);
}