David,

Could you (or someone else) who is on a legitimate platform which does
not support writev() check if this is functional ?

Note that I also found I had to make the #ifdef/#if defined()s to make
things comply across the board.

I've tried both with and without SSL and with/without WRITEV on bsd and
solaris - but obviously 'faking' the four permutations.

Cheers,

Dw

Index: ab.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/ab.c,v
retrieving revision 1.63
diff -c -3 -r1.63 ab.c
*** ab.c        1 May 2002 17:02:20 -0000       1.63
--- ab.c        2 May 2002 10:33:09 -0000
***************
*** 114,120 ****
    *           configure --your-other-options
    */

-
  #define VERSION "1.3d"

  /* -------------------------------------------------------------------- */
--- 114,119 ----
***************
*** 161,167 ****
  #endif                                /* NO_APACHE_INCLUDES */

  #ifdef        USE_SSL
! #if ((!(RSAREF)) && (!(SYSSSL)))
  /* Libraries on most systems.. */
  #include <openssl/rsa.h>
  #include <openssl/crypto.h>
--- 160,166 ----
  #endif                                /* NO_APACHE_INCLUDES */

  #ifdef        USE_SSL
! #if ((!defined(RSAREF)) && (!defined(SYSSSL)))
  /* Libraries on most systems.. */
  #include <openssl/rsa.h>
  #include <openssl/crypto.h>
***************
*** 312,319 ****
  #endif

  static void close_connection(struct connection * c);
! #if NO_WRITEV || USE_SSL
! static void s_write(struct connection * c, char *buff, int len);
  #endif

  /* --------------------------------------------------------- */
--- 311,318 ----
  #endif

  static void close_connection(struct connection * c);
! #if (defined(NO_WRITEV) || defined(USE_SSL))
! static int s_write(struct connection * c, char *buff, int len);
  #endif

  /* --------------------------------------------------------- */
***************
*** 343,354 ****
  /* XXX this sucks - SSL mode and writev() do not mix
   *     another artificial difference.
   */
! #if !NO_WRITEV && !USE_SSL
      struct iovec out[2];
!     int outcnt = 1, snd = 0;
  #endif
      gettimeofday(&c->connect, 0);
! #if !NO_WRITEV && !USE_SSL
      out[0].iov_base = request;
      out[0].iov_len = reqlen;

--- 342,354 ----
  /* XXX this sucks - SSL mode and writev() do not mix
   *     another artificial difference.
   */
! #if ((!(defined(NO_WRITEV))) && (!(defined(USE_SSL))))
      struct iovec out[2];
!     int outcnt = 1;
  #endif
+     int snd = 0;
      gettimeofday(&c->connect, 0);
! #if ((!(defined(NO_WRITEV))) && (!(defined(USE_SSL))))
      out[0].iov_base = request;
      out[0].iov_len = reqlen;

***************
*** 387,400 ****

  /*  Do actual data writing */

! #if NO_WRITEV || USE_SSL
! static void s_write(struct connection * c, char *buff, int len)
  {
      do {
        int n;
! #if USE_SSL
        if (ssl) {
!           n = SSL_write(c->ssl, buff, len);
            if (n < 0) {
                int e = SSL_get_error(c->ssl, n);
                /* XXXX propably wrong !!! */
--- 388,402 ----

  /*  Do actual data writing */

! #if ((defined(NO_WRITEV)) || (defined(USE_SSL)))
! static int s_write(struct connection * c, char *buff, int len)
  {
+     int left = len;
      do {
        int n;
! #ifdef USE_SSL
        if (ssl) {
!           n = SSL_write(c->ssl, buff, left);
            if (n < 0) {
                int e = SSL_get_error(c->ssl, n);
                /* XXXX propably wrong !!! */
***************
*** 406,412 ****
        }
        else
  #endif
!           n = ab_write(c->fd, buff, len);

        if (n < 0) {
            switch (errno) {
--- 408,414 ----
        }
        else
  #endif
!           n = ab_write(c->fd, buff, left);

        if (n < 0) {
            switch (errno) {
***************
*** 416,424 ****
                /* We've tried to write to a broken pipe. */
                epipe++;
                close_connection(c);
!               return;
            default:
! #if USE_SSL
                if (ssl) {
                        fprintf(stderr,"Error writing: ");
                        ERR_print_errors_fp(stderr);
--- 418,426 ----
                /* We've tried to write to a broken pipe. */
                epipe++;
                close_connection(c);
!               return len - left;
            default:
! #ifdef USE_SSL
                if (ssl) {
                        fprintf(stderr,"Error writing: ");
                        ERR_print_errors_fp(stderr);
***************
*** 430,440 ****
        }
        else if (n) {
            if (verbosity >= 3)
!               printf(" --> write(%x) %d (%d)\n", (unsigned char) buff[0], n, len);
            buff += n;
!           len -= n;
        };
!     } while (len > 0);
  }
  #endif

--- 432,444 ----
        }
        else if (n) {
            if (verbosity >= 3)
!               printf(" --> write(%x) %d (%d)\n", (unsigned char) buff[0], n, left);
            buff += n;
!           left -= n;
        };
!     } while (left > 0);
!
!     return len-left;
  }
  #endif

***************
*** 879,885 ****
        goto _bad;
      };

! #if USE_SSL
      /*
       * XXXX move nonblocker - so that measnurement needs to have its OWN
       * state engine OR cannot be compared to http.
--- 883,889 ----
        goto _bad;
      };

! #ifdef USE_SSL
      /*
       * XXXX move nonblocker - so that measnurement needs to have its OWN
       * state engine OR cannot be compared to http.
***************
*** 926,932 ****
            fprintf(stderr, "SSL connection OK: %s\n", SSL_get_cipher(c->ssl));
      }
  #endif
! #if USE_SSL
      if (ssl)
        nonblock(c->fd);
  #endif
--- 930,936 ----
            fprintf(stderr, "SSL connection OK: %s\n", SSL_get_cipher(c->ssl));
      }
  #endif
! #ifdef USE_SSL
      if (ssl)
        nonblock(c->fd);
  #endif
***************
*** 1001,1007 ****
      char respcode[4];         /* 3 digits and null */

      gettimeofday(&c->beginread, 0);
! #if USE_SSL
      if (ssl) {
        r = SSL_read(c->ssl, buffer, sizeof(buffer));
        /* XXX fundamwentally worng .. */
--- 1005,1011 ----
      char respcode[4];         /* 3 digits and null */

      gettimeofday(&c->beginread, 0);
! #ifdef USE_SSL
      if (ssl) {
        r = SSL_read(c->ssl, buffer, sizeof(buffer));
        /* XXX fundamwentally worng .. */
***************
*** 1364,1370 ****
  static void usage(char *progname)
  {
      fprintf(stderr, "Usage: %s [options] [http"
! #if USE_SSL
            "[s]"
  #endif
            "://]hostname[:port]/path\n", progname);
--- 1368,1374 ----
  static void usage(char *progname)
  {
      fprintf(stderr, "Usage: %s [options] [http"
! #ifdef USE_SSL
            "[s]"
  #endif
            "://]hostname[:port]/path\n", progname);
***************
*** 1394,1400 ****
      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
      fprintf(stderr, "    -s              Use httpS instead of HTTP (SSL)\n");
  #endif
      fprintf(stderr, "    -h              Display usage information (this 
message)\n");
--- 1398,1404 ----
      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");
! #ifdef USE_SSL
      fprintf(stderr, "    -s              Use httpS instead of HTTP (SSL)\n");
  #endif
      fprintf(stderr, "    -h              Display usage information (this 
message)\n");
***************
*** 1414,1420 ****
      if (strlen(purl) > 7 && strncmp(purl, "http://";, 7) == 0)
        purl += 7;
      else
! #if USE_SSL
      if (strlen(purl) > 8 && strncmp(purl, "https://";, 8) == 0) {
        purl += 8;
        ssl = 1;
--- 1418,1424 ----
      if (strlen(purl) > 7 && strncmp(purl, "http://";, 7) == 0)
        purl += 7;
      else
! #ifdef USE_SSL
      if (strlen(purl) > 8 && strncmp(purl, "https://";, 8) == 0) {
        purl += 8;
        ssl = 1;
***************
*** 1442,1448 ****
        port = atoi(p);

      if ((
! #if USE_SSL
        (ssl != 0) && (port != 443)) || ((ssl == 0) &&
  #endif
        (port != 80)))
--- 1446,1452 ----
        port = atoi(p);

      if ((
! #ifdef USE_SSL
        (ssl != 0) && (port != 443)) || ((ssl == 0) &&
  #endif
        (port != 80)))
***************
*** 1504,1515 ****
      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
                       "s"
  #endif
                       )) > 0) {
        switch (c) {
! #if USE_SSL
        case 's':
            ssl = 1;
            break;
--- 1508,1519 ----
      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"
! #ifdef USE_SSL
                       "s"
  #endif
                       )) > 0) {
        switch (c) {
! #ifdef USE_SSL
        case 's':
            ssl = 1;
            break;


Reply via email to