httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@hyperreal.org
Subject cvs commit: apache-1.3/src/modules/proxy proxy_util.c
Date Sun, 07 Feb 1999 20:37:27 GMT
martin      99/02/07 12:37:27

  Modified:    src/modules/proxy proxy_util.c
  Log:
  Minor 'beautification' (adding comments)
  
  Revision  Changes    Path
  1.75      +27 -29    apache-1.3/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- proxy_util.c	1999/01/01 19:05:03	1.74
  +++ proxy_util.c	1999/02/07 20:37:26	1.75
  @@ -491,15 +491,15 @@
   
   long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c)
   {
  -    int  ok = 1;
  +    int  ok;
       char buf[IOBUFSIZE];
  -    long total_bytes_rcv;
  +    long total_bytes_rcvd;
       register int n, o, w;
       conn_rec *con = r->connection;
  -    int alt_to = 1;
  +    int alternate_timeouts = 1;	/* 1 if we alternate between soft & hard timeouts */
   
  -    total_bytes_rcv = 0;
  -    if (c)
  +    total_bytes_rcvd = 0;
  +    if (c != NULL)
           c->written = 0;
   
   #ifdef CHARSET_EBCDIC
  @@ -520,34 +520,34 @@
   #ifdef WIN32
       /* works fine under win32, so leave it */
       ap_hard_timeout("proxy send body", r);
  -    alt_to = 0;
  +    alternate_timeouts = 0;
   #else
       /* CHECKME! Since hard_timeout won't work in unix on sends with partial
        * cache completion, we have to alternate between hard_timeout
        * for reads, and soft_timeout for send.  This is because we need
        * to get a return from ap_bwrite to be able to continue caching.
        * BUT, if we *can't* continue anyway, just use hard_timeout.
  +     * (Also, if no cache file is written, use hard timeouts)
        */
   
  -    if (c) {
  -        if (c->len <= 0 || c->cache_completion == 1) {
  -            ap_hard_timeout("proxy send body", r);
  -            alt_to = 0;
  -        }
  -    } else {
  +    if (c == NULL || c->len <= 0 || c->cache_completion == 1.0) {
           ap_hard_timeout("proxy send body", r);
  -        alt_to = 0;
  +        alternate_timeouts = 0;
       }
   #endif
   
  -    while (ok) {
  -        if (alt_to)
  -            ap_hard_timeout("proxy send body", r);
  +    /* Loop and ap_bread() while we can successfully read and write,
  +     * or (after the client aborted) while we can successfully
  +     * read and finish the configured cache_completion.
  +     */
  +    for (ok = 1; ok; ) {
  +        if (alternate_timeouts)
  +            ap_hard_timeout("proxy recv body from upstream server", r);
   
   	/* Read block from server */
   	n = ap_bread(f, buf, IOBUFSIZE);
   
  -        if (alt_to)
  +        if (alternate_timeouts)
               ap_kill_timeout(r);
           else
               ap_reset_timeout(r);
  @@ -560,9 +560,10 @@
   	if (n == 0)
   	    break;		/* EOF */
   	o = 0;
  -	total_bytes_rcv += n;
  +	total_bytes_rcvd += n;
   
   	/* Write to cache first. */
  +	/*@@@ XXX FIXME: Assuming that writing the cache file won't time out?!!? */
           if (c != NULL && c->fp != NULL) {
               if (ap_bwrite(c->fp, &buf[0], n) != n) {
                   c = ap_proxy_cache_error(c);
  @@ -572,13 +573,13 @@
           }
   
   	/* Write the block to the client, detect aborted transfers */
  -        while (n && !con->aborted) {
  -            if (alt_to)
  +        while (!con->aborted && n > 0) {
  +            if (alternate_timeouts)
                   ap_soft_timeout("proxy send body", r);
   
               w = ap_bwrite(con->client, &buf[o], n);
   
  -            if (alt_to)
  +            if (alternate_timeouts)
                   ap_kill_timeout(r);
               else
                   ap_reset_timeout(r);
  @@ -591,7 +592,7 @@
                        */
                       ok = (c->len > 0) &&
                            (c->cache_completion > 0) &&
  -                         (c->len * c->cache_completion < total_bytes_rcv);
  +                         (c->len * c->cache_completion < total_bytes_rcvd);
   
                       if (! ok) {
                           ap_pclosef(c->req->pool, c->fp->fd);
  @@ -605,14 +606,14 @@
               }
               n -= w;
               o += w;
  -        }
  -    }
  +        } /* while client alive and more data to send */
  +    } /* loop and ap_bread while "ok" */
   
       if (!con->aborted)
   	ap_bflush(con->client);
   
       ap_kill_timeout(r);
  -    return total_bytes_rcv;
  +    return total_bytes_rcvd;
   }
   
   /*
  @@ -628,14 +629,11 @@
       BUFF *fp = r->connection->client;
       table_entry *elts = (table_entry *) ap_table_elts(t)->elts;
   
  -    ap_bputs(respline, fp);
  -    ap_bputs(CRLF, fp);
  +    ap_bvputs(fp, respline, CRLF, NULL);
   
       for (i = 0; i < ap_table_elts(t)->nelts; ++i) {
   	if (elts[i].key != NULL) {
   	    ap_bvputs(fp, elts[i].key, ": ", elts[i].val, CRLF, NULL);
  -	    /* FIXME: @@@ This used to be ap_table_set(), but I think
  -	     * ap_table_addn() is correct. MnKr */
   	    ap_table_addn(r->headers_out, elts[i].key, elts[i].val);
   	}
       }
  
  
  

Mime
View raw message