#endif /* NO_APACHE_INCLUDES */
#ifdef USE_SSL
-#if ((!(RSAREF)) && (!(SYSSSL)))
+#if ((!(RSAREF)) && (!defined(SYSSSL)))
/* Libraries on most systems.. */
#include <openssl/rsa.h>
#include <openssl/crypto.h>
#endif
static void close_connection(struct connection * c);
-#if NO_WRITEV || USE_SSL
-static void s_write(struct connection * c, char *buff, int len);
+#if (defined(NO_WRITEV) || defined(USE_SSL))
+#define USE_S_WRITE
+static int s_write(struct connection * c, char *buff, int len);
#endif
/* --------------------------------------------------------- */
/* XXX this sucks - SSL mode and writev() do not mix
* another artificial difference.
*/
-#if !NO_WRITEV && !USE_SSL
+#ifndef USE_S_WRITE
struct iovec out[2];
- int outcnt = 1, snd = 0;
+ int outcnt = 1;
#endif
+ int snd = 0;
gettimeofday(&c->connect, 0);
-#if !NO_WRITEV && !USE_SSL
+#ifndef USE_S_WRITE
out[0].iov_base = request;
out[0].iov_len = reqlen;
#else
snd = s_write(c, request, reqlen);
if (posting > 0) {
- snd += s_write(c, postdata, postlen);
- totalposted += (reqlen + postlen);
+ snd += s_write(c, postdata, postlen);
+ totalposted += (reqlen + postlen);
}
#endif
if (snd < 0) {
/* Do actual data writing */
-#if NO_WRITEV || USE_SSL
-static void s_write(struct connection * c, char *buff, int len)
+#ifdef USE_S_WRITE
+static int s_write(struct connection * c, char *buff, int len)
{
+ int left = len;
do {
int n;
-#if USE_SSL
+#ifdef USE_SSL
if (ssl) {
- n = SSL_write(c->ssl, buff, len);
+ n = SSL_write(c->ssl, buff, left);
if (n < 0) {
int e = SSL_get_error(c->ssl, n);
- /* XXXX propably wrong !!! */
+ /* XXXX probably wrong !!! */
if ((e != SSL_ERROR_WANT_READ) && (e != SSL_ERROR_WANT_WRITE))
n = -1;
else
}
else
#endif
- n = ab_write(c->fd, buff, len);
+ n = ab_write(c->fd, buff, left);
if (n < 0) {
switch (errno) {
/* We've tried to write to a broken pipe. */
epipe++;
close_connection(c);
- return;
+ return len-left;
default:
-#if USE_SSL
+#ifdef USE_SSL
if (ssl) {
fprintf(stderr,"Error writing: ");
ERR_print_errors_fp(stderr);
}
else if (n) {
if (verbosity >= 3)
- printf(" --> write(%x) %d (%d)\n", (unsigned char) buff[0], n, len);
+ printf(" --> write(%x) %d (%d)\n", (unsigned char) buff[0], n, left);
buff += n;
- len -= n;
+ left -= n;
};
- } while (len > 0);
+ } while (left > 0);
+
+ return len - left;
}
#endif
/*
* XXX: what is better; this hideous cast of the copare function; or
* the four warnings during compile ? dirkx just does not know and
- * hates both/
+ * hates both
*/
qsort(stats, requests, sizeof(struct data),
(int (*) (const void *, const void *)) compradre);
goto _bad;
};
-#if USE_SSL
+#ifdef USE_SSL
/*
- * XXXX move nonblocker - so that measnurement needs to have its OWN
+ * XXX move nonblocker - so that measnurement needs to have its OWN
* state engine OR cannot be compared to http.
*/
if (!ssl)
c->state = STATE_CONNECTING;
#ifdef USE_SSL
- /* XX no proper freeing in error's */
+ /* XXX no proper freeing in error's */
/*
- * XXXX no proper choise of completely new connection or one which reuses
+ * XXX no proper choise of completely new connection or one which reuses
* (older) session keys. Fundamentally unrealistic.
*/
if (ssl) {
fprintf(stderr, "SSL connection OK: %s\n", SSL_get_cipher(c->ssl));
}
#endif
-#if USE_SSL
+#ifdef USE_SSL
if (ssl)
nonblock(c->fd);
#endif
char respcode[4]; /* 3 digits and null */
gettimeofday(&c->beginread, 0);
-#if USE_SSL
+#ifdef USE_SSL
if (ssl) {
r = SSL_read(c->ssl, buffer, sizeof(buffer));
- /* XXX fundamwentally worng .. */
+ /* XXX fundamentally worng .. */
if (r < 0 && SSL_get_error(c->ssl, r) == SSL_ERROR_WANT_READ) {
r = -1;
errno = EAGAIN;
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.63 $> apache-1.3");
+ printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.64 $> apache-1.3");
printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
printf("Copyright (c) 1998-2002 The Apache Software Foundation, 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.63 $");
+ printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n", VERSION, "$Revision: 1.64 $");
printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");
static void usage(char *progname)
{
fprintf(stderr, "Usage: %s [options] [http"
-#if USE_SSL
+#ifdef USE_SSL
"[s]"
#endif
"://]hostname[:port]/path\n", progname);
fprintf(stderr, " -S Do not show confidence estimators and warnings.\n");
fprintf(stderr, " -g filename Output collected data to gnuplot format file.\n");
fprintf(stderr, " -e filename Output CSV file with percentages served\n");
-#if USE_SSL
+#ifdef USE_SSL
fprintf(stderr, " -s Use httpS instead of HTTP (SSL)\n");
#endif
fprintf(stderr, " -h Display usage information (this message)\n");
if (strlen(purl) > 7 && strncmp(purl, "http://", 7) == 0)
purl += 7;
else
-#if USE_SSL
+#ifdef USE_SSL
if (strlen(purl) > 8 && strncmp(purl, "https://", 8) == 0) {
purl += 8;
ssl = 1;
port = atoi(p);
if ((
-#if USE_SSL
+#ifdef USE_SSL
(ssl != 0) && (port != 443)) || ((ssl == 0) &&
#endif
(port != 80)))
proxyhost[0] = '\0';
optind = 1;
while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:g:X:de:Sq"
-#if USE_SSL
+#ifdef USE_SSL
"s"
#endif
)) > 0) {
switch (c) {
-#if USE_SSL
+#ifdef USE_SSL
case 's':
ssl = 1;
break;