cvs commit: apache-2.0/src/main buff.c

2000-02-18 Thread stoddard
stoddard00/02/18 10:05:19

  Modified:src/include ap_iol.h
   src/lib/apr aprlib.def
   src/lib/apr/file_io/win32 readwrite.c
   src/lib/apr/include apr_file_io.h
   src/main buff.c
  Log:
  Pass ap_iovec_t on writev calls.
  
  Revision  ChangesPath
  1.10  +1 -1  apache-2.0/src/include/ap_iol.h
  
  Index: ap_iol.h
  ===
  RCS file: /home/cvs/apache-2.0/src/include/ap_iol.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ap_iol.h  2000/01/26 05:56:33 1.9
  +++ ap_iol.h  2000/02/18 18:05:15 1.10
  @@ -106,7 +106,7 @@
   ap_status_t (*close)(ap_iol *fd);
   ap_status_t (*write)(ap_iol *fd, const char *buf, ap_size_t len,
ap_ssize_t *nbytes);
  -ap_status_t (*writev)(ap_iol *fd, const struct iovec *vec, int nvec,
  +ap_status_t (*writev)(ap_iol *fd, const ap_iovec_t *vec, int nvec,
 ap_ssize_t *nbytes);
   ap_status_t (*read)(ap_iol *fd, char *buf, ap_size_t len,
   ap_ssize_t *nbytes);
  
  
  
  1.10  +1 -1  apache-2.0/src/lib/apr/aprlib.def
  
  Index: aprlib.def
  ===
  RCS file: /home/cvs/apache-2.0/src/lib/apr/aprlib.def,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- aprlib.def2000/01/26 05:56:36 1.9
  +++ aprlib.def2000/02/18 18:05:16 1.10
  @@ -20,7 +20,7 @@
   ;ap_get_filesize   @12
   ;ap_get_fileatime   @13
   ;ap_get_filectime   @14
  -;ap_get_filemtime   @15
  + ap_make_iov   @15
ap_dupfile   @16
ap_getfileinfo   @17
ap_open   @18
  
  
  
  1.12  +11 -0 apache-2.0/src/lib/apr/file_io/win32/readwrite.c
  
  Index: readwrite.c
  ===
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- readwrite.c   2000/02/18 02:53:11 1.11
  +++ readwrite.c   2000/02/18 18:05:17 1.12
  @@ -63,6 +63,17 @@
   
   #define GetFilePointer(hfile) SetFilePointer(hfile,0,NULL, FILE_CURRENT)
   
  +ap_status_t ap_make_iov(struct iovec_t **new, const struct iovec *iova, 
ap_context_t *cntxt)
  +{
  +(*new) = ap_palloc(cntxt, sizeof(struct iovec_t));
  +if ((*new) == NULL) {
  +return APR_ENOMEM;
  +}
  +(*new)-cntxt = cntxt;
  +(*new)-theiov = iova;
  +return APR_SUCCESS;
  +}
  +
   ap_status_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
   {
   DWORD bread;
  
  
  
  1.30  +1 -1  apache-2.0/src/lib/apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- apr_file_io.h 2000/02/18 02:53:11 1.29
  +++ apr_file_io.h 2000/02/18 18:05:18 1.30
  @@ -146,7 +146,7 @@
   API_EXPORT(int) ap_fprintf(ap_file_t *fptr, const char *format, ...)
   __attribute__((format(printf,2,3)));
   
  -ap_status_t ap_make_iov(ap_iovec_t **, struct iovec *, ap_context_t *);
  +ap_status_t ap_make_iov(ap_iovec_t **, const struct iovec *, ap_context_t *);
   ap_status_t ap_dupfile(ap_file_t **, ap_file_t *);
   ap_status_t ap_getfileinfo(ap_finfo_t *finfo, ap_file_t *thefile);
   ap_status_t ap_stat(ap_finfo_t *finfo, const char *fname, ap_context_t 
*cont);
  
  
  
  1.30  +3 -2  apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- buff.c2000/01/28 18:00:58 1.29
  +++ buff.c2000/02/18 18:05:19 1.30
  @@ -555,8 +555,9 @@
 int nvec, ap_ssize_t *bytes_written)
   {
   ap_status_t rv;
  -
  -rv = iol_writev(fb-iol, vec, nvec, bytes_written);
  +ap_iovec_t *iov;
  +ap_make_iov(iov, vec, fb-pool);
  +rv = iol_writev(fb-iol, iov, nvec, bytes_written);
   if (rv != APR_SUCCESS) {
fb-saved_errno = rv;
if (rv != APR_EAGAIN) {
  
  
  


cvs commit: apache-2.0/src/main buff.c http_protocol.c

1999-10-31 Thread manoj
manoj   99/10/31 01:13:23

  Modified:src  CHANGES
   src/include buff.h
   src/main buff.c http_protocol.c
  Log:
  Finish removing references to errno from buff, by introducing
  ap_berror() to return the status from calls that don't return an
  ap_status_t.
  
  Revision  ChangesPath
  1.16  +2 -2  apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -d -u -r1.15 -r1.16
  --- CHANGES   1999/10/30 02:06:31 1.15
  +++ CHANGES   1999/10/31 09:13:20 1.16
  @@ -1,7 +1,7 @@
   Changes with Apache 2.0-dev
   
  -  *) Large sections of buff, including the APIs, have been converted to
  - no longer use errno. [Manoj Kasichainula]
  +  *) buff.c has been converted to no longer use errno.
  + [Manoj Kasichainula]
   
 *) mod_speling runs in 2.0-dev now: a bug in readdir_r handling and
interface adaption to APR functions did it. [Martin Kraemer]
  
  
  
  1.11  +6 -0  apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -d -u -r1.10 -r1.11
  --- buff.h1999/10/31 09:02:52 1.10
  +++ buff.h1999/10/31 09:13:21 1.11
  @@ -129,6 +129,11 @@
   struct buff_struct {
   int flags;   /* flags */
   ap_status_t saved_errno; /* saved errno */
  +ap_status_t berrno; /* errno for the functions that don't return
  +   an ap_status_t. This is separate from
  +   saved_errno. A broken call, e.g. ap_bgets
  +   on an unbuffered stream, shouldn't change
  +   the saved error from I/O */
   unsigned char *inptr;/* pointer to next location to read */
   int incnt;   /* number of bytes left to read from 
input buffer;
 * always 0 if had a read error  */
  @@ -180,6 +185,7 @@
   API_EXPORT(void) ap_bonerror(BUFF *fb,
void (*error) (BUFF *, int, void *, 
ap_status_t),
void *data);
  +API_EXPORT(ap_status_t) ap_berror(BUFF *fb);
   
   /* I/O */
   API_EXPORT(ap_status_t) ap_bread(BUFF *fb, void *buf, ap_size_t nbyte,
  
  
  
  1.23  +22 -13apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -d -u -r1.22 -r1.23
  --- buff.c1999/10/31 09:02:53 1.22
  +++ buff.c1999/10/31 09:13:22 1.23
  @@ -55,14 +55,10 @@
*
*/
   
  -/* TODO: Everything involving errno in here is a hack to manage the
  - * transition from errnohood to nonerrnohood - manoj */
  -
   #include httpd.h
   #include http_main.h
   #include http_log.h
   
  -#include errno.h
   #include stdio.h
   #include stdarg.h
   #include string.h
  @@ -210,6 +206,7 @@
}
return iol_setopt(fb-iol, AP_IOL_TIMEOUT, optval);
   }
  +fb-berrno = APR_EINVAL;
   return APR_EINVAL;
   }
   
  @@ -228,6 +225,7 @@
   case BO_TIMEOUT:
return iol_getopt(fb-iol, AP_IOL_TIMEOUT, optval);
   }
  +fb-berrno = APR_EINVAL;
   return APR_EINVAL;
   }
   
  @@ -322,6 +320,7 @@
fb-flags |= B_EOF;
   }
   else if (rv != APR_SUCCESS) {
  + fb-berrno = rv;
fb-saved_errno = rv;
if (rv != APR_EAGAIN) {
doerror(fb, B_RD);
  @@ -447,11 +446,10 @@
   
   /* Can't do bgets on an unbuffered stream */
   if (!(fb-flags  B_RD)) {
  - errno = EINVAL;
  + fb-berrno = APR_EINVAL;
return -1;
   }
   if (fb-flags  B_RDERR) {
  - errno = fb-saved_errno;
return -1;
   }
   
  @@ -466,7 +464,6 @@
break;
rv = read_with_errors(fb, fb-inptr, fb-bufsiz, i);
if (rv != APR_SUCCESS) {
  -errno = rv;
buff[ct] = '\0';
return ct ? ct : -1;
}
  @@ -537,7 +534,6 @@
   if (rv == APR_SUCCESS) {
   return bytes_written;
   }
  -errno = rv;
   return -1;
   }
   
  @@ -552,7 +548,7 @@
   
   rv = ap_bread(fb, buf, 1, i);
   if (rv == APR_SUCCESS  i == 0)
  - errno = 0;  /* no error; EOF */
  +fb-berrno = APR_SUCCESS;   /* no error; EOF */
   if (i != 1)
return EOF;
   else
  @@ -837,6 +833,7 @@
   ap_ssize_t n;   /* Placeholder; not ever used */
   
   if ((fb-flags  (B_EOUT | B_WR)) != B_WR) {
  +fb-berrno = APR_EINVAL;
   return APR_EINVAL;
   }
   

cvs commit: apache-2.0/src/main buff.c

1999-10-26 Thread manoj
manoj   99/10/25 22:24:52

  Modified:src/main buff.c
  Log:
  Fix a Manojly stupid bclose bug.
  
  Revision  ChangesPath
  1.14  +1 -1  apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -d -u -r1.13 -r1.14
  --- buff.c1999/10/25 22:04:05 1.13
  +++ buff.c1999/10/26 05:24:50 1.14
  @@ -834,7 +834,7 @@
rc1 = 0;
   ap_kill_cleanup(fb-pool, fb, bcleanup);
   rc2 = iol_close(fb-iol);
  -if (rc2 != APR_SUCCESS) {
  +if (rc2 == APR_SUCCESS) {
   rc2 = 0;
   }
   else {
  
  
  


cvs commit: apache-2.0/src/main buff.c

1999-10-26 Thread manoj
manoj   99/10/25 23:15:59

  Modified:src/main buff.c
  Log:
  More elimination of errno in buff. Now, everything under ap_bwrite is
  errno-free. ap_bwrite doesn't use errno, excpet for exporting its old
  interface.
  
  Revision  ChangesPath
  1.15  +49 -41apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -d -u -r1.14 -r1.15
  --- buff.c1999/10/26 05:24:50 1.14
  +++ buff.c1999/10/26 06:15:59 1.15
  @@ -606,16 +606,13 @@
   
   /* write the contents of fb-outbase, and buf,
  stop at first partial write for a non-blocking buff
  -
  -   return number of bytes of buf which were written
  -   -1 for errors
   */
  -static int large_write(BUFF *fb, const char *buf, int nbyte)
  +static ap_status_t large_write(BUFF *fb, const char *buf, ap_size_t nbyte,
  +   ap_ssize_t *bytes_written)
   {
   struct iovec vec[2];
   int nvec;
   ap_status_t rv;
  -ap_ssize_t bytes_written;
   
   ap_assert(nbyte  0);
   if (fb-outcnt) {
  @@ -630,64 +627,64 @@
vec[0].iov_len = nbyte;
nvec = 1;
   }
  -rv = writev_it_all(fb, vec, nvec, bytes_written);
  -if (bytes_written == 0) {   /* error or eof */
  -if (rv == APR_SUCCESS) {
  - return 0;
  -}
  -errno = rv;
  -return -1;
  +rv = writev_it_all(fb, vec, nvec, bytes_written);
  +if (*bytes_written == 0) {   /* error or eof */
  +return rv;
   }
  -if (bytes_written  fb-outcnt) {
  +if (*bytes_written  fb-outcnt) {
/* shift bytes forward in buffer */
  - fb-outcnt -= bytes_written;
  - memmove(fb-outbase, fb-outbase + bytes_written, fb-outcnt);
  - return 0;
  + fb-outcnt -= *bytes_written;
  + memmove(fb-outbase, fb-outbase + *bytes_written, fb-outcnt);
  +*bytes_written = 0;
  + return APR_SUCCESS;
   }
  -bytes_written -= fb-outcnt;
  +*bytes_written -= fb-outcnt;
   fb-outcnt = 0;
  -return bytes_written;
  +return APR_SUCCESS;
   }
   
   
  -static int large_write_chunk(BUFF *fb, const char *buf, int nbyte)
  +static ap_status_t large_write_chunk(BUFF *fb, const char *buf, ap_size_t 
nbyte,
  + ap_ssize_t *bytes_written)
   {
  -int rv;
  -int amt;
  -int total;
  +ap_status_t rv;
  +ap_ssize_t total, n, amt;
   
   ap_assert(nbyte  0);
   if (fb-chunk_overcommit) {
amt = nbyte  fb-chunk_overcommit ? fb-chunk_overcommit : nbyte;
  - rv = large_write(fb, buf, amt);
  - if (rv = 0) {
  - return rv;
  + rv = large_write(fb, buf, amt, total);
  + if (total == 0) {   /* error or eof */
  +*bytes_written = total;
  +return rv;
}
  - fb-chunk_overcommit -= rv;
  + fb-chunk_overcommit -= total;
if (fb-chunk_overcommit == 0) {
fb-outbase[0] = '\015';
fb-outbase[1] = '\012';
fb-outcnt = 2;
start_chunk(fb);
}
  - if (rv  amt || amt == nbyte) {
  - return rv;
  + if (total  amt || amt == nbyte) {
  +*bytes_written = total;
  + return APR_SUCCESS;
}
  - nbyte -= rv;
  - buf += rv;
  + nbyte -= total;
  + buf += total;
   }
   ap_assert(fb-chunk_overcommit == 0  fb-outchunk != -1);
   total = 0;
   do {
amt = end_chunk(fb, nbyte);
  - rv = large_write(fb, buf, amt);
  - if (rv  amt) {
  - if (rv  0) {
  - fb-chunk_overcommit = amt;
  - return total ? total : -1;
  - }
  - fb-chunk_overcommit = amt - rv;
  - return total + rv;
  + rv = large_write(fb, buf, amt, n);
  + if (n  amt) {
  + fb-chunk_overcommit = amt - n;
  +*bytes_written = total + n;
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +return rv;
  +#else
  +return *bytes_written ? APR_SUCCESS : rv;
  +#endif
}
fb-outbase[0] = '\015';
fb-outbase[1] = '\012';
  @@ -697,7 +694,8 @@
buf += amt;
total += amt;
   } while (nbyte);
  -return total;
  +*bytes_written = total;
  +return APR_SUCCESS;
   }
   
   /* A wrapper for write which deals with error conditions and
  @@ -777,10 +775,20 @@
*/
   if (!(fb-flags  B_WR)
|| (nbyte  LARGE_WRITE_THRESHOLD  nbyte + fb-outcnt = fb-bufsiz)) 
{
  +ap_status_t rv;
  +ap_ssize_t n;
  +
if (fb-flags  B_CHUNK) {
  - return large_write_chunk(fb, buf, nbyte);
  + rv = large_write_chunk(fb, buf, nbyte, n);
}
  - return large_write(fb, buf, nbyte);
  +else {
  + rv = large_write(fb, buf, nbyte, n);
  +}
  +if (rv 

cvs commit: apache-2.0/src/main buff.c

1999-10-26 Thread manoj
manoj   99/10/26 13:43:52

  Modified:src/main buff.c
  Log:
  Fix some (probably) inconsequential mistakes in ap_bsetopt.
  
  Revision  ChangesPath
  1.16  +2 -2  apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -d -u -r1.15 -r1.16
  --- buff.c1999/10/26 06:15:59 1.15
  +++ buff.c1999/10/26 20:43:46 1.16
  @@ -197,12 +197,12 @@
   ap_register_cleanup(fb-pool, fb, bcleanup, bcleanup);
   }
   
  -API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval)
  +API_EXPORT(ap_status_t) ap_bsetopt(BUFF *fb, int optname, const void *optval)
   {
   switch (optname) {
   case BO_BYTECT:
fb-bytes_sent = *(const long int *) optval - (long int) fb-outcnt;
  - return 0;
  + return APR_SUCCESS;
   
   case BO_TIMEOUT:
fb-flags = ~B_NONBLOCK;
  
  
  


cvs commit: apache-2.0/src/main buff.c http_connection.c http_protocol.c

1999-10-26 Thread manoj
manoj   99/10/26 15:25:03

  Modified:src  CHANGES
   src/main buff.c http_connection.c http_protocol.c
  Log:
  ap_bflush and ap_bclose now return ap_status_t error codes instead of
  returning -1 and setting errno.
  
  Revision  ChangesPath
  1.13  +3 -0  apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -d -u -r1.12 -r1.13
  --- CHANGES   1999/10/23 21:20:15 1.12
  +++ CHANGES   1999/10/26 22:25:00 1.13
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0-dev
   
  +  *) ap_bflush and ap_bclose now return ap_status_t error codes instead
  + of returning -1 and setting errno. [Manoj Kasichainula]
  +
 *) mod_speling runs in 2.0-dev now: a bug in readdir_r handling and
interface adaption to APR functions did it. [Martin Kraemer]
   
  
  
  
  1.17  +36 -37apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -d -u -r1.16 -r1.17
  --- buff.c1999/10/26 20:43:46 1.16
  +++ buff.c1999/10/26 22:25:01 1.17
  @@ -718,32 +718,36 @@
   }
   
   
  -static int bflush_core(BUFF *fb)
  +static ap_status_t bflush_core(BUFF *fb, ap_ssize_t *bytes_written)
   {
  -int total;
  -ap_ssize_t bytes_written;
  +ap_status_t rv;
  +ap_ssize_t n;
   
   if (fb-flags  B_CHUNK) {
end_chunk(fb, 0);
   }
  -total = 0;
  +*bytes_written = 0;
   while (fb-outcnt  0) {
  - (void) write_with_errors(fb, fb-outbase + total, fb-outcnt,
  - bytes_written);
  - if (bytes_written = 0) {   /* error or eof */
  - if (total) {
  - memmove(fb-outbase, fb-outbase + total, fb-outcnt);
  - return total;
  + rv = write_with_errors(fb, fb-outbase + *bytes_written, fb-outcnt,
  + n);
  + if (n = 0) {   /* error or eof */
  + if (*bytes_written) {
  + memmove(fb-outbase, fb-outbase + *bytes_written, fb-outcnt);
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +return rv;
  +#else
  + return APR_SUCCESS;
  +#endif
}
  - return -1;
  + return rv;
}
  - fb-outcnt -= bytes_written;
  - total += bytes_written;
  + fb-outcnt -= n;
  + *bytes_written += n;
   }
   if (fb-flags  B_CHUNK) {
start_chunk(fb);
   }
  -return total;
  +return APR_SUCCESS;
   }
   
   
  @@ -758,6 +762,8 @@
   {
   int amt;
   int total;
  +ap_ssize_t n;
  +ap_status_t rv;
   
   if (fb-flags  (B_WRERR | B_EOUT)) {
errno = fb-saved_errno;
  @@ -775,7 +781,6 @@
*/
   if (!(fb-flags  B_WR)
|| (nbyte  LARGE_WRITE_THRESHOLD  nbyte + fb-outcnt = fb-bufsiz)) 
{
  -ap_status_t rv;
   ap_ssize_t n;
   
if (fb-flags  B_CHUNK) {
  @@ -799,7 +804,8 @@
fb-outcnt += amt;
buf = (const char *) buf + amt;
nbyte -= amt;
  - if (bflush_core(fb)  amt) {
  +(void) bflush_core(fb, n);
  + if (n  amt) {
return amt;
}
total = amt;
  @@ -812,18 +818,18 @@
   
   /*
* Flushes the buffered stream.
  - * Returns 0 on success or -1 on error
*/
  -API_EXPORT(int) ap_bflush(BUFF *fb)
  +API_EXPORT(ap_status_t) ap_bflush(BUFF *fb)
   {
  -int ret;
  -
  -if ((fb-flags  (B_WRERR | B_EOUT | B_WR)) != B_WR)
  - return -1;
  -
  -ret = bflush_core(fb);
  +ap_ssize_t n;   /* Placeholder; not ever used */
   
  -return ret;
  +if ((fb-flags  (B_EOUT | B_WR)) != B_WR) {
  +return APR_EINVAL;
  +}
  +if ((fb-flags  B_WRERR) != 0) {
  +return fb-saved_errno;
  +}
  +return bflush_core(fb, n);
   }
   
   /*
  @@ -832,23 +838,16 @@
* Sets the EOF flag to indicate no futher data can be read,
* and the EOUT flag to indicate no further data can be written.
*/
  -API_EXPORT(int) ap_bclose(BUFF *fb)
  +API_EXPORT(ap_status_t) ap_bclose(BUFF *fb)
   {
  -int rc1, rc2;
  +ap_status_t rc1, rc2;
   
   if (fb-flags  B_WR)
rc1 = ap_bflush(fb);
   else
  - rc1 = 0;
  + rc1 = APR_SUCCESS;
   ap_kill_cleanup(fb-pool, fb, bcleanup);
   rc2 = iol_close(fb-iol);
  -if (rc2 == APR_SUCCESS) {
  -rc2 = 0;
  -}
  -else {
  -errno = rc2;
  -rc2 = -1;
  -}
   
   fb-inptr = fb-inbase;
   fb-incnt = 0;
  @@ -856,7 +855,7 @@
   
   fb-flags |= B_EOF | B_EOUT;
   
  -if (rc1 != 0)
  +if (rc1 != APR_SUCCESS)
return rc1;
   return rc2;
   }
  @@ -921,7 +920,7 @@
   
   fb-outcnt += b-vbuff.curpos - (char 

cvs commit: apache-2.0/src/main buff.c

1999-10-26 Thread manoj
manoj   99/10/26 15:42:51

  Modified:src  CHANGES
   src/include buff.h
   src/main buff.c
  Log:
  Error functions recorded with ap_bonerror now take a status code as an
  argument, so errno isn't needed.
  
  Revision  ChangesPath
  1.14  +3 -1  apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -d -u -r1.13 -r1.14
  --- CHANGES   1999/10/26 22:25:00 1.13
  +++ CHANGES   1999/10/26 22:42:33 1.14
  @@ -1,7 +1,9 @@
   Changes with Apache 2.0-dev
   
 *) ap_bflush and ap_bclose now return ap_status_t error codes instead
  - of returning -1 and setting errno. [Manoj Kasichainula]
  + of returning -1 and setting errno. And error functions recorded
  + with ap_bonerror now take a status code as an argument. [Manoj
  + Kasichainula]
   
 *) mod_speling runs in 2.0-dev now: a bug in readdir_r handling and
interface adaption to APR functions did it. [Martin Kraemer]
  
  
  
  1.5   +5 -4  apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -d -u -r1.4 -r1.5
  --- buff.h1999/10/22 22:08:11 1.4
  +++ buff.h1999/10/26 22:42:41 1.5
  @@ -128,7 +128,7 @@
   
   struct buff_struct {
   int flags;   /* flags */
  -int saved_errno; /* saved errno */
  +ap_status_t saved_errno; /* saved errno */
   unsigned char *inptr;/* pointer to next location to read */
   int incnt;   /* number of bytes left to read from 
input buffer;
 * always 0 if had a read error  */
  @@ -141,7 +141,7 @@
 * keep track of the #remaining bytes in the 
chunk
 * here
 */
  -void (*error) (BUFF *fb, int op, void *data);
  +void (*error) (BUFF *fb, int op, void *data, ap_status_t errnum);
   void *error_data;
   long int bytes_sent; /* number of bytes actually written */
   
  @@ -177,8 +177,9 @@
   #define ap_bgetflag(fb, flag)((fb)-flags  (flag))
   
   /* Error handling */
  -API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *),
  -   void *data);
  +API_EXPORT(void) ap_bonerror(BUFF *fb,
  + void (*error) (BUFF *, int, void *, 
ap_status_t),
  + void *data);
   
   /* I/O */
   API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte);
  
  
  
  1.18  +4 -5  apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -d -u -r1.17 -r1.18
  --- buff.c1999/10/26 22:25:01 1.17
  +++ buff.c1999/10/26 22:42:46 1.18
  @@ -136,11 +136,9 @@
   
   static void doerror(BUFF *fb, int direction)
   {
  -/* TODO: doerror should look at fb-saved_errno instead of errno */
  -errno = fb-saved_errno;
   fb-flags |= (direction == B_RD ? B_RDERR : B_WRERR);
   if (fb-error != NULL)
  - (*fb-error) (fb, direction, fb-error_data);
  + (*fb-error) (fb, direction, fb-error_data, fb-saved_errno);
   }
   
   /* Buffering routines */
  @@ -901,8 +899,9 @@
   return k;
   }
   
  -API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *),
  -   void *data)
  +API_EXPORT(void) ap_bonerror(BUFF *fb,
  + void (*error) (BUFF *, int, void *, 
ap_status_t),
  + void *data)
   {
   fb-error = error;
   fb-error_data = data;
  
  
  


cvs commit: apache-2.0/src/main buff.c

1999-10-25 Thread manoj
manoj   99/10/25 14:12:42

  Modified:src/main buff.c
  Log:
  The first layer of buff changes to abandon errno. Now .*_with_errors and
  doerror are errno independant, but export the old errno-using interface.
  
  Revision  ChangesPath
  1.12  +54 -49apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -d -u -r1.11 -r1.12
  --- buff.c1999/10/24 19:23:57 1.11
  +++ buff.c1999/10/25 21:12:34 1.12
  @@ -136,13 +136,11 @@
   
   static void doerror(BUFF *fb, int direction)
   {
  -int errsave = errno; /* Save errno to prevent overwriting it below */
  -
  +/* TODO: doerror should look at fb-saved_errno instead of errno */
  +errno = fb-saved_errno;
   fb-flags |= (direction == B_RD ? B_RDERR : B_WRERR);
   if (fb-error != NULL)
(*fb-error) (fb, direction, fb-error_data);
  -
  -errno = errsave;
   }
   
   /* Buffering routines */
  @@ -316,24 +314,22 @@
   
   
   /* a wrapper around iol_read which checks for errors and EOFs */
  -static int read_with_errors(BUFF *fb, void *buf, int nbyte)
  +static ap_status_t read_with_errors(BUFF *fb, void *buf, ap_size_t nbyte,
  +ap_ssize_t *bytes_read)
   {
  -int rv;
  -ap_ssize_t bytes_read;
  +ap_status_t rv;
   
  -rv = iol_read(fb-iol, buf, nbyte, bytes_read);
  -if (rv == APR_SUCCESS  bytes_read == 0) {
  +rv = iol_read(fb-iol, buf, nbyte, bytes_read);
  +if (rv == APR_SUCCESS  *bytes_read == 0) {
fb-flags |= B_EOF;
   }
   else if (rv != APR_SUCCESS) {
  -errno = rv;
fb-saved_errno = rv;
if (rv != APR_EAGAIN) {
doerror(fb, B_RD);
}
  -return -1;
   }
  -return bytes_read;
  +return rv;
   }
   
   
  @@ -345,6 +341,7 @@
   API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte)
   {
   int i, nrd;
  +ap_status_t rv;
   
   if (fb-flags  B_RDERR) {
errno = fb-saved_errno;
  @@ -363,7 +360,12 @@
fb-inptr += i;
return i;
}
  - return read_with_errors(fb, buf, nbyte);
  + rv = read_with_errors(fb, buf, nbyte, i);
  +if (rv == APR_SUCCESS) {
  +return i;
  +}
  +errno = rv;
  +return -1;
   }
   
   nrd = fb-incnt;
  @@ -387,16 +389,18 @@
   /* do a single read */
   if (nbyte = fb-bufsiz) {
   /* read directly into caller's buffer */
  - i = read_with_errors(fb, buf, nbyte);
  - if (i == -1) {
  + rv = read_with_errors(fb, buf, nbyte, i);
  + if (rv != APR_SUCCESS) {
  +errno = rv;
return nrd ? nrd : -1;
}
   }
   else {
   /* read into hold buffer, then memcpy */
fb-inptr = fb-inbase;
  - i = read_with_errors(fb, fb-inptr, fb-bufsiz);
  - if (i == -1) {
  + rv = read_with_errors(fb, fb-inptr, fb-bufsiz, i);
  + if (rv != APR_SUCCESS) {
  +errno = rv;
return nrd ? nrd : -1;
}
fb-incnt = i;
  @@ -431,6 +435,7 @@
   API_EXPORT(int) ap_bgets(char *buff, int n, BUFF *fb)
   {
   int i, ch, ct;
  +ap_status_t rv;
   
   /* Can't do bgets on an unbuffered stream */
   if (!(fb-flags  B_RD)) {
  @@ -451,8 +456,9 @@
fb-incnt = 0;
if (fb-flags  B_EOF)
break;
  - i = read_with_errors(fb, fb-inptr, fb-bufsiz);
  - if (i == -1) {
  + rv = read_with_errors(fb, fb-inptr, fb-bufsiz, i);
  + if (rv != APR_SUCCESS) {
  +errno = rv;
buff[ct] = '\0';
return ct ? ct : -1;
}
  @@ -540,51 +546,51 @@
   /* A wrapper for writev which deals with error conditions and
* bytes_sent.
*/
  -static int writev_with_errors(BUFF *fb, const struct iovec *vec, int nvec)
  +static ap_status_t writev_with_errors(BUFF *fb, const struct iovec *vec,
  +  int nvec, ap_ssize_t *bytes_written)
   {
  -int rv;
  -ap_ssize_t bytes_written;
  +ap_status_t rv;
   
  -rv = iol_writev(fb-iol, vec, nvec, bytes_written);
  +rv = iol_writev(fb-iol, vec, nvec, bytes_written);
   if (rv != APR_SUCCESS) {
  -errno = rv;
fb-saved_errno = rv;
if (rv != APR_EAGAIN) {
doerror(fb, B_WR);
}
  - return -1;
   }
  -fb-bytes_sent += bytes_written;
  -return bytes_written;
  +fb-bytes_sent += *bytes_written;
  +return rv;
   }
   
   
   static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec)
   {
   int i;
  -int rv;
  +ap_status_t rv;
  +ap_ssize_t bytes_written;
   int total;
   
   i = 0;
   total = 0;
   while (i  nvec) {
  - rv = writev_with_errors(fb, vec + i, nvec - i);
  - if (rv 

cvs commit: apache-2.0/src/main buff.c

1999-10-25 Thread manoj
manoj   99/10/25 15:04:08

  Modified:src/main buff.c
  Log:
  large_write now doesn't use errno internally, but exports an errnoish
  interface.
  
  Revision  ChangesPath
  1.13  +34 -24apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -d -u -r1.12 -r1.13
  --- buff.c1999/10/25 21:12:34 1.12
  +++ buff.c1999/10/25 22:04:05 1.13
  @@ -563,39 +563,44 @@
   }
   
   
  -static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec)
  +static ap_status_t writev_it_all(BUFF *fb, struct iovec *vec, int nvec,
  + ap_ssize_t *bytes_written)
   {
   int i;
   ap_status_t rv;
  -ap_ssize_t bytes_written;
  -int total;
  +ap_ssize_t n;
   
   i = 0;
  -total = 0;
  +*bytes_written = 0;
   while (i  nvec) {
  - rv = writev_with_errors(fb, vec + i, nvec - i, bytes_written);
  + rv = writev_with_errors(fb, vec + i, nvec - i, n);
if (rv != APR_SUCCESS) {
  -errno = rv;
  - return total ? total : -1;
  +/* XXX - When we decide which way to go here, the ifdef will do away. the 
macro
  + * is undefined by default */
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +return rv;
  +#else
  +return *bytes_written ? APR_SUCCESS : rv;
  +#endif
}
  - total += bytes_written;
  + *bytes_written += n;
if (fb-flags  B_NONBLOCK) {
  - return total;
  + return APR_SUCCESS;
}
/* recalculate to deal with partial writes */
  - while (bytes_written  0) {
  -if (bytes_written  vec[i].iov_len) {
  -vec[i].iov_base = (char *) vec[i].iov_base + bytes_written;
  -vec[i].iov_len -= bytes_written;
  + while (n  0) {
  +if (n  vec[i].iov_len) {
  +vec[i].iov_base = (char *) vec[i].iov_base + n;
  +vec[i].iov_len -= n;
   break;
   }
   else {
  -bytes_written -= vec[i].iov_len;
  +n -= vec[i].iov_len;
   ++i;
   }
   }
   }
  -return total;
  +return APR_SUCCESS;
   }
   
   
  @@ -609,7 +614,8 @@
   {
   struct iovec vec[2];
   int nvec;
  -int rv;
  +ap_status_t rv;
  +ap_ssize_t bytes_written;
   
   ap_assert(nbyte  0);
   if (fb-outcnt) {
  @@ -624,19 +630,23 @@
vec[0].iov_len = nbyte;
nvec = 1;
   }
  -rv = writev_it_all(fb, vec, nvec);
  -if (rv = 0) {
  - return rv;
  +rv = writev_it_all(fb, vec, nvec, bytes_written);
  +if (bytes_written == 0) {   /* error or eof */
  +if (rv == APR_SUCCESS) {
  + return 0;
  +}
  +errno = rv;
  +return -1;
   }
  -if (rv  fb-outcnt) {
  +if (bytes_written  fb-outcnt) {
/* shift bytes forward in buffer */
  - memmove(fb-outbase, fb-outbase + rv, fb-outcnt - rv);
  - fb-outcnt -= rv;
  + fb-outcnt -= bytes_written;
  + memmove(fb-outbase, fb-outbase + bytes_written, fb-outcnt);
return 0;
   }
  -rv -= fb-outcnt;
  +bytes_written -= fb-outcnt;
   fb-outcnt = 0;
  -return rv;
  +return bytes_written;
   }
   
   
  
  
  


cvs commit: apache-2.0/src/main buff.c

1999-10-22 Thread manoj
manoj   99/10/22 15:08:18

  Modified:src/include buff.h
   src/main buff.c
  Log:
  Change ap_bgetopt and ap_bsetopt to use APR-style return codes instead
  of errno. There's no effect on other Apache code since nothing actually
  checks return values on these functions.
  
  Revision  ChangesPath
  1.4   +2 -2  apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -d -u -r1.3 -r1.4
  --- buff.h1999/08/31 05:32:17 1.3
  +++ buff.h1999/10/22 22:08:11 1.4
  @@ -169,8 +169,8 @@
   /* XXX - unused right now - mvsk */
   API_EXPORT(BUFF *) ap_bopenf(ap_context_t *a, const char *name, int flg, int 
mode);
   
  -API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval);
  -API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval);
  +API_EXPORT(ap_status_t) ap_bsetopt(BUFF *fb, int optname, const void 
*optval);
  +API_EXPORT(ap_status_t) ap_bgetopt(BUFF *fb, int optname, void *optval);
   API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value);
   API_EXPORT(int) ap_bclose(BUFF *fb);
   
  
  
  
  1.10  +6 -21 apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -d -u -r1.9 -r1.10
  --- buff.c1999/10/21 19:00:18 1.9
  +++ buff.c1999/10/22 22:08:15 1.10
  @@ -201,8 +201,6 @@
   
   API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval)
   {
  -int rv;
  -
   switch (optname) {
   case BO_BYTECT:
fb-bytes_sent = *(const long int *) optval - (long int) fb-outcnt;
  @@ -214,21 +212,14 @@
fb-flags |= B_NONBLOCK;
/* XXX: should remove B_WR now... */
}
  - rv = iol_setopt(fb-iol, AP_IOL_TIMEOUT, optval);
  -if (rv == APR_SUCCESS) {
  -return 0;
  -}
  -errno = rv;
  -return -1;
  + return iol_setopt(fb-iol, AP_IOL_TIMEOUT, optval);
   }
  -errno = EINVAL;
  -return -1;
  +return APR_EINVAL;
   }
   
  -API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval)
  +API_EXPORT(ap_status_t) ap_bgetopt(BUFF *fb, int optname, void *optval)
   {
   long int bs;
  -int rv;
   
   switch (optname) {
   case BO_BYTECT:
  @@ -236,18 +227,12 @@
if (bs  0L)
bs = 0L;
*(long int *) optval = bs;
  - return 0;
  + return APR_SUCCESS;
   
   case BO_TIMEOUT:
  - rv = iol_getopt(fb-iol, AP_IOL_TIMEOUT, optval);
  -if (rv == APR_SUCCESS) {
  -return 0;
  -}
  -errno = rv;
  -return -1;
  + return iol_getopt(fb-iol, AP_IOL_TIMEOUT, optval);
   }
  -errno = EINVAL;
  -return -1;
  +return APR_EINVAL;
   }
   
   static void start_chunk(BUFF *fb)
  
  
  


cvs commit: apache-2.0/src/main buff.c

1999-10-21 Thread manoj
manoj   99/10/21 12:00:20

  Modified:src/main buff.c
  Log:
  Fix an swap in the ?: operator's arguments in writev_it_all.
  
  Revision  ChangesPath
  1.9   +1 -1  apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -d -u -r1.8 -r1.9
  --- buff.c1999/10/20 19:35:24 1.8
  +++ buff.c1999/10/21 19:00:18 1.9
  @@ -583,7 +583,7 @@
   while (i  nvec) {
rv = writev_with_errors(fb, vec + i, nvec - i);
if (rv  0) {
  - return total ? -1 : total;
  + return total ? total : -1;
}
total += rv;
if (fb-flags  B_NONBLOCK) {