You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Dean Gaudet <dg...@hyperreal.com> on 1997/06/30 22:28:55 UTC

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 <do...@opengroup.org>
  
  Revision  Changes    Path
  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.c	1997/06/29 19:27:20	1.32
  --- buff.c	1997/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 -C3 -r1.14 -r1.15
  *** buff.h	1997/06/16 19:32:50	1.14
  --- buff.h	1997/06/30 20:28:50	1.15
  ***************
  *** 50,55 ****
  --- 50,59 ----
     *
     */
    
  + #ifdef B_SFIO
  + #include "sfio.h"
  + #endif
  + 
    #include <stdarg.h>
    
    /* Reading is buffered */
  ***************
  *** 96,102 ****
  --- 100,120 ----
    /* could also put pointers to the basic I/O routines here */
        int fd;                /* the file descriptor */
        int fd_in;             /* input file descriptor, if different */
  + 
  + #ifdef B_SFIO
  +     Sfio_t   *sf_in;
  +     Sfio_t   *sf_out;
  + #endif
    };
  + 
  + #ifdef B_SFIO
  + typedef struct {
  +     Sfdisc_t disc;
  +     BUFF *buff;
  + } apache_sfio;
  + 
  + extern Sfdisc_t *bsfio_new(pool *p, BUFF *b);
  + #endif
    
    /* Options to bset/getopt */
    #define BO_BYTECT (1)
  
  
  
  1.171     +19 -1     apache/src/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_main.c,v
  retrieving revision 1.170
  retrieving revision 1.171
  diff -C3 -r1.170 -r1.171
  *** http_main.c	1997/06/29 19:27:21	1.170
  --- http_main.c	1997/06/30 20:28:51	1.171
  ***************
  *** 2172,2177 ****
  --- 2172,2188 ----
    	                          (request_rec*)NULL);
    
    	conn_io = bcreate(ptrans, B_RDWR | B_SOCKET);
  + 
  + #ifdef B_SFIO
  + 	(void)sfdisc(conn_io->sf_in, SF_POPDISC);
  + 	sfdisc(conn_io->sf_in, bsfio_new(conn_io->pool, conn_io));
  + 	sfsetbuf(conn_io->sf_in, NULL, 0);
  + 
  + 	(void)sfdisc(conn_io->sf_out, SF_POPDISC);
  + 	sfdisc(conn_io->sf_out, bsfio_new(conn_io->pool, conn_io));
  + 	sfsetbuf(conn_io->sf_out, NULL, 0);
  + #endif
  + 	
    	dupped_csd = csd;
    #if defined(NEED_DUPPED_CSD)
    	if ((dupped_csd = dup(csd)) < 0) {
  ***************
  *** 2315,2320 ****
  --- 2326,2334 ----
     * Executive routines.
     */
    
  + #ifndef STANDALONE_MAIN
  + #define STANDALONE_MAIN standalone_main
  + 
    void standalone_main(int argc, char **argv)
    {
        int remaining_children_to_start;
  ***************
  *** 2512,2517 ****
  --- 2526,2535 ----
        } while (restart_pending);
    
    } /* standalone_main */
  + #else
  + /* prototype */
  + void STANDALONE_MAIN(int argc, char **argv);
  + #endif /* STANDALONE_MAIN */
    
    extern char *optarg;
    extern int optind;
  ***************
  *** 2585,2591 ****
        
        if(standalone) {
            clear_pool (pconf);	/* standalone_main rereads... */
  !         standalone_main(argc, argv);
        }
        else {
            conn_rec *conn;
  --- 2603,2609 ----
        
        if(standalone) {
            clear_pool (pconf);	/* standalone_main rereads... */
  !         STANDALONE_MAIN(argc, argv);
        }
        else {
            conn_rec *conn;