rbb 99/05/26 10:53:07
Modified: apr/test ab_apr.c
Log:
Bring ab_apr up to date with apr.
Revision Changes Path
1.11 +21 -17 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ab_apr.c 1999/05/24 02:04:10 1.10
+++ ab_apr.c 1999/05/26 17:53:04 1.11
@@ -216,12 +216,14 @@
static void write_request(struct connection *c)
{
+ ap_ssize_t len = reqlen;
gettimeofday(&c->connect, 0);
- if (ap_send(c->aprsock, request, reqlen, 30) != reqlen) {
+ if (ap_send(c->aprsock, request, &reqlen, 30) != APR_SUCCESS &&
+ reqlen != len) {
printf("Send request failed!\n");
}
if (posting) {
- ap_send(c->aprsock, postdata, postlen, 30);
+ ap_send(c->aprsock, postdata, &postlen, 30);
totalposted += (reqlen + postlen);
}
@@ -452,14 +454,14 @@
c->cbx = 0;
c->gotheader = 0;
- if ((c->aprsock = ap_create_tcp_socket(cntxt)) == NULL) {
+ if (ap_create_tcp_socket(cntxt, &c->aprsock) != APR_SUCCESS) {
err("Socket:");
}
- if (ap_setport(c->aprsock, port) == APR_FAILURE) {
+ if (ap_setport(c->aprsock, port) != APR_SUCCESS) {
err("Port:");
}
gettimeofday(&c->start, 0);
- if (ap_connect(c->aprsock, hostname) == APR_FAILURE) {
+ if (ap_connect(c->aprsock, hostname) != APR_SUCCESS) {
if (errno == EINPROGRESS) {
c->state = STATE_CONNECTING;
ap_add_poll_socket(readbits, c->aprsock, APR_POLLOUT,
c->socknum);
@@ -475,7 +477,6 @@
start_connect(c);
}
}
- printf("Writing request...\n");
/* connected first time */
write_request(c);
}
@@ -527,7 +528,8 @@
char *part;
char respcode[4]; /* 3 digits and null */
- r = ap_recv(c->aprsock, buffer, sizeof(buffer), aprtimeout);
+ r = sizeof(buffer);
+ ap_recv(c->aprsock, buffer, &r, aprtimeout);
if (r == 0 || (r < 0 && errno != EAGAIN)) {
good++;
close_connection(c);
@@ -687,7 +689,7 @@
memset(con, 0, concurrency * sizeof(struct connection));
stats = malloc(requests * sizeof(struct data));
- readbits = ap_setup_poll(cntxt, concurrency);
+ ap_setup_poll(cntxt, concurrency, &readbits);
/* setup request */
if (!posting) {
@@ -747,7 +749,8 @@
/* Timeout of 30 seconds. */
timeout = 30;
- n = ap_poll(readbits, concurrency, timeout);
+ n = concurrency;
+ ap_poll(readbits, &n, timeout);
if (!n) {
err("\nServer timed out\n\n");
@@ -756,9 +759,7 @@
err("select");
for (i = 0; i < concurrency; i++) {
- printf("rv == %d\n", rv);
- rv = ap_get_revents(readbits, con[i].socknum);
- printf("rv == %d\n", rv);
+ ap_get_revents(readbits, con[i].socknum, &rv);
if ((rv & APR_POLLERR) || (rv & APR_POLLNVAL) || (rv &
APR_POLLHUP)) {
bad++;
err_except++;
@@ -852,24 +853,27 @@
static int open_postfile(char *pfile)
{
- ap_file_t *postfd;
+ ap_file_t *postfd = NULL;
int status;
ap_fileperms_t mode;
+ ap_ssize_t length;
- if ((postfd = ap_open(cntxt, pfile, APR_READ, mode)) == NULL) {
+ if (ap_open(cntxt, pfile, APR_READ, mode, &postfd) != APR_SUCCESS) {
printf("Invalid postfile name (%s)\n", pfile);
return errno;
}
/* No need to perform stat here, the apr_open will do it for us. */
- postlen = ap_get_filesize(postfd);
+ ap_get_filesize(postfd, &postlen);
postdata = malloc(postlen);
if (!postdata) {
printf("Can\'t alloc postfile buffer\n");
return ENOMEM;
}
- if (ap_read(postfd, postdata, postlen) != postlen) {
+ length = postlen;
+ if (ap_read(postfd, postdata, &length) != APR_SUCCESS &&
+ length != postlen) {
printf("error reading postfilen");
return EIO;
}
@@ -891,7 +895,7 @@
trstring = "";
tdstring = "bgcolor=white";
- cntxt = ap_initialize(NULL);
+ ap_create_context(NULL, NULL, &cntxt);
optind = 1;
while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwx:y:z:")) > 0) {