summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2000-04-16 16:59:39 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2000-04-16 16:59:39 +0000
commita6d253d4e37650dee64192247f24d7ddb68888b7 (patch)
tree432707f2d6c9ec82808aa99a723495708970a476 /test
parent5fe3c759a295e20e1dfd3cddcec90f8f1e082307 (diff)
downloadlibapr-a6d253d4e37650dee64192247f24d7ddb68888b7.tar.gz
APR_SO_TIMEOUT now takes microseconds instead of seconds. (The new
CHANGES text also reflects prior work on ap_poll() and ap_set_pipe_timeout()). apr/test/client.c now has a crude command-line mechanism for selecting a read timeout. Included bug fixes: 1) Some storage leaks were removed in BeOS and Unix select() usage. 2) For Win32, the code to process APR_SO_TIMEOUT stored timeout in milliseconds but the code to timeout a TransmitFile() in ap_sendfile() assumed that it had been stored in seconds. 3) ab_apr.c used a 30,000-second timeout in one place. This was changed to a 30-second timeout. 4) fix bad perldoc comment in apr_network_io.h which hid the ap_shutdown() prototype 5) disable stdout buffering in apr/test/client.c so that messages appear in the correct order when an error occurs git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59870 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/ab_apr.c4
-rw-r--r--test/client.c35
2 files changed, 29 insertions, 10 deletions
diff --git a/test/ab_apr.c b/test/ab_apr.c
index 7d36bbca4..f61773675 100644
--- a/test/ab_apr.c
+++ b/test/ab_apr.c
@@ -160,7 +160,7 @@ char *postdata; /* *buffer containing data from postfile */
ap_ssize_t postlen = 0; /* length of data to be POSTed */
char content_type[1024]; /* content type to put in POST header */
int port = 80; /* port number */
-time_t aprtimeout = 30000; /* timeout value... */
+time_t aprtimeout = 30 * AP_USEC_PER_SEC; /* timeout value... */
int use_html = 0; /* use html in the report */
char *tablestring;
@@ -218,7 +218,7 @@ static void write_request(struct connection *c)
{
ap_ssize_t len = reqlen;
c->connect = ap_now();
- ap_setsocketopt(c->aprsock, APR_SO_TIMEOUT, 30);
+ ap_setsocketopt(c->aprsock, APR_SO_TIMEOUT, 30 * AP_USEC_PER_SEC);
if (ap_send(c->aprsock, request, &reqlen) != APR_SUCCESS &&
reqlen != len) {
printf("Send request failed!\n");
diff --git a/test/client.c b/test/client.c
index dfc2c80d1..cd78ce111 100644
--- a/test/client.c
+++ b/test/client.c
@@ -71,11 +71,17 @@ int main(int argc, char *argv[])
char *local_ipaddr, *remote_ipaddr;
char *dest = "127.0.0.1";
ap_uint32_t local_port, remote_port;
+ ap_interval_time_t read_timeout = -1;
+ setbuf(stdout, NULL);
if (argc > 1) {
dest = argv[1];
}
+ if (argc > 2) {
+ read_timeout = AP_USEC_PER_SEC * atoi(argv[2]);
+ }
+
fprintf(stdout, "Initializing.........");
if (ap_initialize() != APR_SUCCESS) {
fprintf(stderr, "Something went wrong\n");
@@ -98,13 +104,15 @@ int main(int argc, char *argv[])
}
fprintf(stdout, "OK\n");
- fprintf(stdout, "\tClient: Setting socket option NONBLOCK.......");
- if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) {
- ap_close_socket(sock);
- fprintf(stderr, "Couldn't set socket option\n");
- exit(-1);
+ if (read_timeout == -1) {
+ fprintf(stdout, "\tClient: Setting socket option NONBLOCK.......");
+ if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) {
+ ap_close_socket(sock);
+ fprintf(stderr, "Couldn't set socket option\n");
+ exit(-1);
+ }
+ fprintf(stdout, "OK\n");
}
- fprintf(stdout, "OK\n");
fprintf(stdout, "\tClient: Setting port for socket.......");
if (ap_set_remote_port(sock, 8021) != APR_SUCCESS) {
@@ -143,11 +151,22 @@ int main(int argc, char *argv[])
}
fprintf(stdout, "OK\n");
+ if (read_timeout != -1) {
+ fprintf(stdout, "\tClient: Setting read timeout.......");
+ stat = ap_setsocketopt(sock, APR_SO_TIMEOUT, read_timeout);
+ if (stat) {
+ fprintf(stderr, "Problem setting timeout: %d\n", stat);
+ exit(-1);
+ }
+ fprintf(stdout, "OK\n");
+ }
+
length = STRLEN;
fprintf(stdout, "\tClient: Trying to receive data over socket.......");
- if (ap_recv(sock, datarecv, &length) != APR_SUCCESS) {
+
+ if ((stat = ap_recv(sock, datarecv, &length)) != APR_SUCCESS) {
ap_close_socket(sock);
- fprintf(stderr, "Problem receiving data\n");
+ fprintf(stderr, "Problem receiving data: %d\n", stat);
exit(-1);
}
if (strcmp(datarecv, "Recv data test")) {