Apache 2.0 STATUS:
-Last modified at [$Date: 1999/11/16 15:11:51 $]
+Last modified at [$Date: 1999/11/16 18:30:18 $]
Release:
* TODO in source -- just do an egrep on "TODO" and see what's there
- * Odd comments in source (egrep for "ZZZ") need to be cleaned-up
-
* Work on other MPMs. Possible MPMs discussed or in progress include:
- Dean Gaudet's async MPM
/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
-/* ZZZ let's pass the buffer and the host entry so we don't have to allocate
- another stack frame. */
static ap_inline void do_double_reverse (conn_rec *conn)
{
struct hostent *hptr;
conn->double_reverse = -1;
return;
}
- hptr = gethostbyname(conn->remote_host); /*ZZZ change to AP func */
- if (hptr) { /*ZZZ enumerate through host entries */
+ hptr = gethostbyname(conn->remote_host);
+ if (hptr) {
char **haddr;
for (haddr = hptr->h_addr_list; *haddr; haddr++) {
&& conn->remote_host == NULL
&& (type == REMOTE_DOUBLE_REV
|| hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
- /* ZZZ change to AP functions. */
iaddr = &(conn->remote_addr.sin_addr);
hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), AF_INET);
if (hptr != NULL) {
if (r->method_number == M_PUT) {
return METHOD_NOT_ALLOWED;
}
- /* ZZZ can we store if the file exists or not? */
if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
"File does not exist: %s",r->path_info ?
((r->proto_num >= HTTP_VERSION(1,1)) &&
(r->chunked = 1))) && /* THIS CODE IS CORRECT, see comment above. */
r->server->keep_alive &&
- /* ZZZ change to APR keepalive timeout defined value */
(r->server->keep_alive_timeout > 0) &&
((r->server->keep_alive_max == 0) ||
(r->server->keep_alive_max > r->connection->keepalives)) &&
* were given a time in the future, we return the current time - the
* Last-Modified can't be in the future.
*/
- /* ZZZ Change time call to use time AP time thread functions. */
now = (mtime < r->request_time) ? r->request_time : time(NULL);
return (mtime > now) ? now : mtime;
}
return OK;
}
- /* ZZZ We are changing time(NULL) to AP time thread functions. */
mtime = (r->mtime != 0) ? r->mtime : time(NULL);
/* If an If-Match request-header field was given
static int check_safe_file(request_rec *r)
{
- /* ZZZ change to AP defines */
if (r->finfo.st_mode == 0 /* doesn't exist */
|| S_ISDIR(r->finfo.st_mode)
|| S_ISREG(r->finfo.st_mode)
}
else {
errno = 0;
- /* ZZZ change to AP func for File Info */
rv = stat(path, &r->finfo);
}
if (cp != end)
*cp = '/';
- if (!rv) { /* ZZZ AP Status check here */
-
+ if (!rv) {
/*
* Aha! Found something. If it was a directory, we will search
* contents of that directory for a multi_match, so the PATH_INFO
* argument starts with the component after that.
*/
- /* ZZZ use AP file type checking defines */
if (S_ISDIR(r->finfo.st_mode) && last_cp) {
r->finfo.st_mode = 0; /* No such file... */
cp = last_cp;
*/
r->finfo.st_mode = 0;
- /* ZZZ Let's throw some AP Errno checking in here and get rid of the
- #defines. */
#if defined(ENOENT) && defined(ENOTDIR)
if (errno == ENOENT || errno == ENOTDIR) {
last_cp = cp;
--cp;
}
else {
-#if defined(EACCES) /* ZZZ again, AP error checking. */
+#if defined(EACCES)
if (errno != EACCES)
#endif
ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
if (test_filename[test_filename_len - 1] == '/')
--num_dirs;
- if (S_ISDIR(r->finfo.st_mode)) /* zzz use AP funcs and defines to make
- this quicker */
+ if (S_ISDIR(r->finfo.st_mode))
++num_dirs;
/*
* S_ISDIR test. But if you accessed /symlink/index.html, for example,
* you would *not* get the 403.
*/
- if (!S_ISDIR(r->finfo.st_mode) /* ZZZ use AP funcs and defines */
+ if (!S_ISDIR(r->finfo.st_mode)
&& (res = check_symlinks(r->filename, ap_allow_options(r)))) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"Symbolic link not allowed: %s", r->filename);
rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */
- /* ZZZ use AP funcs to get File Info */
if (stat(rnew->filename, &rnew->finfo) < 0) {
rnew->finfo.st_mode = 0;
}
* no matter what, if it's a subdirectory, we need to re-run
* directory_walk
*/
- /* ZZZ use AP funcs and defines for this. */
if (S_ISDIR(rnew->finfo.st_mode)) {
res = directory_walk(rnew);
if (!res) {
chdir("/");
-/* ZZZ
+/*
* fork() is evil if we're also doing spawn_thread...so we don't use it.
* This means that it won't detach properly, so we'll have to find a way
* round this.
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
- if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */
+ if (stat(fname, &finfo) == -1)
return;
}
/* don't require conf/httpd.conf if we have a -C or -c switch */
if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
!(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
- if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */
+ if (stat(fname, &finfo) == -1)
return;
}
parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
if (ap_pcfg_openfile(&parms.config_file, p, fname) != APR_SUCCESS) {
- /* ZZZ use ap_strerror() once it exists to print an error message */
fprintf(stderr, "%s: could not open document config file %s\n",
ap_server_argv0, fname);
exit(1);
s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
- s->timeout = DEFAULT_TIMEOUT; /*ZZZ use AP default timeouts here*/
+ s->timeout = DEFAULT_TIMEOUT;
s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
s->keep_alive_max = DEFAULT_KEEPALIVE;
s->keep_alive = 1;
s->next = NULL;
s->addrs = ap_pcalloc(p, sizeof(server_addr_rec));
/* NOT virtual host; don't match any real network interface */
- /* ZZZ Initialize the Network Address here. */
s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
s->addrs->host_port = 0; /* matches any port */
s->addrs->virthost = ""; /* must be non-NULL */
#ifdef USE_SO_LINGER
#define NO_LINGCLOSE /* The two lingering options are exclusive */
-static void sock_enable_linger(int s) /* // ZZZZZ abstract the socket, s */
+static void sock_enable_linger(int s)
{
- struct linger li; /* // ZZZZZ SocketOptions... */
+ struct linger li;
li.l_onoff = 1;
li.l_linger = MAX_SECS_TO_LINGER;
- if (setsockopt(s, SOL_SOCKET, SO_LINGER, /* // ZZZZZ abstract, return SUCCESS or not */
+ if (setsockopt(s, SOL_SOCKET, SO_LINGER,
(char *) &li, sizeof(struct linger)) < 0) {
ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf,
"setsockopt: (SO_LINGER)");
* distinguish between a dropped connection and something that might be
* worth logging.
*/
-/*ZZZ this routine needs to be adapted for use with poll()*/
static void lingering_close(request_rec *r)
{
- /*ZZZ remove the hardwired 512. This is an IO Buffer Size */
+ /*TODO remove the hardwired 512. This is an IO Buffer Size */
char dummybuf[512];
struct pollfd pd;
int lsd;
lsd = r->connection->client->fd;
- if ((shutdown(lsd, 1) != 0) /* ZZZ abstract shutdown */
+ if ((shutdown(lsd, 1) != 0)
|| ap_is_aborted(r->connection)) {
ap_bclose(r->connection->client);
return;
pd.revents = 0;
} while ((poll(&pd, 1, 2) == 1)
&& read(lsd, dummybuf, sizeof(dummybuf)));
- /* && (time() = epoch) < max_wait); */ /* ZZZZ time function is not good... */
+ /* && (time() = epoch) < max_wait); */
/* Should now have seen final ack. Safe to finally kill socket */
ap_bclose(r->connection->client);
*/
#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(int s) /* ZZZ abstract */
+static void sock_disable_nagle(int s)
{
/* The Nagle algorithm says that we should delay sending partial
* packets in hopes of getting more data. We don't want to do
}
}
-static int make_child(server_rec *s, int slot, time_t now) /* ZZZ */
+static int make_child(server_rec *s, int slot, time_t now)
{
int pid;
/* we're still doing a 1-for-1 replacement of dead
* children with new children
*/
- /* ZZZ abstract out for AP funcs. */
make_child(server_conf, child_slot, time(NULL));
--remaining_children_to_start;
}
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
return (0);
}
-static int make_child(server_rec *s, int slot, time_t now) /* ZZZ */
+static int make_child(server_rec *s, int slot, time_t now)
{
thread_id tid;
/* we're still doing a 1-for-1 replacement of dead
* children with new children
*/
- /* ZZZ abstract out for AP funcs. */
make_child(server_conf, child_slot, time(NULL));
--remaining_children_to_start;
}
"SIGHUP received. Attempting to restart");
}
if (!is_graceful) {
- ap_restart_time = time(NULL); /* ZZZZZ */
+ ap_restart_time = time(NULL);
}
delete_port(port_of_death);
return 0;
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
*/
#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(int s) /* ZZZ abstract */
+static void sock_disable_nagle(int s)
{
/* The Nagle algorithm says that we should delay sending partial
* packets in hopes of getting more data. We don't want to do
}
}
-static int make_child(server_rec *s, int slot, time_t now) /* ZZZ */
+static int make_child(server_rec *s, int slot, time_t now)
{
int pid;
idle_spawn_rate = 1;
}
else {
- /* ZZZZ */
if (idle_spawn_rate >= 8) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
/* we're still doing a 1-for-1 replacement of dead
* children with new children
*/
- /* ZZZ abstract out for AP funcs. */
make_child(server_conf, child_slot, time(NULL));
--remaining_children_to_start;
}
"SIGHUP received. Attempting to restart");
}
if (!is_graceful) {
- ap_restart_time = time(NULL); /* ZZZZZ */
+ ap_restart_time = time(NULL);
}
return 0;
}
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
ss = &ap_scoreboard_image->servers[child_num][thread_num];
if (status == START_PREQUEST) {
- /*ss->start_time = GetCurrentTime(); ZZZ return time in uS since the
+ /*ss->start_time = GetCurrentTime(); return time in uS since the
epoch. Some platforms do not support gettimeofday. Create a routine
to get the current time is some useful units. */
if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0) {
}
else if (status == STOP_PREQUEST) {
/*ss->stop_time = GetCurrentTime();
- ZZZ return time in uS since the epoch */
+ return time in uS since the epoch */
if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0) {
ss->start_time.tv_sec = ss->start_time.tv_usec = 0L;
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
return;
}
-static void sock_disable_nagle(int s) /* ZZZ abstract */
+static void sock_disable_nagle(int s)
{
/* The Nagle algorithm says that we should delay sending partial
* packets in hopes of getting more data. We don't want to do
}
fname = ap_server_root_relative(cmd->pool, arg);
- /* ZZZ change this to the AP func FileInfo*/
if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
" does not exist or is not a directory", NULL);
API_EXPORT(char *) ap_get_time()
{
- /* ZZZ When we abstract out time, this whole function should change to use
- AP funcs. */
time_t t;
char *time_string;
API_EXPORT(char *) ap_ht_time(ap_context_t *p, time_t t, const char *fmt, int gmt)
{
- /* ZZZ this function can be replaced by calls to time formatting routines
- in APR. */
char ts[MAX_STRING_LEN];
char tf[MAX_STRING_LEN];
struct tm *tms;
char *date_str_ptr = date_str;
int real_year;
- tms = gmtime(&sec); /* ZZZ replace with AP time routine */
+ tms = gmtime(&sec);
/* Assumption: this is always 3 */
/* i = strlen(ap_day_snames[tms->tm_wday]); */
{
struct stat finfo;
- /* ZZZ replace with AP File Info func. */
if (stat(path, &finfo) == -1)
return 0; /* in error condition, just return no */
*/
unsigned long ap_get_virthost_addr(char *w, unsigned short *ports)
{
- /* ZZZ Redesign for AP func changes */
struct hostent *hep;
unsigned long my_addr;
char *p;
char *server_hostname;
struct hostent *p;
- /* ZZZ change to use AP funcs. */
#ifdef BEOS
if (gethostname(str, sizeof(str) - 1) == 0)
#else
int nbytes;
ap_MD5Init(&context);
- /* ZZZ use AP func instead of fread. */
while ((nbytes = read(infile, buf, sizeof(buf)))) {
length += nbytes;
if (!convert) {
}
ap_MD5Update(&context, buf, nbytes);
}
- /* ZZZ use AP seek func instead of REWIND. */
lseek(infile, 0L, SEEK_SET);
return ap_md5contextTo64(p, &context);
}
int nbytes;
ap_MD5Init(&context);
- /* ZZZ use AP func instead of fread. */
while ((nbytes = read(infile, buf, sizeof(buf)))) {
length += nbytes;
ap_MD5Update(&context, buf, nbytes);
}
- /* ZZZ use AP seek func instead of REWIND. */
lseek(infile, 0L, SEEK_SET);
return ap_md5contextTo64(p, &context);
}
}
#endif
-/* ZZZ need to look at this in more depth and convert to an AP func so we
- can get rid of OS specific code.
- */
#if 0
API_EXPORT(int) ap_call_exec(request_rec *r, ap_child_info_t *pinfo, char *argv0,
char **env, int shellcmd)
static const char *get_addresses(ap_context_t *p, char *w, server_addr_rec ***paddr,
unsigned port)
{
- /* ZZZ redesign to use AP funcs and types. Will see what I can do to make it
- similar using posix std's. */
-
struct hostent *hep;
unsigned long my_addr;
server_addr_rec *sar;
fprintf(f, "VirtualHost configuration:\n");
for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
for (ic = iphash_table[i]; ic; ic = ic->next) {
- /* ZZZ should we change the Net addr to a string for this? */
if (ic->sar->host_port == 0) {
ap_snprintf(buf, sizeof(buf), "%pA:*", &ic->sar->host_addr);
}
/* compile the tables and such we need to do the run-time vhost lookups */
void ap_fini_vhost_config(ap_context_t *p, server_rec *main_s)
{
- /* ZZZ need to redesign for use with AP funcs. will look into this later.
- */
server_addr_rec *sar;
int has_default_vhost_addr;
server_rec *s;
* names we'll match have ports associated with them
*/
const char *host = r->hostname;
- /* ZZZ use AP func here. */
unsigned port = ntohs(r->connection->local_addr.sin_port);
server_rec *s;
server_rec *last_s;