used posix_fadvise in lib/http-fil.c
This commit is contained in:
@ -408,7 +408,6 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
|
@ -610,6 +610,7 @@ static int open_peer (file_state_t* file_state, const mio_bch_t* actual_file)
|
||||
file_state_send_final_status_to_client (file_state, ERRNO_TO_STATUS_CODE(errno), 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case MIO_HTTP_PUT:
|
||||
@ -643,6 +644,14 @@ static int open_peer (file_state_t* file_state, const mio_bch_t* actual_file)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static MIO_INLINE void fadvise_on_peer (file_state_t* file_state)
|
||||
{
|
||||
#if defined(HAVE_POSIX_FADVISE)
|
||||
if (file_state->req_method == MIO_HTTP_GET)
|
||||
posix_fadvise (file_state->peer, file_state->start_offset, file_state->end_offset - file_state->start_offset + 1, POSIX_FADV_SEQUENTIAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int mio_svc_htts_dofile (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* req, const mio_bch_t* docroot, const mio_bch_t* file)
|
||||
{
|
||||
mio_t* mio = htts->mio;
|
||||
@ -682,6 +691,8 @@ int mio_svc_htts_dofile (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t*
|
||||
if (open_peer(file_state, actual_file) <= -1 ||
|
||||
process_range_header(file_state, req) <= -1) goto oops;
|
||||
|
||||
fadvise_on_peer (file_state);
|
||||
|
||||
#if !defined(FILE_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||
if (file_state->req_content_length_unlimited)
|
||||
{
|
||||
|
@ -376,6 +376,9 @@
|
||||
/* Define to 1 if you have the <openssl/ssl.h> header file. */
|
||||
#undef HAVE_OPENSSL_SSL_H
|
||||
|
||||
/* Define to 1 if you have the `posix_fadvise' function. */
|
||||
#undef HAVE_POSIX_FADVISE
|
||||
|
||||
/* Define to 1 if you have the `posix_spawn' function. */
|
||||
#undef HAVE_POSIX_SPAWN
|
||||
|
||||
|
Reference in New Issue
Block a user