w = ap_bwrite(con->client, &buf[o], n);
if (w <= 0)
break;
- ap_reset_timeout(r); /* reset timeout after successfule write */
n -= w;
o += w;
}
* because it has the lifetime of the connection. The other allocations
* are temporary and can be tossed away any time.
*/
- user = ap_getword_nulls (r->connection->pool, &password, ':');
- r->connection->ap_auth_type = "Basic";
- r->connection->user = r->parsed_uri.user = user;
+ user = ap_getword_nulls (r->pool, &password, ':');
+ r->ap_auth_type = "Basic";
+ r->user = r->parsed_uri.user = user;
nocache = 1; /* This resource only accessible with username/password */
}
else if ((user = r->parsed_uri.user) != NULL) {
}
f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock, sock);
+ ap_bpushfd(f, sock);
/* shouldn't we implement telnet control options here? */
#ifdef CHARSET_EBCDIC
/* 120 Service ready in nnn minutes. */
/* 220 Service ready for new user. */
/* 421 Service not available, closing control connection. */
- ap_hard_timeout("proxy ftp", r);
i = ftp_getrc_msg(f, resp, sizeof resp);
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
#if 0
if (i == 120) {
- ap_kill_timeout(r);
/* RFC2068 states:
* 14.38 Retry-After
*
}
#endif
if (i != 220) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY, resp);
}
i = ftp_getrc(f);
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i == 530) {
- ap_kill_timeout(r);
return ftp_unauthorized (r, 1); /* log it: user name guessing attempt? */
}
if (i != 230 && i != 331) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
i = ftp_getrc(f);
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, "Error reading from remote server");
}
if (i == 332) {
- ap_kill_timeout(r);
- return ap_proxyerror(r, HTTP_UNAUTHORIZED,
- "Need account for login");
+ return ap_proxyerror(r, HTTP_UNAUTHORIZED, "Need account for login");
}
/* @@@ questionable -- we might as well return a 403 Forbidden here */
if (i == 530) {
- ap_kill_timeout(r);
return ftp_unauthorized (r, 1); /* log it: passwd guessing attempt? */
}
if (i != 230 && i != 202) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
}
i = ftp_getrc(f);
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i == 550) {
- ap_kill_timeout(r);
return HTTP_NOT_FOUND;
}
if (i != 250) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
i = ftp_getrc(f);
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i != 200 && i != 504) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
/* Allow not implemented */
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"proxy: error creating PASV socket");
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_INTERNAL_SERVER_ERROR;
}
"PASV: control connection is toast");
ap_pclosesocket(p, dsock);
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_INTERNAL_SERVER_ERROR;
}
else {
i = ap_proxy_doconnect(dsock, &data_addr, r);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- ap_pstrcat(r->pool,
- "Could not connect to remote machine: ",
- strerror(errno), NULL));
+ ap_pstrcat(r->pool,
+ "Could not connect to remote machine: ",
+ strerror(errno), NULL));
}
else {
pasvmode = 1;
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"proxy: error getting socket address");
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_INTERNAL_SERVER_ERROR;
}
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"proxy: error creating socket");
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_INTERNAL_SERVER_ERROR;
}
"proxy: error setting reuseaddr option");
ap_pclosesocket(p, dsock);
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_INTERNAL_SERVER_ERROR;
#endif /*_OSD_POSIX*/
}
/* 550 Requested action not taken. */
Explain1("FTP: returned status %d", i);
if (i == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i == 550) {
- ap_kill_timeout(r);
return HTTP_NOT_FOUND;
}
if (i != 250) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
path = "";
i = ftp_getrc_msg(f, resp, sizeof resp);
Explain1("FTP: PWD returned status %d", i);
if (i == -1 || i == 421) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i == 550) {
- ap_kill_timeout(r);
return HTTP_NOT_FOUND;
}
if (i == 257) {
rc = ftp_getrc(f);
Explain1("FTP: returned status %d", rc);
if (rc == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (rc == 550) {
Explain0("FTP: RETR failed, trying LIST instead");
rc = ftp_getrc(f);
Explain1("FTP: returned status %d", rc);
if (rc == -1) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (rc == 550) {
- ap_kill_timeout(r);
return HTTP_NOT_FOUND;
}
if (rc != 250) {
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
i = ftp_getrc_msg(f, resp, sizeof resp);
Explain1("FTP: PWD returned status %d", i);
if (i == -1 || i == 421) {
- ap_kill_timeout(r);
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
+ "Error reading from remote server");
}
if (i == 550) {
- ap_kill_timeout(r);
return HTTP_NOT_FOUND;
}
if (i == 257) {
return ap_proxyerror(r, HTTP_BAD_GATEWAY,
"Error reading from remote server");
}
- ap_kill_timeout(r);
if (rc != 125 && rc != 150 && rc != 226 && rc != 250)
return HTTP_BAD_GATEWAY;
}
if (!pasvmode) { /* wait for connection */
- ap_hard_timeout("proxy ftp data connect", r);
clen = sizeof(struct sockaddr_in);
do
csd = accept(dsock, (struct sockaddr *) &server, &clen);
"proxy: failed to accept data connection");
ap_pclosesocket(p, dsock);
ap_bclose(f);
- ap_kill_timeout(r);
if (c != NULL)
c = ap_proxy_cache_error(c);
return HTTP_BAD_GATEWAY;
}
ap_note_cleanups_for_socket(p, csd);
data = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(data, csd, -1);
- ap_kill_timeout(r);
+ ap_bpushfd(data, csd);
}
else {
data = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(data, dsock, dsock);
+ ap_bpushfd(data, dsock);
}
- ap_hard_timeout("proxy receive", r);
/* send response */
/* write status line */
if (!r->assbackwards)
Explain1("FTP: returned status %d", i);
}
- ap_kill_timeout(r);
ap_proxy_cache_tidy(c);
/* finish */
clear_connection(r->pool, r->headers_in); /* Strip connection-based headers */
f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock, sock);
+ ap_bpushfd(f, sock);
- ap_hard_timeout("proxy send", r);
ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF,
NULL);
if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
ap_bwrite(f, buffer, i);
}
ap_bflush(f);
- ap_kill_timeout(r);
-
- ap_hard_timeout("proxy receive", r);
len = ap_bgets(buffer, sizeof buffer - 1, f);
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 (length %d)",
proxyhost ? proxyhost : desthost, len);
"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");
}
/* If not an HTTP/1 message or if the status line was > 8192 bytes */
if (buffer[5] != '1' || buffer[len - 1] != '\n') {
ap_bclose(f);
- ap_kill_timeout(r);
return HTTP_BAD_GATEWAY;
}
backasswards = 0;
c->hdrs = resp_hdrs;
- ap_kill_timeout(r);
/*
* HTTP/1.0 requires us to accept 3 types of dates, but only generate
return i;
}
- ap_hard_timeout("proxy receive", r);
-
/* write status line */
if (!r->assbackwards)
ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
c = ap_proxy_cache_error(c);
}
}
- ap_kill_timeout(r);
#ifdef CHARSET_EBCDIC
/* What we read/write after the header should not be modified
#include "mod_proxy.h"
#include "http_main.h"
#include "ap_md5.h"
-#include "multithread.h"
#include "http_log.h"
#include "util_uri.h"
#include "util_date.h" /* get ap_checkmask() decl. */
+#include <pthread.h>
+
static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
* has its own timeout handler which can set both buffers to EOUT.
*/
- ap_kill_timeout(r);
-
#ifdef WIN32
/* works fine under win32, so leave it */
- ap_hard_timeout("proxy send body", r);
- 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 == NULL || c->len <= 0 || c->cache_completion == 1.0) {
- ap_hard_timeout("proxy send body", r);
alternate_timeouts = 0;
}
#endif
* 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);
-
+ for (ok = 1; ok; ) {
/* Read block from server */
n = ap_bread(f, buf, IOBUFSIZE);
- if (alternate_timeouts)
- ap_kill_timeout(r);
- else
- ap_reset_timeout(r);
-
if (n == -1) { /* input error */
if (c != NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
/* Write the block to the client, detect aborted transfers */
while (!con->aborted && n > 0) {
- if (alternate_timeouts)
- ap_soft_timeout("proxy send body", r);
-
w = ap_bwrite(con->client, &buf[o], n);
- if (alternate_timeouts)
- ap_kill_timeout(r);
- else
- ap_reset_timeout(r);
-
if (w <= 0) {
if (c != NULL && c->fp != NULL) {
/* when a send failure occurs, we need to decide
if (!con->aborted)
ap_bflush(con->client);
- ap_kill_timeout(r);
return total_bytes_rcvd;
}
{
int i;
struct hostent *hp;
+/* XXX - Either get rid of TLS, or use pthread/APR functions */
+#define APACHE_TLS
static APACHE_TLS struct hostent hpbuf;
static APACHE_TLS u_long ipaddr;
static APACHE_TLS char *charpbuf[2];
{
int i;
- ap_hard_timeout("proxy connect", r);
do {
i = connect(sock, (struct sockaddr *) addr, sizeof(struct sockaddr_in));
#ifdef WIN32
"proxy connect to %s port %d failed",
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port));
}
- ap_kill_timeout(r);
return i;
}