--- thttpd/libhttpd.c 2001/06/29 13:08:08 1.1.4.2 +++ thttpd/libhttpd.c 2001/06/25 02:23:00 1.1.6.2 @@ -822,37 +822,6 @@ #endif /* ERR_DIR */ } -void -httpd_send_err_blocked( httpd_conn* hc ) - { -#ifdef ERR_DIR - - char filename[1000]; - - /* Try virtual host error page. */ - if ( hc->hs->vhost && hc->hostdir[0] != '\0' ) - { - (void) my_snprintf( filename, sizeof(filename), - "%s/%s/err403blocked.html", hc->hostdir, ERR_DIR ); - if ( send_err_file( hc, 403, err403title, "", filename ) ) - return; - } - - /* Try server-wide error page. */ - (void) my_snprintf( filename, sizeof(filename), - "%s/err403blocked.html", ERR_DIR ); - if ( send_err_file( hc, 403, err403title, "", filename ) ) - return; - - /* Fall back on built-in error page. */ - send_response( hc, 403, err403title, "", err403form, "" ); - -#else /* ERR_DIR */ - - send_response( hc, 403, err403title, "", err403form, "" ); - -#endif /* ERR_DIR */ - } #ifdef ERR_DIR static int @@ -1734,6 +1703,10 @@ hc->keep_alive = 0; hc->should_linger = 0; hc->file_address = (char*) 0; +#ifdef MMAP_MAX + hc->file_fd = -1; + hc->write_buf = (char*) 0; +#endif return GC_OK; } @@ -2384,6 +2357,15 @@ { make_log_entry( hc, nowP ); +#ifdef MMAP_MAX + if ( hc->file_fd >= 0) + { + (void) close( hc->file_fd ); + hc->file_fd = -1; + } + if ( hc->write_buf ) + (void) free (hc->write_buf); +#endif if ( hc->file_address != (char*) 0 ) { mmc_unmap( hc->file_address, &(hc->sb), nowP ); @@ -3642,11 +3624,22 @@ } else { - hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP ); +#ifdef MMAP_MAX + if ( hc->sb.st_size < MMAP_MAX) +#endif + hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP ); if ( hc->file_address == (char*) 0 ) { - httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); - return -1; +#ifdef MMAP_MAX + hc->file_fd = open ( hc->expnfilename, O_RDONLY); + hc->write_buf = malloc (WRITE_BUFFER); + hc->write_ofs = WRITE_BUFFER; + if ( hc->file_fd < 0 || !hc->write_buf ) +#endif + { + httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); + return -1; + } } send_mime( hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,