Re: Fixing NO_WRIVEV

2002-05-02 Thread David Reid

Will do in a while :)

david

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 02, 2002 11:36 AM
Subject: Fixing NO_WRIVEV


>
> 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 - 1.63
> --- ab.c 2 May 2002 10:33:09 -
> ***
> *** 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 
>   #include 
> --- 160,166 
>   #endif /* NO_APACHE_INCLUDES */
>
>   #ifdef USE_SSL
> ! #if ((!defined(RSAREF)) && (!defined(SYSSSL)))
>   /* Libraries on most systems.. */
>   #include 
>   #include 
> ***
> *** 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);
>   /*  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);
>   /*  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) {

Fixing NO_WRIVEV

2002-05-02 Thread dirkx


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.c1 May 2002 17:02:20 -   1.63
--- ab.c2 May 2002 10:33:09 -
***
*** 114,120 
*   configure --your-other-options
*/

-
  #define VERSION "1.3d"

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

  #ifdefUSE_SSL
! #if ((!(RSAREF)) && (!(SYSSSL)))
  /* Libraries on most systems.. */
  #include 
  #include 
--- 160,166 
  #endif/* NO_APACHE_INCLUDES */

  #ifdefUSE_SSL
! #if ((!defined(RSAREF)) && (!defined(SYSSSL)))
  /* Libraries on most systems.. */
  #include 
  #include 
***
*** 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);
/*  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);
/*  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