From: Roy T. Fielding Date: Thu, 26 Aug 1999 16:30:39 +0000 (+0000) Subject: Odd comments and leftover bits from the pthreads version. X-Git-Tag: PRE_APR_CHANGES~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44679abe2ba404d00965efc34483c68b58486cdb;p=apache Odd comments and leftover bits from the pthreads version. The comments really should be deleted, or at least cleaned up. Submitted by: pthreads leftovers git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83779 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_log.h b/include/http_log.h index d9162bd22f..5cd8498425 100644 --- a/include/http_log.h +++ b/include/http_log.h @@ -122,7 +122,7 @@ API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, __attribute__((format(printf,5,6))); API_EXPORT(void) ap_error_log2stderr (server_rec *); -void ap_log_pid (pool *p, char *fname); +void ap_log_pid (pool *p, const char *fname); /* These are for legacy code, new code should use ap_log_error, * or ap_log_rerror. */ diff --git a/modules/http/http_core.c b/modules/http/http_core.c index b8abc7693f..e8197e50ea 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -517,6 +517,8 @@ char *ap_response_code_string(request_rec *r, int error_index) /* Code from Harald Hanche-Olsen */ +/* 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; @@ -530,8 +532,8 @@ static ap_inline void do_double_reverse (conn_rec *conn) conn->double_reverse = -1; return; } - hptr = gethostbyname(conn->remote_host); - if (hptr) { + hptr = gethostbyname(conn->remote_host); /*ZZZ change to AP func */ + if (hptr) { /*ZZZ enumerate through host entries */ char **haddr; for (haddr = hptr->h_addr_list; *haddr; haddr++) { @@ -2503,7 +2505,7 @@ static int default_handler(request_rec *r) 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, r, "File does not exist: %s",r->path_info ? diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index e24b56e428..1e6d2e3cdf 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -310,6 +310,7 @@ API_EXPORT(int) ap_set_keepalive(request_rec *r) ((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)) && @@ -378,6 +379,7 @@ API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime) * 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; } @@ -403,6 +405,7 @@ API_EXPORT(int) ap_meets_conditions(request_rec *r) 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 diff --git a/modules/http/http_request.c b/modules/http/http_request.c index 4e4c0cffbc..f018f876b7 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -115,6 +115,8 @@ IMPLEMENT_HOOK_RUN_FIRST(int,auth_checker,(request_rec *r),(r),DECLINED) */ 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) @@ -287,6 +289,9 @@ static int get_path_info(request_rec *r) * even if they returned an error. */ 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; @@ -298,7 +303,7 @@ static int get_path_info(request_rec *r) --cp; } else { -#if defined(EACCES) +#if defined(EACCES) /* ZZZ again, AP error checking. */ if (errno != EACCES) #endif ap_log_rerror(APLOG_MARK, APLOG_ERR, r, @@ -437,7 +442,8 @@ static int directory_walk(request_rec *r) if (test_filename[test_filename_len - 1] == '/') --num_dirs; - if (S_ISDIR(r->finfo.st_mode)) + if (S_ISDIR(r->finfo.st_mode)) /* zzz use AP funcs and defines to make + this quicker */ ++num_dirs; /* @@ -572,7 +578,7 @@ static int directory_walk(request_rec *r) * 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) + if (!S_ISDIR(r->finfo.st_mode) /* ZZZ use AP funcs and defines */ && (res = check_symlinks(r->filename, ap_allow_options(r)))) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Symbolic link not allowed: %s", r->filename); @@ -858,6 +864,8 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, rnew->uri = ap_make_full_path(rnew->pool, udir, new_file); 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; } @@ -873,7 +881,8 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, * no matter what, if it's a subdirectory, we need to re-run * directory_walk */ - if (S_ISDIR(rnew->finfo.st_mode)) { + /* ZZZ use AP funcs and defines for this. */ + if (S_ISDIR(rnew->finfo.st_mode)) { res = directory_walk(rnew); if (!res) { res = file_walk(rnew); diff --git a/server/config.c b/server/config.c index 8bd9107949..d9f694c81d 100644 --- a/server/config.c +++ b/server/config.c @@ -1021,14 +1021,14 @@ void ap_process_resource_config(server_rec *s, const char *fname, pool *p, pool 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) + if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */ 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) + if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */ return; } @@ -1255,13 +1255,14 @@ static server_rec *init_server_config(pool *p) 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; + s->timeout = DEFAULT_TIMEOUT; /*ZZZ use AP default timeouts here*/ 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 */ diff --git a/server/log.c b/server/log.c index cc92cf3575..91d6f6fb11 100644 --- a/server/log.c +++ b/server/log.c @@ -185,7 +185,7 @@ static int error_log_child(void *cmd, child_info *pinfo) static void open_error_log(server_rec *s, pool *p) { - char *fname; + const char *fname; if (*s->error_fname == '|') { FILE *dummy; @@ -231,6 +231,7 @@ static void open_error_log(server_rec *s, pool *p) #endif else { fname = ap_server_root_relative(p, s->error_fname); + /* Change to AP funcs. */ if (!(s->error_log = ap_pfopen(p, fname, "a"))) { perror("fopen"); fprintf(stderr, "%s: could not open error log file %s.\n", @@ -296,6 +297,7 @@ static void log_error_core(const char *file, int line, int level, { char errstr[MAX_STRING_LEN]; size_t len; + /* change to AP errno funcs. */ int save_errno = errno; FILE *logf; @@ -390,6 +392,7 @@ static void log_error_core(const char *file, int line, int level, && !(level & APLOG_WIN32ERROR) #endif ) { + /* ZZZ use AP funcs to set the errno and the error string. */ len += ap_snprintf(errstr + len, sizeof(errstr) - len, "(%d)%s: ", save_errno, strerror(save_errno)); } @@ -442,6 +445,8 @@ static void log_error_core(const char *file, int line, int level, /* NULL if we are logging to syslog */ if (logf) { + /* ZZZ let's just use AP funcs to Write to the error log. If failure, + can we output a message to the console??? */ fputs(errstr, logf); fputc('\n', logf); fflush(logf); @@ -488,7 +493,7 @@ API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, va_end(args); } -void ap_log_pid(pool *p, char *fname) +void ap_log_pid(pool *p, const char *fname) { FILE *pid_file; struct stat finfo; @@ -501,7 +506,7 @@ void ap_log_pid(pool *p, char *fname) fname = ap_server_root_relative(p, fname); mypid = getpid(); if (mypid != saved_pid && stat(fname, &finfo) == 0) { - /* USR1 and HUP call this on each restart. + /* WINCH and HUP call this on each restart. * Only warn on first time through for this pid. * * XXX: Could just write first time through too, although @@ -557,6 +562,7 @@ API_EXPORT(void) ap_log_reason(const char *reason, const char *file, request_rec API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) { + /* Use AP funcs to output message and abort program. */ fprintf(stderr, "[%s] file %s, line %d, assertion \"%s\" failed\n", ap_get_time(), szFile, nLine, szExp); #ifndef WIN32 diff --git a/server/util.c b/server/util.c index a8b1d911aa..4770fcf51f 100644 --- a/server/util.c +++ b/server/util.c @@ -111,6 +111,8 @@ API_VAR_EXPORT const char ap_day_snames[7][4] = 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; @@ -142,6 +144,8 @@ API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype) API_EXPORT(char *) ap_ht_time(pool *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; @@ -849,7 +853,8 @@ API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name) errno = EACCES; return NULL; } - + + /* ZZZ bopenf and use AP defines for flags. */ file = ap_pfopen(p, name, "r"); #ifdef DEBUG saved_errno = errno; @@ -1643,6 +1648,7 @@ API_EXPORT(int) ap_is_directory(const char *path) { struct stat finfo; + /* ZZZ replace with AP File Info func. */ if (stat(path, &finfo) == -1) return 0; /* in error condition, just return no */ @@ -1917,6 +1923,7 @@ API_EXPORT(gid_t) ap_gname2id(const char *name) */ 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; @@ -1988,11 +1995,13 @@ char *ap_get_local_host(pool *a) char *server_hostname; struct hostent *p; -#ifdef BEOS /* BeOS returns zero as an error for gethostname */ - if (gethostname(str, sizeof(str) - 1) == 0) { -#else - if (gethostname(str, sizeof(str) - 1) != 0) { -#endif /* BeOS */ + /* ZZZ change to use AP funcs. */ +#ifdef BEOS + if (gethostname(str, sizeof(str) - 1) == 0) +#else + if (gethostname(str, sizeof(str) - 1) != 0) +#endif + { perror("Unable to gethostname"); exit(1); } diff --git a/server/vhost.c b/server/vhost.c index 8f5fc7d11a..d6443eab4a 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -167,6 +167,9 @@ void ap_init_vhost_config(pool *p) static const char *get_addresses(pool *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; @@ -470,6 +473,8 @@ static void dump_vhost_config(FILE *f) /* compile the tables and such we need to do the run-time vhost lookups */ void ap_fini_vhost_config(pool *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; @@ -774,6 +779,7 @@ static void check_hostalias(request_rec *r) * 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; @@ -833,6 +839,7 @@ static void check_serverpath(request_rec *r) server_rec *s; server_rec *last_s; name_chain *src; + /* use AP func here. */ unsigned port = ntohs(r->connection->local_addr.sin_port); /*