LLFIO
v2.00
|
A handle to a TLS secure socket-like entity. More...
#include "tls_socket_handle.hpp"
Public Types | |
enum | shutdown_kind { shutdown_read , shutdown_write , shutdown_both } |
The channels which can be shut down. More... | |
using | path_type = byte_io_handle::path_type |
using | extent_type = byte_io_handle::extent_type |
using | size_type = byte_io_handle::size_type |
using | mode = byte_io_handle::mode |
using | creation = byte_io_handle::creation |
using | caching = byte_io_handle::caching |
using | flag = byte_io_handle::flag |
using | buffer_type = byte_io_handle::buffer_type |
using | const_buffer_type = byte_io_handle::const_buffer_type |
using | buffers_type = byte_io_handle::buffers_type |
using | const_buffers_type = byte_io_handle::const_buffers_type |
template<class T > | |
using | io_request = byte_io_handle::io_request< T > |
template<class T > | |
using | io_result = byte_io_handle::io_result< T > |
using | barrier_kind = byte_io_multiplexer::barrier_kind |
using | registered_buffer_type = byte_io_multiplexer::registered_buffer_type |
template<class T > | |
using | awaitable = byte_io_multiplexer::awaitable< T > |
Public Member Functions | |
virtual std::string | algorithms_description () const =0 |
Returns an implementation defined string describing the algorithms either to be chosen during connection, or if after connection the algorithms chosen. Can be an empty string if the implementation currently has no mechanism for determining the algorithms available or in use (if the latter you may wish to retry later). | |
virtual result< void > | set_registered_buffer_chunk_size (size_t bytes) noexcept=0 |
Sets the chunk size for registered buffer allocation. More... | |
virtual result< void > | set_algorithms (tls_algorithm set) noexcept=0 |
Sets the algorithms to be used by the TLS connection. | |
virtual result< void > | set_authentication_certificates_path (path_view identifier) noexcept=0 |
Sets the CA certificates by which this connecting socket identifies itself to servers. Defaults to empty i.e. clients do not authenticate themselves to servers. More... | |
virtual result< string_view > | set_connect_hostname (string_view host, uint16_t port) noexcept=0 |
Sets the name of the server which will be connected to for TLS. More... | |
result< void > | connect (string_view host, uint16_t port, deadline d={}) noexcept |
Connects to a host, setting the TLS connetion hostname. Convenience overload. More... | |
awaitable< io_result< void > > | co_connect (string_view host, uint16_t port, deadline d={}) noexcept |
A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle! More... | |
awaitable< io_result< void > > | co_connect (const ip::address &addr, deadline d={}) noexcept |
A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle! More... | |
result< void > | connect (const ip::address &addr, deadline d={}) noexcept |
Connects to an address. More... | |
virtual void | _deleter () |
void | swap (byte_socket_handle &o) noexcept |
Swap with another instance. | |
void | swap (handle &o) noexcept |
Swap with another instance. | |
ip::family | family () const noexcept |
Returns the IP family of this socket instance. | |
virtual result< ip::address > | local_endpoint () const noexcept |
Returns the local endpoint of this socket instance. | |
virtual result< ip::address > | remote_endpoint () const noexcept |
Returns the remote endpoint of this socket instance. | |
virtual result< void > | shutdown (shutdown_kind=shutdown_write) noexcept |
Initiates shutting down further communication on the socket. More... | |
result< void > | connect (const ip::address &addr, deadline d={}) noexcept |
Connects to an address. More... | |
awaitable< io_result< void > > | co_connect (const ip::address &addr, deadline d={}) noexcept |
A coroutinised equivalent to .connect() which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect() if no i/o multiplexer has been set on this handle! More... | |
virtual result< void > | close () noexcept override |
Immediately close the native handle type managed by this handle. | |
result< void > | shutdown_and_close (deadline d={}) noexcept |
Convenience function to shut down the outbound connection and wait for the other side to shut down our inbound connection by throwing away any bytes read, then closing the socket. Note that if the deadline passes and we are still reading data, the socket is forced closed. | |
io_result< size_type > | read (std::initializer_list< buffer_type > lst, deadline d=deadline()) noexcept |
io_result< buffers_type > | read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
io_result< buffers_type > | read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
io_result< size_type > | read (extent_type offset, std::initializer_list< buffer_type > lst, deadline d=deadline()) noexcept |
io_result< buffers_type > | read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
io_result< buffers_type > | read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
io_result< size_type > | read (extent_type offset, std::initializer_list< buffer_type > lst, deadline d=deadline()) noexcept |
io_result< size_type > | write (std::initializer_list< const_buffer_type > lst, deadline d=deadline()) noexcept |
io_result< const_buffers_type > | write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
io_result< const_buffers_type > | write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
io_result< size_type > | write (extent_type offset, std::initializer_list< const_buffer_type > lst, deadline d=deadline()) noexcept |
io_result< const_buffers_type > | write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
io_result< const_buffers_type > | write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
io_result< size_type > | write (extent_type offset, std::initializer_list< const_buffer_type > lst, deadline d=deadline()) noexcept |
awaitable< io_result< buffers_type > > | co_read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
A coroutinised equivalent to .read() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read() if no i/o multiplexer has been set on this handle! More... | |
awaitable< io_result< buffers_type > > | co_read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
awaitable< io_result< buffers_type > > | co_read (io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
A coroutinised equivalent to .read() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read() if no i/o multiplexer has been set on this handle! More... | |
awaitable< io_result< buffers_type > > | co_read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d=deadline()) noexcept |
awaitable< io_result< const_buffers_type > > | co_write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
A coroutinised equivalent to .write() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write() if no i/o multiplexer has been set on this handle! More... | |
awaitable< io_result< const_buffers_type > > | co_write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
awaitable< io_result< const_buffers_type > > | co_write (io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
A coroutinised equivalent to .write() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write() if no i/o multiplexer has been set on this handle! More... | |
awaitable< io_result< const_buffers_type > > | co_write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d=deadline()) noexcept |
byte_io_multiplexer * | multiplexer () const noexcept |
The i/o multiplexer this handle will use to multiplex i/o. If this returns null, then this handle has not been registered with an i/o multiplexer yet. | |
virtual result< void > | set_multiplexer (byte_io_multiplexer *c=this_thread::multiplexer()) noexcept |
Sets the i/o multiplexer this handle will use to implement read() , write() and barrier() . More... | |
size_t | max_buffers () const noexcept |
The maximum number of buffers which a single read or write syscall can (atomically) process at a time for this specific open handle. On POSIX, this is known as IOV_MAX . Preferentially uses any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
result< registered_buffer_type > | allocate_registered_buffer (size_t &bytes) noexcept |
Request the allocation of a new registered i/o buffer with the system suitable for maximum performance i/o, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
template<class... Args> | |
bool | try_read (Args &&... args) noexcept |
template<class... Args, class Rep , class Period > | |
bool | try_read_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept |
template<class... Args, class Clock , class Duration > | |
bool | try_read_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept |
template<class... Args> | |
bool | try_write (Args &&... args) noexcept |
template<class... Args, class Rep , class Period > | |
bool | try_write_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept |
template<class... Args, class Clock , class Duration > | |
bool | try_write_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept |
virtual io_result< const_buffers_type > | barrier (io_request< const_buffers_type > reqs=io_request< const_buffers_type >(), barrier_kind kind=barrier_kind::nowait_data_only, deadline d=deadline()) noexcept |
Issue a write reordering barrier such that writes preceding the barrier will reach storage before writes after this barrier, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation. More... | |
io_result< const_buffers_type > | barrier (barrier_kind kind, deadline d=deadline()) noexcept |
template<class... Args> | |
bool | try_barrier (Args &&... args) noexcept |
template<class... Args, class Rep , class Period > | |
bool | try_barrier_for (Args &&... args, const std::chrono::duration< Rep, Period > &duration) noexcept |
template<class... Args, class Clock , class Duration > | |
bool | try_barrier_until (Args &&... args, const std::chrono::time_point< Clock, Duration > &timeout) noexcept |
awaitable< io_result< const_buffers_type > > | co_barrier (io_request< const_buffers_type > reqs=io_request< const_buffers_type >(), barrier_kind kind=barrier_kind::nowait_data_only, deadline d=deadline()) noexcept |
A coroutinised equivalent to .barrier() which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .barrier() if no i/o multiplexer has been set on this handle! More... | |
flag | flags () const noexcept |
The flags this handle was opened with. | |
QUICKCPPLIB_BITFIELD_BEGIN_T (flag, uint16_t) | |
Bitwise flags which can be specified. More... | |
virtual result< path_type > | current_path () const noexcept |
result< handle > | clone () const noexcept |
virtual native_handle_type | release () noexcept |
Release the native handle type managed by this handle. | |
bool | is_valid () const noexcept |
True if the handle is valid (and usually open) | |
bool | is_readable () const noexcept |
True if the handle is readable. | |
bool | is_writable () const noexcept |
True if the handle is writable. | |
bool | is_append_only () const noexcept |
True if the handle is append only. | |
virtual result< void > | set_append_only (bool enable) noexcept |
EXTENSION: Changes whether this handle is append only or not. More... | |
bool | is_multiplexable () const noexcept |
True if multiplexable. | |
bool | is_nonblocking () const noexcept |
True if nonblocking. | |
bool | is_seekable () const noexcept |
True if seekable. | |
bool | requires_aligned_io () const noexcept |
True if requires aligned i/o. | |
bool | is_kernel_handle () const noexcept |
True if native_handle() is a valid kernel handle. | |
bool | is_regular () const noexcept |
True if a regular file or device. | |
bool | is_directory () const noexcept |
True if a directory. | |
bool | is_symlink () const noexcept |
True if a symlink. | |
bool | is_pipe () const noexcept |
True if a pipe. | |
bool | is_socket () const noexcept |
True if a socket. | |
bool | is_multiplexer () const noexcept |
True if a multiplexer like BSD kqueues, Linux epoll or Windows IOCP. | |
bool | is_process () const noexcept |
True if a process. | |
bool | is_section () const noexcept |
True if a memory section. | |
bool | is_allocation () const noexcept |
True if a memory allocation. | |
bool | is_path () const noexcept |
True if a path or a directory. | |
bool | is_tls_socket () const noexcept |
True if a TLS socket. | |
bool | is_http_socket () const noexcept |
True if a HTTP socket. | |
caching | kernel_caching () const noexcept |
Kernel cache strategy used by this handle. | |
bool | are_reads_from_cache () const noexcept |
True if the handle uses the kernel page cache for reads. | |
bool | are_writes_durable () const noexcept |
True if writes are safely on storage on completion. | |
bool | are_safety_barriers_issued () const noexcept |
True if issuing safety fsyncs is on. | |
native_handle_type | native_handle () const noexcept |
The native handle used by this handle. | |
Static Public Member Functions | |
static result< byte_socket_handle > | byte_socket (ip::family family, mode _mode=mode::write, caching _caching=caching::all, flag flags=flag::none) noexcept |
static result< byte_socket_handle > | multiplexable_byte_socket (ip::family family, mode _mode=mode::write, caching _caching=caching::all, flag flags=flag::multiplexable) noexcept |
Convenience function defaulting flag::multiplexable set. | |
Protected Member Functions | |
tls_socket_handle & | operator= (tls_socket_handle &&)=default |
tls_socket_handle (byte_socket_handle &&sock) | |
constexpr | byte_socket_handle () |
Default constructor. | |
constexpr | byte_socket_handle (native_handle_type h, flag flags, byte_io_multiplexer *ctx) |
Construct a handle from a supplied native handle. | |
byte_socket_handle (const byte_socket_handle &)=delete | |
No copy construction (use clone()) | |
constexpr | byte_socket_handle (byte_socket_handle &&o) noexcept |
Implicit move construction of byte_socket_handle permitted. | |
constexpr | byte_socket_handle (handle &&o, byte_io_multiplexer *ctx) noexcept |
Explicit conversion from handle permitted. | |
constexpr | byte_socket_handle (byte_io_handle &&o) noexcept |
Explicit conversion from byte_io_handle permitted. | |
virtual result< void > | _do_connect (const ip::address &addr, deadline d) noexcept |
result< void > | _do_multiplexer_connect (const ip::address &addr, deadline d) noexcept |
virtual size_t | _do_max_buffers () const noexcept |
The virtualised implementation of max_buffers() used if no multiplexer has been set. | |
virtual result< registered_buffer_type > | _do_allocate_registered_buffer (size_t &bytes) noexcept |
The virtualised implementation of allocate_registered_buffer() used if no multiplexer has been set. | |
virtual io_result< buffers_type > | _do_read (io_request< buffers_type > reqs, deadline d) noexcept |
The virtualised implementation of read() used if no multiplexer has been set. | |
virtual io_result< buffers_type > | _do_read (registered_buffer_type base, io_request< buffers_type > reqs, deadline d) noexcept |
The virtualised implementation of read() used if no multiplexer has been set. | |
virtual io_result< const_buffers_type > | _do_write (io_request< const_buffers_type > reqs, deadline d) noexcept |
The virtualised implementation of write() used if no multiplexer has been set. | |
virtual io_result< const_buffers_type > | _do_write (registered_buffer_type base, io_request< const_buffers_type > reqs, deadline d) noexcept |
The virtualised implementation of write() used if no multiplexer has been set. | |
virtual io_result< const_buffers_type > | _do_barrier (io_request< const_buffers_type > reqs, barrier_kind kind, deadline d) noexcept |
The virtualised implementation of barrier() used if no multiplexer has been set. | |
io_result< buffers_type > | _do_multiplexer_read (registered_buffer_type &&base, io_request< buffers_type > reqs, deadline d) noexcept |
io_result< const_buffers_type > | _do_multiplexer_write (registered_buffer_type &&base, io_request< const_buffers_type > reqs, deadline d) noexcept |
io_result< const_buffers_type > | _do_multiplexer_barrier (registered_buffer_type &&base, io_request< const_buffers_type > reqs, barrier_kind kind, deadline d) noexcept |
Protected Attributes | |
byte_io_multiplexer * | _ctx {nullptr} |
union { | |
native_handle_type _v | |
struct { | |
intptr_t _padding0_ | |
uint32_t _padding1_ | |
flag flags | |
uint16_t _padding2_ | |
} _ | |
}; | |
A handle to a TLS secure socket-like entity.
As you cannot create one of these on your own, one generally acquires one of these from a tls_socket_source
.
|
inherited |
The channels which can be shut down.
Enumerator | |
---|---|
shutdown_read | Shutdown further reads. |
shutdown_write | Shutdown further writes. |
shutdown_both | Shutdown both further reads and writes. |
|
inlinenoexceptinherited |
Request the allocation of a new registered i/o buffer with the system suitable for maximum performance i/o, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
bytes | The size of the i/o buffer requested. This may be rounded (considerably) upwards, you should always use the value returned. |
Some i/o multiplexer implementations have the ability to allocate i/o buffers in special memory shared between the i/o hardware and user space processes. Using registered i/o buffers can entirely eliminate all kernel transitions and memory copying during i/o, and can saturate very high end hardware from a single kernel thread.
If no multiplexer is set, the default implementation uses map_handle
to allocate raw memory pages from the OS kernel. If the requested buffer size is a multiple of one of the larger page sizes from utils::page_sizes()
, an attempt to satisfy the request using the larger page size will be attempted first.
|
inlinevirtualnoexceptinherited |
Issue a write reordering barrier such that writes preceding the barrier will reach storage before writes after this barrier, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
caching::reads
which means that all writes form a strict sequential order not completing until acknowledged by the storage device. Filing system can and do use different algorithms to give much better performance with caching::reads
, some (e.g. ZFS) spectacularly better.reqs | A scatter-gather and offset request for what range to barrier. May be ignored on some platforms which always write barrier the entire file. Supplying a default initialised reqs write barriers the entire file. |
kind | Which kind of write reordering barrier to perform. |
d | An optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel. |
|
inlinestaticnoexceptinherited |
Create a socket handle.
family | Which IP family to create the socket in. |
_mode | How to open the socket. If this is mode::append , the read side of the socket is shutdown; if this is mode::read , the write side of the socket is shutdown. |
_caching | How to ask the kernel to cache the socket. If writes are not cached, SO_SNDBUF to the minimum possible value and TCP_NODELAY is set, this should cause writes to hit the network as quickly as possible. |
flags | Any additional custom behaviours. |
|
inlinenoexceptinherited |
Clone this handle (copy constructor is disabled to avoid accidental copying)
|
inlinenoexceptinherited |
A coroutinised equivalent to .barrier()
which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .barrier()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
noexceptinherited |
A coroutinised equivalent to .connect()
which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
A coroutinised equivalent to .connect()
which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
noexcept |
A coroutinised equivalent to .connect()
which suspends the coroutine until a connection occurs. Blocks execution i.e is equivalent to .connect()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
inlinenoexceptinherited |
A coroutinised equivalent to .read()
which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
A coroutinised equivalent to .read()
which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .read()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
inlinenoexceptinherited |
A coroutinised equivalent to .write()
which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
inlinenoexceptinherited |
A coroutinised equivalent to .write()
which suspends the coroutine until the i/o finishes. Blocks execution i.e is equivalent to .write()
if no i/o multiplexer has been set on this handle!
The awaitable returned is eager i.e. it immediately begins the i/o. If the i/o completes and finishes immediately, no coroutine suspension occurs.
|
inlinenoexceptinherited |
Connects to an address.
addr | The address to connect to. |
d | How long to wait for a connection. |
The connection begins upon first call, if it times out then you can call this function again with a new timeout to poll the socket for when it connects. Eventually this function will either succeed, or fail with an error if the connection failed.
|
inlinenoexcept |
Connects to an address.
addr | The address to connect to. |
d | How long to wait for a connection. |
The connection begins upon first call, if it times out then you can call this function again with a new timeout to poll the socket for when it connects. Eventually this function will either succeed, or fail with an error if the connection failed.
|
inlinenoexcept |
Connects to a host, setting the TLS connetion hostname. Convenience overload.
host | The hostname to connect to. The TLS connection will use this hostname. |
port | The port to connect to. The TLS connection will use this port. |
d | How long to wait for a connection. |
This is a convenience overload combining set_connect_hostname()
and connect()
from the base class.
|
inlinevirtualnoexceptinherited |
Returns the current path of the open handle as said by the operating system. Note that you are NOT guaranteed that any path refreshed bears any resemblance to the original, some operating systems will return some different path which still reaches the same inode via some other route e.g. hardlinks, dereferenced symbolic links, etc. Windows and Linux correctly track changes to the specific path the handle was opened with, not getting confused by other hard links. MacOS nearly gets it right, but under some circumstances e.g. renaming may switch to a different hard link's path which is almost certainly a bug.
If LLFIO was not able to determine the current path for this open handle e.g. the inode has been unlinked, it returns an empty path. Be aware that FreeBSD can return an empty (deleted) path for file inodes no longer cached by the kernel path cache, LLFIO cannot detect the difference. FreeBSD will also return any path leading to the inode if it is hard linked. FreeBSD does implement path retrieval for directory inodes correctly however, and see algorithm::cached_parent_handle_adapter<T>
for a handle adapter which makes use of that.
On Linux if /proc
is not mounted, this call fails with an error. All APIs in LLFIO which require the use of current_path()
can be told to not use it e.g. flag::disable_safety_unlinks
. It is up to you to detect if current_path()
is not working, and to change how you call LLFIO appropriately.
On Windows, you will almost certainly get back a path of the form \!!\Device\HarddiskVolume10\Users\ned\...
. See path_view
for what all the path prefix sequences mean, but to summarise the \!!\
prefix is LLFIO-only and will not be accepted by other Windows APIs. Pass LLFIO derived paths through the function to_win32_path()
to Win32-ise them. This function is also available on Linux where it does nothing, so you can use it in portable code.
path_handle
to fix a base location on the file system and work from that anchor instead!algorithm::cached_parent_handle_adapter<T>
which overrides this with an implementation based on retrieving the current path of a cached handle to the parent directory. On platforms with instability or failure to retrieve the correct current path for regular files, the cached parent handle adapter works around the problem by taking advantage of directory inodes not having the same instability problems on any platform. Reimplemented in llfio_v2_xxx::symlink_handle, and llfio_v2_xxx::process_handle.
|
inlinenoexceptinherited |
The maximum number of buffers which a single read or write syscall can (atomically) process at a time for this specific open handle. On POSIX, this is known as IOV_MAX
. Preferentially uses any i/o multiplexer set over the virtually overridable per-class implementation.
Note that the actual number of buffers accepted for a read or a write may be significantly lower than this system-defined limit, depending on available resources. The read()
or write()
call will return the buffers accepted at the time of invoking the syscall.
Note also that some OSs will error out if you supply more than this limit to read()
or write()
, but other OSs do not. Some OSs guarantee that each i/o syscall has effects atomically visible or not to other i/o, other OSs do not.
OS X does not implement scatter-gather file i/o syscalls. Thus this function will always return 1
in that situation.
Microsoft Windows may implement scatter-gather i/o under certain handle configurations. Most of the time for non-socket handles this function will return 1
.
For handles which implement i/o entirely in user space, and thus syscalls are not involved, this function will return 0
.
|
inlineinherited |
Bitwise flags which can be specified.
< No flags
Unlinks the file on handle close. On POSIX, this simply unlinks whatever is pointed to by path()
upon the call of close()
if and only if the inode matches. On Windows, if you are on Windows 10 1709 or later, exactly the same thing occurs. If on previous editions of Windows, the file entry does not disappears but becomes unavailable for anyone else to open with an errc::resource_unavailable_try_again
error return. Because this is confusing, unless the win_disable_unlink_emulation
flag is also specified, this POSIX behaviour is somewhat emulated by LLFIO on older Windows by renaming the file to a random name on close()
causing it to appear to have been unlinked immediately.
Some kernel caching modes have unhelpfully inconsistent behaviours in getting your data onto storage, so by default unless this flag is specified LLFIO adds extra fsyncs to the following operations for the caching modes specified below: truncation of file length either explicitly or during file open. closing of the handle either explicitly or in the destructor.
Additionally on Linux only to prevent loss of file metadata: On the parent directory whenever a file might have been created. On the parent directory on file close.
This only occurs for these kernel caching modes: caching::none caching::reads caching::reads_and_metadata caching::safety_barriers
file_handle::unlink()
could accidentally delete the wrong file if someone has renamed the open file handle since the time it was opened. To prevent this occuring, where the OS doesn't provide race free unlink-by-open-handle we compare the inode of the path we are about to unlink with that of the open handle before unlinking.
Ask the OS to disable prefetching of data. This can improve random i/o performance.
Ask the OS to maximise prefetching of data, possibly prefetching the entire file into kernel cache. This can improve sequential i/o performance.
< See the documentation for unlink_on_first_close
Microsoft Windows NTFS, having been created in the late 1980s, did not originally implement extents-based storage and thus could only represent sparse files via efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000), a proper extents-based on-storage representation was added, thus allowing only 64Kb extent chunks written to be stored irrespective of whatever the maximum file extent was set to.
For various historical reasons, extents-based storage is disabled by default in newly created files on NTFS, unlike in almost every other major filing system. You have to explicitly "opt in" to extents-based storage.
As extents-based storage is nearly cost free on NTFS, LLFIO by default opts in to extents-based storage for any empty file it creates. If you don't want this, you can specify this flag to prevent that happening.
Filesystems tend to be embarrassingly parallel for operations performed to different inodes. Where LLFIO performs i/o to multiple inodes at a time, it will use OpenMP or the Parallelism or Concurrency standard library extensions to usually complete the operation in constant rather than linear time. If you don't want this default, you can disable default using this flag.
Microsoft Windows NTFS has the option, when creating a directory, to set whether leafname lookup will be case sensitive. This is the only way of getting exact POSIX semantics on Windows without resorting to editing the system registry, however it also affects all code doing lookups within that directory, so we must default it to off.
Create the handle in a way where i/o upon it can be multiplexed with other i/o on the same initiating thread of execution i.e. you can perform more than one read concurrently, without using threads. The blocking operations .read()
and .write()
may have to use a less efficient, but cancellable, blocking implementation for handles created in this way. On Microsoft Windows, this creates handles with OVERLAPPED
semantics. On POSIX, this creates handles with nonblocking semantics for non-file handles such as pipes and sockets, however for file, directory and symlink handles it does not set nonblocking, as it is non-portable.
< Using insane POSIX byte range locks
< This is an inode created with no representation on the filing system
|
inlinenoexceptinherited |
Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
reqs | A scatter-gather and offset request. |
d | An optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel. |
|
inlinenoexceptinherited |
Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
reqs | A scatter-gather and offset request. |
d | An optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel. |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinevirtualnoexceptinherited |
EXTENSION: Changes whether this handle is append only or not.
Reimplemented in llfio_v2_xxx::process_handle.
|
pure virtualnoexcept |
Sets the CA certificates by which this connecting socket identifies itself to servers. Defaults to empty i.e. clients do not authenticate themselves to servers.
Note that setting this to an empty path disables authentication by the client, so client impersonation attacks become possible. This can be useful however for situations where setting up client authentication certificates is non-trivial or unnecessary (e.g. a HTTPS client connecting to a HTTPS web service), and all that is wanted is an encrypted network transport.
Be aware that the path may not be a filesystem path, but some other sort of implementation defined identifier.
|
pure virtualnoexcept |
Sets the name of the server which will be connected to for TLS.
host | The hostname to connect to. The TLS connection will use this hostname. |
port | The port to connect to. The TLS connection will use this port. |
TLS requires the hostname and port to which it will connect for identity verification. This can be different to the actual IP address to which you connect, if you wish.
If you don't call this before connect()
(or don't use the connect()
overload also taking host
and port
), then the client will NOT authenticate the server's certificate.
|
inlinevirtualnoexceptinherited |
Sets the i/o multiplexer this handle will use to implement read()
, write()
and barrier()
.
Note that this call deregisters this handle from any existing i/o multiplexer, and registers it with the new i/o multiplexer. You must therefore not call it if any i/o is currently outstanding on this handle. You should also be aware that multiple dynamic memory allocations and deallocations may occur, as well as multiple syscalls (i.e. this is an expensive call, try to do it from cold code).
If the handle was not created as multiplexable, this call always fails.
Reimplemented in llfio_v2_xxx::mapped_file_handle.
|
pure virtualnoexcept |
Sets the chunk size for registered buffer allocation.
Some TLS socket handle implementations are able to use registered buffers from their underlying plain socket. If so, this sets the granularity of registered buffer allocation, otherwise an error is returned if registered buffers are not supported.
|
inlinevirtualnoexceptinherited |
Initiates shutting down further communication on the socket.
The default is shutdown_write
, as generally if shutting down you want send a FIN packet to remote and loop polling reads until you receive a FIN from remote.
|
inlinenoexceptinherited |
Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
truncate(newsize)
first.reqs | A scatter-gather and offset request. |
d | An optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel. |
|
inlinenoexceptinherited |
Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overridable per-class implementation.
truncate(newsize)
first.reqs | A scatter-gather and offset request. |
d | An optional deadline by which the i/o must complete, else it is cancelled. Note function may return significantly after this deadline if the i/o takes long to cancel. |
|
inlinenoexceptinherited |