You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2002/03/19 19:03:05 UTC

DO NOT REPLY [Bug 7252] New: - Should fopen() in this example really be ap_pfopen ()?

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7252>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7252

Should fopen() in this example really be ap_pfopen ()?

           Summary: Should fopen() in this example really be ap_pfopen ()?
           Product: Apache httpd-1.3
           Version: 1.3.23
          Platform: All
               URL: http://httpd.apache.org/docs/misc/API.html#resp_handlers
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Documentation
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: bernard.l.dubreuil@erdc.usace.army.mil


Maybe this is obvious to the experienced Apache programmer but in this example 
why is fopen() used to open the file and ap_pfclose() used to close it?

int default_handler (request_rec *r)
{
    int errstatus;
    FILE *f;

    if (r->method_number != M_GET) return DECLINED;
    if (r->finfo.st_mode == 0) return NOT_FOUND;

    if ((errstatus = ap_set_content_length (r, r->finfo.st_size))
    || (errstatus = ap_set_last_modified (r, r->finfo.st_mtime)))
        return errstatus;

    f = fopen (r->filename, "r");

    if (f == NULL) {
        log_reason("file permissions deny server access",
                   r->filename, r);
        return FORBIDDEN;
    }

    register_timeout ("send", r);
    ap_send_http_header (r);

    if (!r->header_only) send_fd (f, r);
    ap_pfclose (r->pool, f);
    return OK;
}