httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@opengroup.org>
Subject Re: Apache and DCE
Date Mon, 30 Jun 1997 19:51:52 GMT
Randy Terbush <randy@zyzzyva.com> wrote:

> 
> Doug/Dean,
> 
> In this section of the patch below, saferead() is returning the 
> requested number of bytes to be read, not the actual return of 
> sfread().

argh, I forgot about that.  sfwrite will keep trying to get _all_ of
nbyte, which normally won't happen, so we hang.  Now I see setting
f->next = 0; stops it from trying harder than we want.  New patch
below against 1.2.0, I can send in one against the latest from-cvs if 
you'd rather, just let me know.  

-Doug

*** ./buff.c.orig	Thu May 29 01:21:15 1997
--- ./buff.c	Mon Jun 30 15:42:23 1997
***************
*** 143,148 ****
--- 143,157 ----
      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;
  }
  
***************
*** 290,296 ****
      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()
--- 299,304 ----
***************
*** 297,305 ****
   * 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;
  
      if( fb->flags & B_SAFEREAD ) {
--- 305,325 ----
   * would block.  It also deals with the EINTR errno result from read().
   * return code is like read() except EINTR is eliminated.
   */
+ 
+ 
+ #ifdef B_SFIO
  static int
! saferead(BUFF *fb, char *buf, int nbyte)
  {
+     return sfread(fb->sf_in, buf, nbyte);
+ }
+ #else
+ #define saferead __bsaferead
+ #endif
+ 
+ static int
+ __bsaferead(BUFF *fb, void *buf, int nbyte)
+ {
      int rv;
  
      if( fb->flags & B_SAFEREAD ) {
***************
*** 329,335 ****
--- 349,390 ----
      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 = __bsaferead(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.
   * If fewer than byte bytes are currently available, then return those.
***************
*** 621,627 ****
--- 676,686 ----
  	return -1;
  
      while (nbyte > 0) {
+ #ifdef B_SFIO
+ 	i = sfwrite(fb->sf_out, buf, nbyte);
+ #else
  	i = write(fb->fd, buf, nbyte);
+ #endif
  	if (i < 0) {
  	    if (errno != EAGAIN && errno != EINTR) {
  		return -1;
***************
*** 657,664 ****
  	return -1;
  
      if (!(fb->flags & B_CHUNK))
  	return write(fb->fd, buf, nbyte);
! 
  #ifdef NO_WRITEV
      /* without writev() this has poor performance, too bad */
  
--- 716,726 ----
  	return -1;
  
      if (!(fb->flags & B_CHUNK))
+ #ifdef B_SFIO
+ 	return sfwrite(fb->sf_out, buf, nbyte);
+ #else
  	return write(fb->fd, buf, nbyte);
! #endif
  #ifdef NO_WRITEV
      /* without writev() this has poor performance, too bad */
  
***************
*** 780,786 ****
--- 842,852 ----
  	            -1 : fb->outcnt;
  	}
  	else {
+ #ifdef B_SFIO	    
+ 	    do i = sfwrite(fb->sf_out, fb->outbase, fb->outcnt);
+ #else
  	    do i = write(fb->fd, fb->outbase, fb->outcnt);
+ #endif
  	    while (i == -1 && errno == EINTR && !(fb->flags & B_EOUT));
  	}
  	if (i <= 0) {
***************
*** 862,868 ****
--- 928,938 ----
      while (fb->outcnt > 0)
      {
  	/* the buffer must be full */
+ #ifdef B_SFIO
+  	do i = sfwrite(fb->sf_out, fb->outbase, fb->outcnt);
+ #else
  	do i = write(fb->fd, fb->outbase, fb->outcnt);
+ #endif
  	while (i == -1 && errno == EINTR && !(fb->flags & B_EOUT));
  	if (i == 0) {
  	    errno = EAGAIN;
***************
*** 919,924 ****
--- 989,999 ----
      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;
*** ./buff.h.orig	Mon Feb 10 10:49:54 1997
--- ./buff.h	Mon Jun 30 15:25:58 1997
***************
*** 50,55 ****
--- 50,59 ----
   *
   */
  
+ #ifdef B_SFIO
+ #include "sfio.h"
+ #endif
+ 
  #include <stdarg.h>
  
  /* Reading is buffered */
***************
*** 94,100 ****
--- 98,118 ----
  /* 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)
*** ./http_main.c.orig	Thu May 29 00:50:27 1997
--- ./http_main.c	Mon Jun 30 15:23:06 1997
***************
*** 1832,1837 ****
--- 1832,1848 ----
  	                          (request_rec*)NULL);
  
  	conn_io = bcreate(ptrans, B_RDWR);
+ 
+ #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) {
***************
*** 2106,2111 ****
--- 2117,2125 ----
   * Executive routines.
   */
  
+ #ifndef STANDALONE_MAIN
+ #define STANDALONE_MAIN standalone_main
+ 
  void standalone_main(int argc, char **argv)
  {
      struct sockaddr_in sa_server;
***************
*** 2322,2327 ****
--- 2336,2345 ----
      } while (restart_pending);
  
  } /* standalone_main */
+ #else
+ /* prototype */
+ void STANDALONE_MAIN(int argc, char **argv);
+ #endif /* STANDALONE_MAIN */
  
  extern char *optarg;
  extern int optind;
***************
*** 2394,2400 ****
      
      if(standalone) {
          clear_pool (pconf);	/* standalone_main rereads... */
!         standalone_main(argc, argv);
      }
      else {
          conn_rec *conn;
--- 2412,2418 ----
      
      if(standalone) {
          clear_pool (pconf);	/* standalone_main rereads... */
!         STANDALONE_MAIN(argc, argv);
      }
      else {
          conn_rec *conn;



Mime
View raw message