9 #if defined( RESTINIO_FREEBSD_TARGET ) || defined( RESTINIO_MACOS_TARGET ) 12 #include <sys/sendfile.h> 26 template <
typename Socket >
44 #if defined( RESTINIO_FREEBSD_TARGET ) || defined( RESTINIO_MACOS_TARGET ) 50 if(
static_cast<
off_t >( -1 ) !=
n )
77 auto const n = ::
read(
136 return [
this, ctx =
this->shared_from_this()]
138 (
const asio_ns::error_code & ec, std::size_t written )
noexcept 142 this->m_remained_size -= written;
143 this->m_transfered_size += written;
144 if( 0 ==
this->m_remained_size )
146 this->m_after_sendfile_cb(
148 this->m_transfered_size );
152 this->init_next_write();
157 this->m_after_sendfile_cb(
159 this->m_transfered_size );
194 #if defined( RESTINIO_FREEBSD_TARGET ) 215 #if __FreeBSD__ >= 11
236 #elif defined( RESTINIO_MACOS_TARGET ) 246 static_cast<
off_t >(
347 if( !try_turn_non_blocking_mode() )
355 if( 0 == m_remained_size )
360 (
void)try_initiate_waiting_for_write_readiness();
364 const auto n = call_native_sendfile();
368 if( errno == EAGAIN || errno == EINTR )
370 if( !try_initiate_waiting_for_write_readiness() )
377 errno, asio_ns::error::get_system_category() },
387 (
void)try_initiate_waiting_for_write_readiness();
392 m_remained_size -=
static_cast< file_size_t >( n );
393 m_transfered_size +=
static_cast< file_size_t >( n );
void init_next_write() noexcept
sendfile_operation_runner_t(const sendfile_operation_runner_t &)=delete
virtual void start() override
void init_next_write() noexcept
sendfile_operation_runner_t(sendfile_operation_runner_t &&)=delete
A runner of sendfile operation.
sendfile_operation_runner_t(sendfile_operation_runner_t &&)=delete
sendfile_operation_runner_t(const sendfile_operation_runner_t &)=delete
auto make_async_write_handler() noexcept
Helper method for making a lambda for async_write completion handler.
sendfile_operation_runner_t & operator=(sendfile_operation_runner_t &&)=delete
sendfile_operation_runner_t & operator=(sendfile_operation_runner_t &&)=delete
virtual void start() override
RESTINIO_NODISCARD bool try_initiate_waiting_for_write_readiness() noexcept
RESTINIO_NODISCARD char to_lower_case(unsigned char ch)
std::unique_ptr< char[] > m_buffer
sendfile_operation_runner_t & operator=(const sendfile_operation_runner_t &)=delete
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, optional_t< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in optional_t<Value_Type> if parameter exists ...
sendfile_operation_runner_t & operator=(const sendfile_operation_runner_t &)=delete