martin 99/10/27 15:38:56
Modified: src/support ab.c Log: Backport of the BEOS additions for the apache 2.0 branch Revision Changes Path 1.36 +21 -6 apache-1.3/src/support/ab.c Index: ab.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/support/ab.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- ab.c 1999/10/27 22:30:16 1.35 +++ ab.c 1999/10/27 22:38:53 1.36 @@ -224,6 +224,16 @@ fd_set readbits, writebits; /* bits for select */ struct sockaddr_in server; /* server addr structure */ +#ifndef BEOS +#define ab_close(s) close(s) +#define ab_read(a,b,c) read(a,b,c) +#define ab_write(a,b,c) write(a,b,c) +#else +#define ab_close(s) closesocket(s) +#define ab_read(a,b,c) recv(a,b,c,0) +#define ab_write(a,b,c) send(a,b,c,0) +#endif + /* --------------------------------------------------------- */ /* simple little function to perror and exit */ @@ -262,9 +272,9 @@ } writev(c->fd,out, outcnt); #else - write(c->fd,request,reqlen); + ab_write(c->fd,request,reqlen); if (posting>0) { - write(c->fd,postdata,postlen); + ab_write(c->fd,postdata,postlen); totalposted += (reqlen + postlen); } #endif @@ -281,7 +291,11 @@ static void nonblock(int fd) { int i = 1; +#ifdef BEOS + setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &i, sizeof(i)); +#else ioctl(fd, FIONBIO, &i); +#endif } /* --------------------------------------------------------- */ @@ -526,7 +540,7 @@ return; } else { - close(c->fd); + ab_close(c->fd); err_conn++; if (bad++ > 10) { err("\nTest aborted after 10 failures\n\n"); @@ -571,7 +585,7 @@ } } - close(c->fd); + ab_close(c->fd); FD_CLR(c->fd, &readbits); FD_CLR(c->fd, &writebits); @@ -589,8 +603,9 @@ int r; char *part; char respcode[4]; /* 3 digits and null */ + + r = ab_read(c->fd, buffer, sizeof(buffer)); - r = read(c->fd, buffer, sizeof(buffer)); if (r == 0 || (r < 0 && errno != EAGAIN)) { good++; close_connection(c); @@ -636,7 +651,7 @@ return; else { /* header is in invalid or too big - close connection */ - close(c->fd); + ab_close(c->fd); if (bad++ > 10) { err("\nTest aborted after 10 failures\n\n"); } @@ -867,14 +882,14 @@ static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.35 $> apache-1.3"); + printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.36 $> apache-1.3"); printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/\n"); printf("\n"); } else { printf("<p>\n"); - printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n", VERSION, "$Revision: 1.35 $"); + printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n", VERSION, "$Revision: 1.36 $"); printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n"); printf(" Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/<br>\n"); printf("</p>\n<p>\n");