ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/thttpd/libhttpd.c
(Generate patch)

Comparing thttpd/libhttpd.c (file contents):
Revision 1.1.4.2 by root, Fri Jun 29 13:08:08 2001 UTC vs.
Revision 1.1.6.2 by root, Mon Jun 25 02:23:00 2001 UTC

820 send_response( hc, status, title, extraheads, form, arg ); 820 send_response( hc, status, title, extraheads, form, arg );
821 821
822#endif /* ERR_DIR */ 822#endif /* ERR_DIR */
823 } 823 }
824 824
825void
826httpd_send_err_blocked( httpd_conn* hc )
827 {
828#ifdef ERR_DIR
829
830 char filename[1000];
831
832 /* Try virtual host error page. */
833 if ( hc->hs->vhost && hc->hostdir[0] != '\0' )
834 {
835 (void) my_snprintf( filename, sizeof(filename),
836 "%s/%s/err403blocked.html", hc->hostdir, ERR_DIR );
837 if ( send_err_file( hc, 403, err403title, "", filename ) )
838 return;
839 }
840
841 /* Try server-wide error page. */
842 (void) my_snprintf( filename, sizeof(filename),
843 "%s/err403blocked.html", ERR_DIR );
844 if ( send_err_file( hc, 403, err403title, "", filename ) )
845 return;
846
847 /* Fall back on built-in error page. */
848 send_response( hc, 403, err403title, "", err403form, "" );
849
850#else /* ERR_DIR */
851
852 send_response( hc, 403, err403title, "", err403form, "" );
853
854#endif /* ERR_DIR */
855 }
856 825
857#ifdef ERR_DIR 826#ifdef ERR_DIR
858static int 827static int
859send_err_file( httpd_conn* hc, int status, char* title, char* extraheads, char* filename ) 828send_err_file( httpd_conn* hc, int status, char* title, char* extraheads, char* filename )
860 { 829 {
1732 hc->init_byte_loc = 0; 1701 hc->init_byte_loc = 0;
1733 hc->end_byte_loc = -1; 1702 hc->end_byte_loc = -1;
1734 hc->keep_alive = 0; 1703 hc->keep_alive = 0;
1735 hc->should_linger = 0; 1704 hc->should_linger = 0;
1736 hc->file_address = (char*) 0; 1705 hc->file_address = (char*) 0;
1706#ifdef MMAP_MAX
1707 hc->file_fd = -1;
1708 hc->write_buf = (char*) 0;
1709#endif
1737 return GC_OK; 1710 return GC_OK;
1738 } 1711 }
1739 1712
1740 1713
1741/* Checks hc->read_buf to see whether a complete request has been read so far; 1714/* Checks hc->read_buf to see whether a complete request has been read so far;
2382void 2355void
2383httpd_close_conn( httpd_conn* hc, struct timeval* nowP ) 2356httpd_close_conn( httpd_conn* hc, struct timeval* nowP )
2384 { 2357 {
2385 make_log_entry( hc, nowP ); 2358 make_log_entry( hc, nowP );
2386 2359
2360#ifdef MMAP_MAX
2361 if ( hc->file_fd >= 0)
2362 {
2363 (void) close( hc->file_fd );
2364 hc->file_fd = -1;
2365 }
2366 if ( hc->write_buf )
2367 (void) free (hc->write_buf);
2368#endif
2387 if ( hc->file_address != (char*) 0 ) 2369 if ( hc->file_address != (char*) 0 )
2388 { 2370 {
2389 mmc_unmap( hc->file_address, &(hc->sb), nowP ); 2371 mmc_unmap( hc->file_address, &(hc->sb), nowP );
2390 hc->file_address = (char*) 0; 2372 hc->file_address = (char*) 0;
2391 } 2373 }
3640 hc, 304, err304title, hc->encodings, "", hc->type, hc->sb.st_size, 3622 hc, 304, err304title, hc->encodings, "", hc->type, hc->sb.st_size,
3641 hc->sb.st_mtime ); 3623 hc->sb.st_mtime );
3642 } 3624 }
3643 else 3625 else
3644 { 3626 {
3627#ifdef MMAP_MAX
3628 if ( hc->sb.st_size < MMAP_MAX)
3629#endif
3645 hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP ); 3630 hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP );
3646 if ( hc->file_address == (char*) 0 ) 3631 if ( hc->file_address == (char*) 0 )
3647 { 3632 {
3633#ifdef MMAP_MAX
3634 hc->file_fd = open ( hc->expnfilename, O_RDONLY);
3635 hc->write_buf = malloc (WRITE_BUFFER);
3636 hc->write_ofs = WRITE_BUFFER;
3637 if ( hc->file_fd < 0 || !hc->write_buf )
3638#endif
3639 {
3648 httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); 3640 httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl );
3649 return -1; 3641 return -1;
3642 }
3650 } 3643 }
3651 send_mime( 3644 send_mime(
3652 hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size, 3645 hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size,
3653 hc->sb.st_mtime ); 3646 hc->sb.st_mtime );
3654 } 3647 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines