You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/05/19 18:37:59 UTC
cvs commit: apache-apr/apr/test Makefile.in ab_apr.c
rbb 99/05/19 09:37:58
Modified: apr/test Makefile.in ab_apr.c
Log:
Bring ab_apr back to working state with the current apr layer.
Revision Changes Path
1.5 +5 -0 apache-apr/apr/test/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apache-apr/apr/test/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Makefile.in 1999/05/17 13:11:51 1.4
+++ Makefile.in 1999/05/19 16:37:56 1.5
@@ -17,12 +17,14 @@
testproc \
testsock \
testthread \
+ ab \
testtime
OBJS= testfile.o \
testproc.o \
testsock.o \
testthread.o \
+ ab_apr.o \
testtime.o
.c.o:
@@ -32,6 +34,9 @@
testfile: testfile.o
$(CC) $(CFLAGS) testfile.o -o testfile $(LDFLAGS)
+
+ab: ab_apr.o
+ $(CC) $(CFLAGS) ab_apr.o -o ab $(LDFLAGS)
testproc: testproc.o
$(CC) $(CFLAGS) testproc.o -o testproc $(LDFLAGS)
1.7 +35 -21 apache-apr/apr/test/ab_apr.c
Index: ab_apr.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/test/ab_apr.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ab_apr.c 1999/05/18 12:19:36 1.6
+++ ab_apr.c 1999/05/19 16:37:56 1.7
@@ -478,21 +478,29 @@
c->cbx = 0;
c->gotheader = 0;
- if ((c->aprsock = ap_create_tcp_socket(cntxt)) == NULL)
+ if ((c->aprsock = ap_create_tcp_socket(cntxt)) == NULL) {
err("Socket:");
+ }
+ if (ap_setport(cntxt, c->aprsock, port) == APR_FAILURE) {
+ err("Port:");
+ }
nonblock(c->aprsock);
gettimeofday(&c->start, 0);
- if (ap_connect(cntxt, c->aprsock, hostname)) {
- return;
- }
- else {
- /*we don't have to close the socket. If we have an error this bad,
- ap_connect will destroy it for us. */
- err_conn++;
- if (bad++ > 10) {
- err("\nTest aborted after 10 failures\n\n");
+ if (ap_connect(cntxt, c->aprsock, hostname) == APR_FAILURE) {
+ if (errno == EINPROGRESS) {
+ c->state = STATE_CONNECTING;
+ ap_add_poll_socket(cntxt, readbits, c->aprsock, APR_POLLOUT, c->socknum);
+ return;
}
- start_connect(c);
+ else {
+ /* we don't have to close the socket. If we have an error this bad,
+ ap_connect will destroy it for us. */
+ err_conn++;
+ if (bad++ > 10) {
+ err("\nTest aborted after 10 failures\n\n");
+ }
+ start_connect(c);
+ }
}
printf("Writing request...\n");
/* connected first time */
@@ -692,8 +700,9 @@
static void test(void)
{
- struct timeval timeout, now;
-
+ struct timeval now;
+ time_t timeout;
+ ap_int16_t rv;
int i;
if (!use_html) {
@@ -749,8 +758,10 @@
gettimeofday(&start, 0);
/* initialise lots of requests */
- for (i = 0; i < concurrency; i++)
+ for (i = 0; i < concurrency; i++) {
+ con[i].socknum = i;
start_connect(&con[i]);
+ }
while (done < requests) {
ap_int32_t n;
@@ -761,10 +772,9 @@
requests = done; /* so stats are correct */
}
/* Timeout of 30 seconds. */
- timeout.tv_sec = 30;
- timeout.tv_usec = 0;
+ timeout = 30;
- n = ap_poll(cntxt, readbits, concurrency, &timeout);
+ n = ap_poll(cntxt, readbits, concurrency, timeout);
if (!n) {
err("\nServer timed out\n\n");
@@ -773,16 +783,18 @@
err("select");
for (i = 0; i < concurrency; i++) {
- ap_pollfd_t *s = readbits[con[i].socknum];
- if ( == APR_SUCCESS) {
+ printf("rv == %d\n", rv);
+ rv = ap_get_revents(cntxt, readbits, con[i].socknum);
+ printf("rv == %d\n", rv);
+ if ((rv & APR_POLLERR) || (rv & APR_POLLNVAL) || (rv & APR_POLLHUP)) {
bad++;
err_except++;
start_connect(&con[i]);
continue;
}
- if (ap_sd_isset(s, &sel_read) == APR_SUCCESS)
+ if ((rv & APR_POLLIN) || (rv & APR_POLLPRI))
read_connection(&con[i]);
- if (ap_sd_isset(s, &sel_write) == APR_SUCCESS)
+ if (rv & APR_POLLOUT)
write_request(&con[i]);
}
}
@@ -905,6 +917,8 @@
tablestring = "";
trstring = "";
tdstring = "bgcolor=white";
+
+ cntxt = ap_initialize(NULL);
optind = 1;
while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwx:y:z:")) > 0) {