… | |
… | |
1701 | hc->init_byte_loc = 0; |
1701 | hc->init_byte_loc = 0; |
1702 | hc->end_byte_loc = -1; |
1702 | hc->end_byte_loc = -1; |
1703 | hc->keep_alive = 0; |
1703 | hc->keep_alive = 0; |
1704 | hc->should_linger = 0; |
1704 | hc->should_linger = 0; |
1705 | 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 |
1706 | return GC_OK; |
1710 | return GC_OK; |
1707 | } |
1711 | } |
1708 | |
1712 | |
1709 | |
1713 | |
1710 | /* 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; |
… | |
… | |
2351 | void |
2355 | void |
2352 | httpd_close_conn( httpd_conn* hc, struct timeval* nowP ) |
2356 | httpd_close_conn( httpd_conn* hc, struct timeval* nowP ) |
2353 | { |
2357 | { |
2354 | make_log_entry( hc, nowP ); |
2358 | make_log_entry( hc, nowP ); |
2355 | |
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 | { |
|
|
2368 | (void) free (hc->write_buf); |
|
|
2369 | hc->write_buf = 0; |
|
|
2370 | } |
|
|
2371 | #endif |
2356 | if ( hc->file_address != (char*) 0 ) |
2372 | if ( hc->file_address != (char*) 0 ) |
2357 | { |
2373 | { |
2358 | mmc_unmap( hc->file_address, &(hc->sb), nowP ); |
2374 | mmc_unmap( hc->file_address, &(hc->sb), nowP ); |
2359 | hc->file_address = (char*) 0; |
2375 | hc->file_address = (char*) 0; |
2360 | } |
2376 | } |
… | |
… | |
3609 | hc, 304, err304title, hc->encodings, "", hc->type, hc->sb.st_size, |
3625 | hc, 304, err304title, hc->encodings, "", hc->type, hc->sb.st_size, |
3610 | hc->sb.st_mtime ); |
3626 | hc->sb.st_mtime ); |
3611 | } |
3627 | } |
3612 | else |
3628 | else |
3613 | { |
3629 | { |
|
|
3630 | #ifdef MMAP_MAX |
|
|
3631 | if ( hc->sb.st_size < MMAP_MAX) |
|
|
3632 | #endif |
3614 | hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP ); |
3633 | hc->file_address = mmc_map( hc->expnfilename, &(hc->sb), nowP ); |
3615 | if ( hc->file_address == (char*) 0 ) |
3634 | if ( hc->file_address == (char*) 0 ) |
3616 | { |
3635 | { |
|
|
3636 | #ifdef MMAP_MAX |
|
|
3637 | hc->file_fd = open ( hc->expnfilename, O_RDONLY); |
|
|
3638 | hc->write_buf = malloc (WRITE_BUFFER); |
|
|
3639 | hc->write_ofs = WRITE_BUFFER; |
|
|
3640 | if ( hc->file_fd < 0 || !hc->write_buf ) |
|
|
3641 | #endif |
|
|
3642 | { |
3617 | httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); |
3643 | httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); |
3618 | return -1; |
3644 | return -1; |
|
|
3645 | } |
3619 | } |
3646 | } |
3620 | send_mime( |
3647 | send_mime( |
3621 | hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size, |
3648 | hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size, |
3622 | hc->sb.st_mtime ); |
3649 | hc->sb.st_mtime ); |
3623 | } |
3650 | } |