stoddard 99/08/27 13:22:04
Modified: src/modules/proxy proxy_cache.c proxy_connect.c proxy_util.c Log: Do not access fd directly, use ap_bfileno instead. Revision Changes Path 1.63 +17 -18 apache-1.3/src/modules/proxy/proxy_cache.c Index: proxy_cache.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- proxy_cache.c 1999/08/02 10:45:33 1.62 +++ proxy_cache.c 1999/08/27 20:21:49 1.63 @@ -728,7 +728,7 @@ ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r, "proxy: bad (short?) cache file: %s", c->filename); if (i != 1) { - ap_pclosef(r->pool, cachefp->fd); + ap_pclosef(r->pool, ap_bfileno(cachefp, B_WR)); cachefp = NULL; } } @@ -754,7 +754,7 @@ if ((q = ap_table_get(c->hdrs, "Expires")) != NULL) ap_table_set(r->headers_out, "Expires", q); } - ap_pclosef(r->pool, cachefp->fd); + ap_pclosef(r->pool, ap_bfileno(cachefp, B_WR)); Explain0("Use local copy, cached file hasn't changed"); return HTTP_NOT_MODIFIED; } @@ -772,7 +772,7 @@ r->sent_bodyct = 1; if (!r->header_only) ap_proxy_send_fb(cachefp, r, NULL); - ap_pclosef(r->pool, cachefp->fd); + ap_pclosef(r->pool, ap_bfileno(cachefp, B_WR)); return OK; } @@ -876,7 +876,7 @@ Explain1("Response is not cacheable, unlinking %s", c->filename); /* close the file */ if (c->fp != NULL) { - ap_pclosef(r->pool, c->fp->fd); + ap_pclosef(r->pool, ap_bfileno(c->fp, B_WR)); c->fp = NULL; } /* delete the previously cached file */ @@ -973,17 +973,17 @@ /* set any changed headers somehow */ /* update dates and version, but not content-length */ if (lmod != c->lmod || expc != c->expire || date != c->date) { - off_t curpos = lseek(c->fp->fd, 0, SEEK_SET); + off_t curpos = lseek(ap_bfileno(c->fp, B_WR), 0, SEEK_SET); if (curpos == -1) ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error seeking on cache file %s", c->filename); - else if (write(c->fp->fd, buff, 35) == -1) + else if (write(ap_bfileno(c->fp, B_WR), buff, 35) == -1) ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error updating cache file %s", c->filename); } - ap_pclosef(r->pool, c->fp->fd); + ap_pclosef(r->pool, ap_bfileno(c->fp, B_WR)); Explain0("Remote document not modified, use local copy"); /* CHECKME: Is this right? Shouldn't we check IMS again here? */ return HTTP_NOT_MODIFIED; @@ -1005,25 +1005,24 @@ /* set any changed headers somehow */ /* update dates and version, but not content-length */ if (lmod != c->lmod || expc != c->expire || date != c->date) { - off_t curpos = lseek(c->fp->fd, 0, SEEK_SET); + off_t curpos = lseek(ap_bfileno(c->fp, B_WR), 0, SEEK_SET); if (curpos == -1) ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error seeking on cache file %s", c->filename); - else if (write(c->fp->fd, buff, 35) == -1) + else if (write(ap_bfileno(c->fp, B_WR), buff, 35) == -1) ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error updating cache file %s", c->filename); } - ap_pclosef(r->pool, c->fp->fd); + ap_pclosef(r->pool, ap_bfileno(c->fp, B_WR)); return OK; } } /* new or modified file */ if (c->fp != NULL) { - ap_pclosef(r->pool, c->fp->fd); - c->fp->fd = -1; + ap_pclosef(r->pool, ap_bfileno(c->fp, B_WR)); } c->version = 0; ap_proxy_sec2hex(0, buff + 27); @@ -1057,7 +1056,7 @@ if (ap_bvputs(c->fp, buff, "X-URL: ", c->url, "\n", NULL) == -1) { ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error writing cache file(%s)", c->tempfile); - ap_pclosef(r->pool, c->fp->fd); + ap_pclosef(r->pool, ap_bfileno(c->fp, B_WR)); unlink(c->tempfile); c->fp = NULL; } @@ -1082,7 +1081,7 @@ if (c->len != -1) { /* file lengths don't match; don't cache it */ if (bc != c->len) { - ap_pclosef(c->req->pool, c->fp->fd); /* no need to flush */ + ap_pclosef(c->req->pool, ap_bfileno(c->fp, B_WR)); /* no need to flush */ unlink(c->tempfile); return; } @@ -1102,11 +1101,11 @@ c->len = bc; ap_bflush(c->fp); ap_proxy_sec2hex(c->len, buff); - curpos = lseek(c->fp->fd, 36, SEEK_SET); + curpos = lseek(ap_bfileno(c->fp, B_WR), 36, SEEK_SET); if (curpos == -1) ap_log_error(APLOG_MARK, APLOG_ERR, s, "proxy: error seeking on cache file %s", c->tempfile); - else if (write(c->fp->fd, buff, 8) == -1) + else if (write(ap_bfileno(c->fp, B_WR), buff, 8) == -1) ap_log_error(APLOG_MARK, APLOG_ERR, s, "proxy: error updating cache file %s", c->tempfile); } @@ -1115,12 +1114,12 @@ ap_log_error(APLOG_MARK, APLOG_ERR, s, "proxy: error writing to cache file %s", c->tempfile); - ap_pclosef(c->req->pool, c->fp->fd); + ap_pclosef(c->req->pool, ap_bfileno(c->fp, B_WR)); unlink(c->tempfile); return; } - if (ap_pclosef(c->req->pool, c->fp->fd) == -1) { + if (ap_pclosef(c->req->pool, ap_bfileno(c->fp, B_WR)) == -1) { ap_log_error(APLOG_MARK, APLOG_ERR, s, "proxy: error closing cache file %s", c->tempfile); unlink(c->tempfile); 1.39 +6 -6 apache-1.3/src/modules/proxy/proxy_connect.c Index: proxy_connect.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_connect.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- proxy_connect.c 1999/04/27 20:36:34 1.38 +++ proxy_connect.c 1999/08/27 20:21:51 1.39 @@ -241,11 +241,11 @@ while (1) { /* Infinite loop until error (one side closes the connection) */ FD_ZERO(&fds); FD_SET(sock, &fds); - FD_SET(r->connection->client->fd, &fds); + FD_SET(ap_bfileno(r->connection->client, B_WR), &fds); Explain0("Going to sleep (select)"); - i = ap_select((r->connection->client->fd > sock ? - r->connection->client->fd + 1 : + i = ap_select((ap_bfileno(r->connection->client, B_WR) > sock ? + ap_bfileno(r->connection->client, B_WR) + 1 : sock + 1), &fds, NULL, NULL, NULL); Explain1("Woke from select(), i=%d", i); @@ -255,16 +255,16 @@ if ((nbytes = read(sock, buffer, HUGE_STRING_LEN)) != 0) { if (nbytes == -1) break; - if (write(r->connection->client->fd, buffer, nbytes) == EOF) + if (write(ap_bfileno(r->connection->client, B_WR), buffer, nbytes) == EOF) break; Explain1("Wrote %d bytes to client", nbytes); } else break; } - else if (FD_ISSET(r->connection->client->fd, &fds)) { + else if (FD_ISSET(ap_bfileno(r->connection->client, B_WR), &fds)) { Explain0("client->fd was set"); - if ((nbytes = read(r->connection->client->fd, buffer, + if ((nbytes = read(ap_bfileno(r->connection->client, B_WR), buffer, HUGE_STRING_LEN)) != 0) { if (nbytes == -1) break; 1.80 +2 -2 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.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- proxy_util.c 1999/05/01 17:02:29 1.79 +++ proxy_util.c 1999/08/27 20:21:52 1.80 @@ -600,7 +600,7 @@ (c->len * c->cache_completion < total_bytes_rcvd); if (! ok) { - ap_pclosef(c->req->pool, c->fp->fd); + ap_pclosef(c->req->pool, ap_bfileno(c->fp, B_WR)); c->fp = NULL; unlink(c->tempfile); c = NULL; @@ -831,7 +831,7 @@ { if (c != NULL) { if (c->fp != NULL) { - ap_pclosef(c->req->pool, c->fp->fd); + ap_pclosef(c->req->pool, ap_bfileno(c->fp, B_WR)); c->fp = NULL; } if (c->tempfile) unlink(c->tempfile);