cvs commit: apache/src buff.c
dgaudet 98/01/26 22:25:05 Modified:src Tag: APACHE_1_2_X buff.c Log: This is the proper fix for chunked encoding and bputc()... the last one misses cases where bputc() is mixed with other bwrite() calls. Revision ChangesPath No revision No revision 1.26.2.3 +12 -9 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.26.2.2 retrieving revision 1.26.2.3 diff -u -r1.26.2.2 -r1.26.2.3 --- buff.c1998/01/14 00:02:56 1.26.2.2 +++ buff.c1998/01/27 06:25:02 1.26.2.3 @@ -187,7 +187,13 @@ } /* - * start chunked encoding + * Start chunked encoding. + * + * Note that in order for bputc() to be an efficient macro we have to + * guarantee that start_chunk() has always been called on the buffer before we + * leave any routine in this file. Said another way, if a routine here uses + * end_chunk() and writes something on the wire, then it has to call + * start_chunk() or set an error condition before returning. */ static void start_chunk( BUFF *fb ) @@ -584,16 +590,9 @@ bflsbuf(int c, BUFF *fb) { char ss[1]; -int rc; ss[0] = c; -rc = bwrite(fb, ss, 1); -/* We do start_chunk() here so that the bputc macro can be smaller - * and faster - */ -if (rc == 1 (fb-flags B_CHUNK)) - start_chunk(fb); -return rc; +return bwrite(fb, ss, 1); } /* @@ -913,6 +912,10 @@ if (fb-flags B_EOUT) return -1; } + +if (fb-flags B_CHUNK) + start_chunk(fb); + return 0; }
cvs commit: apache/src buff.c
dgaudet 97/07/31 02:10:30 Modified:src buff.c Log: Improve the heuristic for deciding when to use writev() vs. when to copy into the buffer. No sense copying if the copy would fill the buffer, might as well writev and start a fresh buffer. Revision ChangesPath 1.40 +1 -1 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- buff.c1997/07/29 06:52:26 1.39 +++ buff.c1997/07/31 09:10:29 1.40 @@ -1005,7 +1005,7 @@ * Detect case where we're asked to write a large buffer, and combine our * current buffer with it in a single writev() */ -if (fb-outcnt 0 nbyte = fb-bufsiz) { +if (fb-outcnt 0 nbyte + fb-outcnt = fb-bufsiz) { return large_write (fb, buf, nbyte); } #endif
cvs commit: apache/src buff.c buff.h http_main.c
dgaudet 97/06/30 13:28:54 Modified:src buff.c buff.h http_main.c Log: Allow for replacing standalone_main. Allow the use of sfio in buff.c. Submitted by: Doug MacEachern [EMAIL PROTECTED] Revision ChangesPath 1.33 +67 -5 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C3 -r1.32 -r1.33 *** buff.c1997/06/29 19:27:20 1.32 --- buff.c1997/06/30 20:28:50 1.33 *** *** 200,206 { int rv; ! #ifdef WIN32 if (fb-flags B_SOCKET) { rv = recvwithtimeout( fb-fd_in, buf, nbyte, 0 ); if (rv == SOCKET_ERROR) --- 200,206 { int rv; ! #if defined (WIN32) if (fb-flags B_SOCKET) { rv = recvwithtimeout( fb-fd_in, buf, nbyte, 0 ); if (rv == SOCKET_ERROR) *** *** 218,224 { int rv; ! #ifdef WIN32 if (fb-flags B_SOCKET) { rv = sendwithtimeout( fb-fd, buf, nbyte, 0); if (rv == SOCKET_ERROR) --- 218,224 { int rv; ! #if defined(WIN32) if (fb-flags B_SOCKET) { rv = sendwithtimeout( fb-fd, buf, nbyte, 0); if (rv == SOCKET_ERROR) *** *** 226,233 } else rv = write( fb-fd, buf, nbyte ); #else ! rv = write( fb-fd, buf, nbyte ); #endif /* WIN32 */ return rv; } --- 226,235 } else rv = write( fb-fd, buf, nbyte ); + #elif defined (B_SFIO) + i = sfwrite(fb-sf_out, buf, nbyte); #else ! rv = write(fb-fd, buf, nbyte); #endif /* WIN32 */ return rv; } *** *** 279,284 --- 281,295 fb-fd = -1; fb-fd_in = -1; + #ifdef B_SFIO + fb-sf_in = NULL; + fb-sf_out = NULL; + fb-sf_in = sfnew(fb-sf_in, NIL(Void_t*), +(size_t)SF_UNBOUND, 0, SF_READ); + fb-sf_out = sfnew(fb-sf_out, NIL(Void_t*), +(size_t)SF_UNBOUND, 1, SF_WRITE); + #endif + return fb; } *** *** 426,440 return value; } - /* * This is called instead of read() everywhere in here. It implements * the B_SAFEREAD functionality -- which is to force a flush() if a read() * would block. It also deals with the EINTR errno result from read(). * return code is like read() except EINTR is eliminated. */ static int ! saferead( BUFF *fb, void *buf, int nbyte ) { int rv; --- 437,462 return value; } /* * This is called instead of read() everywhere in here. It implements * the B_SAFEREAD functionality -- which is to force a flush() if a read() * would block. It also deals with the EINTR errno result from read(). * return code is like read() except EINTR is eliminated. */ + + + #if !defined (B_SFIO) || defined (WIN32) + #define saferead saferead_guts + #else static int ! saferead(BUFF *fb, char *buf, int nbyte) ! { ! return sfread(fb-sf_in, buf, nbyte); ! } ! #endif ! ! static int ! saferead_guts(BUFF *fb, void *buf, int nbyte) { int rv; *** *** 461,466 --- 483,523 return( rv ); } + #ifdef B_SFIO + int bsfio_read(Sfio_t *f, char *buf, int nbyte, apache_sfio *disc) + { + int rv; + BUFF *fb = disc-buff; + + rv = saferead_guts(fb, buf, nbyte); + + buf[rv] = '\0'; + f-next = 0; + + return(rv); + } + + int bsfio_write(Sfio_t *f, char *buf, int nbyte, apache_sfio *disc) + { + return write(disc-buff-fd, buf, nbyte); + } + + Sfdisc_t *bsfio_new(pool *p, BUFF *b) + { + apache_sfio* disc; + + if(!(disc = (apache_sfio*)palloc(p, sizeof(apache_sfio))) ) + return (Sfdisc_t *)disc; + + disc-disc.readf = (Sfread_f)bsfio_read; + disc-disc.writef = (Sfwrite_f)bsfio_write; + disc-disc.seekf = (Sfseek_f)NULL; + disc-disc.exceptf = (Sfexcept_f)NULL; + disc-buff = b; + + return (Sfdisc_t *)disc; + } + #endif /* * Read up to nbyte bytes into buf. *** *** 1069,1074 --- 1126,1136 fb-flags |= B_EOF | B_EOUT; fb-fd = -1; fb-fd_in = -1; + + #ifdef B_SFIO + sfclose(fb-sf_in); + sfclose(fb-sf_out); + #endif if (rc1 != 0) return rc1; else if (rc2 != 0) return rc2; 1.15 +18 -0 apache/src/buff.h Index: buff.h === RCS file: /export/home/cvs/apache/src/buff.h,v retrieving revision 1.14 retrieving revision 1.15 diff
cvs commit: apache/src buff.c conf.h
dgaudet 97/06/30 14:03:19 Modified:src buff.c conf.h Log: I want to be able to use inline, especially for some of the cleanups where we're factoring out common code. Revision ChangesPath 1.34 +0 -6 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C3 -r1.33 -r1.34 *** buff.c1997/06/30 20:28:50 1.33 --- buff.c1997/06/30 21:03:16 1.34 *** *** 190,201 #endif /* WIN32 */ - - /* these are wrappers to make code below more readable */ - #if !defined (__GNUC__) - #define inline - #endif - static inline int buff_read (BUFF *fb, void *buf, int nbyte) { int rv; --- 190,195 1.108 +5 -0 apache/src/conf.h Index: conf.h === RCS file: /export/home/cvs/apache/src/conf.h,v retrieving revision 1.107 retrieving revision 1.108 diff -C3 -r1.107 -r1.108 *** conf.h1997/06/29 19:27:20 1.107 --- conf.h1997/06/30 21:03:17 1.108 *** *** 738,743 --- 738,748 #define ap_select select #endif + /* so that we can use inline on some critical functions */ + #if !defined(__GNUC__) + #define inline + #endif + /* Finding offsets of elements within structures. * Taken from the X code... they've sweated portability of this stuff * so we don't have to. Sigh...
cvs commit: apache/src buff.c
dgaudet 97/06/30 14:16:18 Modified:src buff.c Log: Oops I made a tiny goofup when merging the sfio changes. Revision ChangesPath 1.35 +1 -1 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C3 -r1.34 -r1.35 *** buff.c1997/06/30 21:03:16 1.34 --- buff.c1997/06/30 21:16:17 1.35 *** *** 221,227 else rv = write( fb-fd, buf, nbyte ); #elif defined (B_SFIO) ! i = sfwrite(fb-sf_out, buf, nbyte); #else rv = write(fb-fd, buf, nbyte); #endif /* WIN32 */ --- 221,227 else rv = write( fb-fd, buf, nbyte ); #elif defined (B_SFIO) ! rv = sfwrite(fb-sf_out, buf, nbyte); #else rv = write(fb-fd, buf, nbyte); #endif /* WIN32 */
cvs commit: apache/src buff.c
dgaudet 97/06/16 12:45:13 Modified:src buff.c Log: A tiny bit more cleanup. Also check B_SOCKET when closing the fds. Revision ChangesPath 1.29 +24 -11apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C3 -r1.28 -r1.29 *** buff.c1997/06/16 19:32:49 1.28 --- buff.c1997/06/16 19:45:12 1.29 *** *** 759,766 while (nbyte 0) { i = buff_write( fb, buf, nbyte ); ! if( i 0 ) { ! if( errno != EAGAIN errno != EINTR ) { return -1; } } --- 759,766 while (nbyte 0) { i = buff_write( fb, buf, nbyte ); ! if (i 0) { ! if (errno != EAGAIN errno != EINTR) { return -1; } } *** *** 785,803 bcwrite(BUFF *fb, const void *buf, int nbyte) { char chunksize[16]; /* Big enough for practically anything */ - int i; #ifndef NO_WRITEV struct iovec vec[3]; ! int rv; #endif if (fb-flags (B_WRERR|B_EOUT)) return -1; ! if (!(fb-flags B_CHUNK)) ! { ! i = buff_write(fb, buf, nbyte); ! return(i); } #ifdef NO_WRITEV --- 785,800 bcwrite(BUFF *fb, const void *buf, int nbyte) { char chunksize[16]; /* Big enough for practically anything */ #ifndef NO_WRITEV struct iovec vec[3]; ! int i, rv; #endif if (fb-flags (B_WRERR|B_EOUT)) return -1; ! if (!(fb-flags B_CHUNK)) { ! return buff_write(fb, buf, nbyte); } #ifdef NO_WRITEV *** *** 1050,1058 if (fb-flags B_WR) rc1 = bflush(fb); else rc1 = 0; ! rc2 = closesocket(fb-fd); ! if (fb-fd_in != fb-fd) rc3 = closesocket(fb-fd_in); ! else rc3 = 0; fb-inptr = fb-inbase; fb-incnt = 0; --- 1047,1071 if (fb-flags B_WR) rc1 = bflush(fb); else rc1 = 0; ! #ifdef WIN32 ! if (fb-flags B_SOCKET) { ! rc2 = closesocket(fb-fd); ! if (fb-fd_in != fb-fd) { ! rc3 = closesocket(fb-fd_in); ! } else { ! rc3 = 0; ! } ! } else { ! #endif ! rc2 = close(fb-fd); ! if (fb-fd_in != fb-fd) { ! rc3 = close(fb-fd_in); ! } else { ! rc3 = 0; ! } ! #ifdef WIN32 ! } ! #endif fb-inptr = fb-inbase; fb-incnt = 0;
cvs commit: apache/src buff.c
fielding97/05/28 22:21:16 Modified:src buff.c Log: saferead must stop reading if the buffer has been marked in error (i.e., a timeout has occurred). Necessary for proxy timeouts. Submitted by: Petr Lampa Reviewed by: Roy Fielding Revision ChangesPath 1.26 +1 -1 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C3 -r1.25 -r1.26 *** buff.c1997/04/27 06:23:21 1.25 --- buff.c1997/05/29 05:21:15 1.26 *** *** 325,331 } do { rv = read( fb-fd_in, buf, nbyte ); ! } while ( rv == -1 errno == EINTR ); return( rv ); } --- 325,331 } do { rv = read( fb-fd_in, buf, nbyte ); ! } while (rv == -1 errno == EINTR !(fb-flags B_EOUT)); return( rv ); }
cvs commit: apache/src buff.c
ben 97/02/21 09:12:49 Modified:src buff.c Log: Don't note -ve fds for cleanup. Reviewed by: Randy, Chuck, Marc Revision ChangesPath 1.21 +3 -2 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C3 -r1.20 -r1.21 *** buff.c1997/02/17 11:05:01 1.20 --- buff.c1997/02/21 17:12:49 1.21 *** *** 149,156 { fb-fd = fd_out; fb-fd_in = fd_in; ! note_cleanups_for_fd(fb-pool,fb-fd); ! if(fb-fd != fb-fd_in) note_cleanups_for_fd(fb-pool,fb-fd_in); } --- 149,157 { fb-fd = fd_out; fb-fd_in = fd_in; ! if(fb-fd = 0) ! note_cleanups_for_fd(fb-pool,fb-fd); ! if(fb-fd != fb-fd_in fb-fd_in = 0) note_cleanups_for_fd(fb-pool,fb-fd_in); }
cvs commit: apache/src buff.c conf.h http_main.c
marc97/02/17 03:05:03 Modified:src buff.c conf.h http_main.c Log: Add bstring.h include for IRIX; FD_ZERO uses bzero, which is prototyped in bstring.h. Don't use killpg(); part of the IRIX -D_BSD_COMPAT functionality, and since the rest of apache doesn't use -D_BSD_COMPAT it probably shouldn't use killpg(). Note that HAVE_BSTRING_H may not be the best name for the define. Reviewed by: Marc Slemko, Jim Jagielski Submitted by: Dean Gaudet Revision ChangesPath 1.20 +4 -0 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C3 -r1.19 -r1.20 *** buff.c1997/02/15 18:34:27 1.19 --- buff.c1997/02/17 11:05:01 1.20 *** *** 65,70 --- 65,74 #include alloc.h #include buff.h + #ifdef HAVE_BSTRING_H + #include bstring.h/* for IRIX, FD_SET calls bzero() */ + #endif + #define DEFAULT_BUFSIZE (4096) /* 1.79 +4 -1 apache/src/conf.h Index: conf.h === RCS file: /export/home/cvs/apache/src/conf.h,v retrieving revision 1.78 retrieving revision 1.79 diff -C3 -r1.78 -r1.79 *** conf.h1997/02/10 21:22:20 1.78 --- conf.h1997/02/17 11:05:01 1.79 *** *** 102,114 #elif defined(IRIX) #undef HAVE_GMTOFF ! #undef NO_KILLPG #undef NO_SETSID #define JMP_BUF sigjmp_buf #define USE_FCNTL_SERIALIZED_ACCEPT #define HAVE_SHMGET #define HAVE_CRYPT_H #define NO_LONG_DOUBLE #elif defined(HIUX) #define HAVE_SYS_RESOURCE_H --- 102,117 #elif defined(IRIX) #undef HAVE_GMTOFF ! /* IRIX has killpg, but it's only in _BSD_COMPAT, so don't use it in case ! * there's some weird conflict with non-BSD signals */ ! #define NO_KILLPG #undef NO_SETSID #define JMP_BUF sigjmp_buf #define USE_FCNTL_SERIALIZED_ACCEPT #define HAVE_SHMGET #define HAVE_CRYPT_H #define NO_LONG_DOUBLE + #define HAVE_BSTRING_H #elif defined(HIUX) #define HAVE_SYS_RESOURCE_H 1.122 +4 -0 apache/src/http_main.c Index: http_main.c === RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.121 retrieving revision 1.122 diff -C3 -r1.121 -r1.122 *** http_main.c 1997/02/16 23:32:32 1.121 --- http_main.c 1997/02/17 11:05:02 1.122 *** *** 100,105 --- 100,109 #endif #include netinet/tcp.h + #ifdef HAVE_BSTRING_H + #include bstring.h/* for IRIX, FD_SET calls bzero() */ + #endif + #include explain.h #if !defined(max)
cvs commit: apache/src buff.c
ben 97/02/15 10:34:28 Modified:src buff.c Log: Fix warning. Revision ChangesPath 1.19 +2 -1 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C3 -r1.18 -r1.19 *** buff.c1997/02/10 21:22:19 1.18 --- buff.c1997/02/15 18:34:27 1.19 *** *** 239,245 } /* we know this will fit because of how we wrote it in start_chunk() */ ! i = ap_snprintf( fb-outbase[fb-outchunk], fb-outchunk_header_size, %x, fb-outcnt - fb-outchunk - fb-outchunk_header_size ); /* we may have to tack some trailing spaces onto the number we just wrote --- 239,246 } /* we know this will fit because of how we wrote it in start_chunk() */ ! i = ap_snprintf( (char *)fb-outbase[fb-outchunk], ! fb-outchunk_header_size, %x, fb-outcnt - fb-outchunk - fb-outchunk_header_size ); /* we may have to tack some trailing spaces onto the number we just wrote
cvs commit: apache/src buff.c
jim 97/01/13 16:18:47 Modified:src buff.c Log: NEXTSTEP 2.0 doesn't have unistd.h Revision ChangesPath 1.12 +2 -0 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C3 -r1.11 -r1.12 *** buff.c1997/01/01 18:10:14 1.11 --- buff.c1997/01/14 00:18:45 1.12 *** *** 54,60 --- 54,62 #include stdio.h #include stdarg.h #include string.h + #ifndef NEXT #include unistd.h + #endif #include conf.h #include alloc.h
cvs commit: apache/src buff.c mod_rewrite.c mod_rewrite.h
chuck 96/12/09 14:39:22 Modified:src buff.c mod_rewrite.c mod_rewrite.h Log: Reviewed by: Brian Behlendorf, Chuck Murcko Submitted by: Marc Evans [EMAIL PROTECTED] patches for DEC AXP running OSF/1 v3.0. Revision ChangesPath 1.10 +1 -1 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C3 -r1.9 -r1.10 *** buff.c1996/11/10 09:16:10 1.9 --- buff.c1996/12/09 22:39:18 1.10 *** *** 419,425 for (;;) { ! x = memchr(fb-inptr, '\012', fb-incnt); if (x != NULL) { x++; --- 419,425 for (;;) { ! x = (unsigned char *)memchr(fb-inptr, '\012', fb-incnt); if (x != NULL) { x++; 1.9 +26 -26apache/src/mod_rewrite.c Index: mod_rewrite.c === RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C3 -r1.8 -r1.9 *** mod_rewrite.c 1996/11/14 07:24:43 1.8 --- mod_rewrite.c 1996/12/09 22:39:19 1.9 *** *** 163,194 ** */ - /* the main config structure */ - module rewrite_module = { -STANDARD_MODULE_STUFF, - -init_module, /* module initializer */ - -config_perdir_create,/* create per-dirconfig structures */ -config_perdir_merge, /* merge per-dirconfig structures */ -config_server_create,/* create per-server config structures */ -config_server_merge, /* merge per-server config structures */ -command_table, /* table of config file commands */ - -handler_table, /* [#7] table of MIME-typed-dispatched request action handlers */ - -hook_uri2file, /* [#1] URI to filename translation */ - -NULL,/* [#3] check_user_id: get and validate user id from the HTTP request */ -NULL,/* [#4] check_auth:check if the user is ok _here_ */ -NULL,/* [#2] check_access: check access by host address, etc. */ - -hook_mimetype, /* [#5] determine MIME type */ - -hook_fixup, /* [#6] pre-run fixups */ -NULL /* [#8] log a transaction */ - }; - /* the table of commands we provide */ static command_rec command_table[] = { { RewriteEngine, cmd_rewriteengine, NULL, OR_FILEINFO, FLAG, --- 163,168 *** *** 214,219 --- 188,219 static handler_rec handler_table[] = { { redirect-handler, handler_redirect }, { NULL } + }; + + /* the main config structure */ + module rewrite_module = { +STANDARD_MODULE_STUFF, + +init_module, /* module initializer */ + +config_perdir_create,/* create per-dirconfig structures */ +config_perdir_merge, /* merge per-dirconfig structures */ +config_server_create,/* create per-server config structures */ +config_server_merge, /* merge per-server config structures */ +command_table, /* table of config file commands */ + +handler_table, /* [#7] table of MIME-typed-dispatched request action handlers */ + +hook_uri2file, /* [#1] URI to filename translation */ + +NULL,/* [#3] check_user_id: get and validate user id from the HTTP request */ +NULL,/* [#4] check_auth:check if the user is ok _here_ */ +NULL,/* [#2] check_access: check access by host address, etc. */ + +hook_mimetype, /* [#5] determine MIME type */ + +hook_fixup, /* [#6] pre-run fixups */ +NULL /* [#8] log a transaction */ }; /* the common cache */ 1.11 +0 -2 apache/src/mod_rewrite.h Index: mod_rewrite.h === RCS file: /export/home/cvs/apache/src/mod_rewrite.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C3 -r1.10 -r1.11 *** mod_rewrite.h 1996/11/20 19:55:06 1.10 --- mod_rewrite.h 1996/12/09 22:39:20 1.11 *** *** 280,287 /* static config */ extern module rewrite_module; - static command_rec command_table[]; - static handler_rec handler_table[]; extern cache *cachep; /* config structure handling */ --- 280,285
cvs commit: apache/src buff.c buff.h http_config.h http_core.c http_protocol.c http_protocol.h http_request.c httpd.h mod_actions.c mod_alias.c mod_cgi.c mod_include.c mod_negotiation.c mod_proxy.c util.c
akosut 96/07/28 12:27:58 Modified:src buff.c buff.h http_config.h http_core.c http_protocol.c http_protocol.h http_request.c httpd.h mod_actions.c mod_alias.c mod_cgi.c mod_include.c mod_negotiation.c mod_proxy.c util.c Log: Make Apache unconditionally compliant with all HTTP/1.1 features and requirements, as of draft -06. Revision ChangesPath 1.5 +40 -4 apache/src/buff.c Index: buff.c === RCS file: /export/home/cvs/apache/src/buff.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C3 -r1.4 -r1.5 *** buff.c1996/07/25 19:32:26 1.4 --- buff.c1996/07/28 19:27:41 1.5 *** *** 1,3 --- 1,4 + /* * Copyright (c) 1996 The Apache Group. All rights reserved. * *** *** 173,178 --- 174,193 } /* + * Set a flag on (1) or off (0). Currently, these flags work + * as a function of the bcwrite() function, so we make sure to + * flush before setting them one way or the other; otherwise + * writes could end up with the wrong flag. + */ + int bsetflag(BUFF *fb, int flag, int value) + { + bflush(fb); + if (value) fb-flags |= flag; + else fb-flags = ~flag; + return value; + } + + /* * Read up to nbyte bytes into buf. * If fewer than byte bytes are currently available, then return those. * Returns 0 for EOF, -1 for error. *** *** 410,415 --- 425,451 } /* + * A hook to write() that deals with chunking. This is really a protocol- + * level issue, but we deal with it here because it's simpler; this is + * an interim solution pending a complete rewrite of all this stuff in + * 2.0, using something like sfio stacked disciplines or BSD's funopen(). + */ + int bcwrite(BUFF *fb, const void *buf, int nbyte) { + int r; + + if (fb-flags B_CHUNK) { + char chunksize[16]; /* Big enough for practically anything */ + + sprintf(chunksize, %x\015\012, nbyte); + write(fb-fd, chunksize, strlen(chunksize)); + } + r = write(fb-fd, buf, nbyte); + if ((r 0) (fb-flags B_CHUNK)) + write(fb-fd, \015\012, 2); + return r; + } + + /* * Write nbyte bytes. * Only returns fewer than nbyte if an error ocurred. * Returns -1 if no bytes were written before the error ocurred. *** *** 425,431 if (!(fb-flags B_WR)) { /* unbuffered write */ ! do i = write(fb-fd, buf, nbyte); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) --- 461,467 if (!(fb-flags B_WR)) { /* unbuffered write */ ! do i = bcwrite(fb, buf, nbyte); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) *** *** 458,464 } /* the buffer must be full */ ! do i = write(fb-fd, fb-outbase, fb-bufsiz); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) --- 494,500 } /* the buffer must be full */ ! do i = bcwrite(fb, fb-outbase, fb-bufsiz); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) *** *** 494,500 */ while (nbyte fb-bufsiz) { ! do i = write(fb-fd, buf, nbyte); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) --- 530,536 */ while (nbyte fb-bufsiz) { ! do i = bcwrite(fb, buf, nbyte); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) *** *** 540,546 { /* the buffer must be full */ j = fb-outcnt; ! do i = write(fb-fd, fb-outbase, fb-outcnt); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) --- 576,582 { /* the buffer must be full */ j = fb-outcnt; ! do i = bcwrite(fb, fb-outbase, fb-outcnt); while (i == -1 errno == EINTR); if (i 0) fb-bytes_sent += i; if (i == 0) 1.5 +5 -0 apache/src/buff.h Index: buff.h === RCS file: /export/home/cvs/apache/src/buff.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C3 -r1.4 -r1.5 *** buff.h1996/05/27 21:08:27 1.4 --- buff.h1996/07/28 19:27:42 1.5 *** *** 66,71 --- 66,73 /* A write error has occurred */ #define B_WRERR (32) #define B_ERROR (48)