You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dg...@hyperreal.org on 1999/05/01 19:02:31 UTC

cvs commit: apache-1.3/src/modules/proxy proxy_ftp.c proxy_http.c proxy_util.c

dgaudet     99/05/01 10:02:30

  Modified:    src      CHANGES
               src/main http_main.c
               src/modules/proxy proxy_ftp.c proxy_http.c proxy_util.c
  Log:
  *) Fix intermittent SEGV in ap_proxy_cache_error() in
  src/modules/proxy_util.c where a NULL filepointer and temporary
  filename were closed and unlinked.
  
  *) Fix inconsistant error messages reported by mod_proxy
  
  PR:		3178
  Submitted by:	Graham Leggett <mi...@sharp.fm>
  
  Revision  Changes    Path
  1.1337    +8 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1336
  retrieving revision 1.1337
  diff -u -r1.1336 -r1.1337
  --- CHANGES	1999/05/01 13:42:07	1.1336
  +++ CHANGES	1999/05/01 17:02:24	1.1337
  @@ -1,5 +1,13 @@
   Changes with Apache 1.3.7
   
  +  *) Fix intermittent SEGV in ap_proxy_cache_error() in
  +     src/modules/proxy_util.c where a NULL filepointer and
  +     temporary filename were closed and unlinked.
  +     [Graham Leggett <mi...@sharp.fm>] PR#3178
  +
  +  *) Fix inconsistant error messages reported by mod_proxy.
  +     [Graham Leggett <mi...@sharp.fm>]
  +
     *) OS/2: Fix terminating CGIs that aren't compiled by EMX GCC when a 
        connection is aborted.  [Brian Havard]
   
  
  
  
  1.433     +2 -1      apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.432
  retrieving revision 1.433
  diff -u -r1.432 -r1.433
  --- http_main.c	1999/04/27 20:36:31	1.432
  +++ http_main.c	1999/05/01 17:02:26	1.433
  @@ -3678,6 +3678,7 @@
   #endif
   #endif
       signal(SIGALRM, alrm_handler);
  +    signal(SIGUSR2, alrm_handler);
   #ifdef TPF
       signal(SIGHUP, just_die);
       signal(SIGTERM, just_die);
  @@ -4241,7 +4242,7 @@
   		else if (ps->last_rtime + ss->timeout_len < now) {
   		    /* no progress, and the timeout length has been exceeded */
   		    ss->timeout_len = 0;
  -		    kill(ps->pid, SIGALRM);
  +		    kill(ps->pid, SIGUSR2);
   		}
   	    }
   #endif
  
  
  
  1.75      +18 -5     apache-1.3/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- proxy_ftp.c	1999/04/09 13:06:28	1.74
  +++ proxy_ftp.c	1999/05/01 17:02:28	1.75
  @@ -323,8 +323,11 @@
       while (!con->aborted) {
   	n = ap_bgets(buf, sizeof buf, f);
   	if (n == -1) {		/* input error */
  -	    if (c != NULL)
  +	    if (c != NULL) {
  +		ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		    "proxy: error reading from %s", c->url);
   		c = ap_proxy_cache_error(c);
  +	    }
   	    break;
   	}
   	if (n == 0)
  @@ -383,8 +386,11 @@
   	o = 0;
   	total_bytes_sent += n;
   
  -	if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n) != n)
  +	if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n) != n) {
  +	    ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		"proxy: error writing to %s", c->tempfile);
   	    c = ap_proxy_cache_error(c);
  +	}
   
   	while (n && !r->connection->aborted) {
   	    w = ap_bwrite(con->client, &buf[o], n);
  @@ -1196,8 +1202,11 @@
       if (!r->assbackwards)
   	ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
       if (c != NULL && c->fp != NULL
  -	&& ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1)
  -	c = ap_proxy_cache_error(c);
  +	&& ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) {
  +	    ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		"proxy: error writing CRLF to %s", c->tempfile);
  +	    c = ap_proxy_cache_error(c);
  +    }
   
   /* send headers */
       tdo.req = r;
  @@ -1206,8 +1215,11 @@
   
       if (!r->assbackwards)
   	ap_rputs(CRLF, r);
  -    if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1)
  +    if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) {
  +	ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +	    "proxy: error writing CRLF to %s", c->tempfile);
   	c = ap_proxy_cache_error(c);
  +    }
   
       ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
       r->sent_bodyct = 1;
  @@ -1226,6 +1238,7 @@
   
   	/* XXX: we checked for 125||150||226||250 above. This is redundant. */
   	if (rc != 226 && rc != 250)
  +            /* XXX: we no longer log an "error writing to c->tempfile" - should we? */
   	    c = ap_proxy_cache_error(c);
       }
       else {
  
  
  
  1.64      +21 -7     apache-1.3/src/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_http.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- proxy_http.c	1999/03/08 15:44:03	1.63
  +++ proxy_http.c	1999/05/01 17:02:29	1.64
  @@ -364,14 +364,19 @@
       ap_hard_timeout("proxy receive", r);
   
       len = ap_bgets(buffer, sizeof buffer - 1, f);
  -    if (len == -1 || len == 0) {
  +    if (len == -1) {
   	ap_bclose(f);
   	ap_kill_timeout(r);
   	ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
  -		     "ap_bgets() - proxy receive - Error reading from remote server %s",
  -		     proxyhost ? proxyhost : desthost);
  +		     "ap_bgets() - proxy receive - Error reading from remote server %s (length %d)",
  +		     proxyhost ? proxyhost : desthost, len);
   	return ap_proxyerror(r, HTTP_BAD_GATEWAY,
   			     "Error reading from remote server");
  +    } else if (len == 0) {
  +	ap_bclose(f);
  +	ap_kill_timeout(r);
  +	return ap_proxyerror(r, HTTP_BAD_GATEWAY,
  +			     "Document contains no data");
       }
   
   /* Is it an HTTP/1 response?  This is buggy if we ever see an HTTP/1.10 */
  @@ -480,8 +485,11 @@
       if (!r->assbackwards)
   	ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
       if (c != NULL && c->fp != NULL &&
  -	ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1)
  -	c = ap_proxy_cache_error(c);
  +	ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) {
  +	    ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		"proxy: error writing status line to %s", c->tempfile);
  +	    c = ap_proxy_cache_error(c);
  +    }
   
   /* send headers */
       tdo.req = r;
  @@ -490,16 +498,22 @@
   
       if (!r->assbackwards)
   	ap_rputs(CRLF, r);
  -    if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1)
  +    if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) {
  +	ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +	    "proxy: error writing CRLF to %s", c->tempfile);
   	c = ap_proxy_cache_error(c);
  +    }
   
       ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
       r->sent_bodyct = 1;
   /* Is it an HTTP/0.9 respose? If so, send the extra data */
       if (backasswards) {
   	ap_bwrite(r->connection->client, buffer, len);
  -	if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len) != len)
  +	if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len) != len) {
  +	    ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		"proxy: error writing extra data to %s", c->tempfile);
   	    c = ap_proxy_cache_error(c);
  +	}
       }
       ap_kill_timeout(r);
   
  
  
  
  1.79      +18 -8     apache-1.3/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- proxy_util.c	1999/03/10 17:42:46	1.78
  +++ proxy_util.c	1999/05/01 17:02:29	1.79
  @@ -553,8 +553,11 @@
               ap_reset_timeout(r);
   
   	if (n == -1) {		/* input error */
  -	    if (c != NULL)
  +	    if (c != NULL) {
  +		ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		    "proxy: error reading from %s", c->url);
   		c = ap_proxy_cache_error(c);
  +	    }
   	    break;
   	}
   	if (n == 0)
  @@ -566,7 +569,9 @@
   	/*@@@ 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);
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  +		    "proxy: error writing to %s", c->tempfile);
  +		c = ap_proxy_cache_error(c);
               } else {
                   c->written += n;
               }
  @@ -824,11 +829,13 @@
   
   cache_req *ap_proxy_cache_error(cache_req *c)
   {
  -    ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
  -		 "proxy: error writing to cache file %s", c->tempfile);
  -    ap_pclosef(c->req->pool, c->fp->fd);
  -    c->fp = NULL;
  -    unlink(c->tempfile);
  +    if (c != NULL) {
  +	if (c->fp != NULL) {
  +	    ap_pclosef(c->req->pool, c->fp->fd);
  +	    c->fp = NULL;
  +	}
  +	if (c->tempfile) unlink(c->tempfile);
  +    }
       return NULL;
   }
   
  @@ -1262,8 +1269,11 @@
       if (!parm->req->assbackwards)
   	ap_rvputs(parm->req, key, ": ", value, CRLF, NULL);
       if (parm->cache != NULL && parm->cache->fp != NULL &&
  -	ap_bvputs(parm->cache->fp, key, ": ", value, CRLF, NULL) == -1)
  +	ap_bvputs(parm->cache->fp, key, ": ", value, CRLF, NULL) == -1) {
  +	    ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->cache->req,
  +		    "proxy: error writing header to %s", parm->cache->tempfile);
   	    parm->cache = ap_proxy_cache_error(parm->cache);
  +    }
       return 1; /* tell ap_table_do() to continue calling us for more headers */
   }