Tell all waiters that something bad happened and they should all go away.
Can be used only once; waiters should clean up and there must not be any
new waiters.
When size > align, we simply call the small allocator with the provided size,
but that does not guarantee any alignment above the default.
Round the allocation size to the nearest power of two in that case, to
guarantee alignment.
Calling state.get() will throw the exception instead of calling the function,
thus denying the called function the chance to deal with the exception.
Fix by constructing the future directly from state.
Currently we require that memory be freed on the same cpu it was allocated.
This does not impose difficulties on the user code, since our code is already
smp-unsafe, and so must use message-passing to run the destructor on the
origin cpu, so memory is naturally freed there as well.
However, library code does not run under our assumptions, specifically
std::exception_ptr, which we do transport across cores.
To support this use case, add low-performance support for cross-cpu frees,
using an atomic singly linked list per core.
It only supports -help at the moment. It is quite annoying to see:
$ ./httpd -h
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >'
what(): unrecognised option '-h'
Aborted
Support both -h and --help.
Throwing an exception may allocate memory, which we don't want to do
in the syscall thread pool (only reactor threads support allocation, for now).
Move the conversion of negative syscall results to exceptions to a separate
task, running in the reactor thread, to avoid this.
I am currently unable to use core/file.hh in a fresh include file. Type
conflicts arise, which probably don't happen in other existing files because
of existing includes that end up getting the environment all right beforehand.
FAILED: g++ -MMD -MT build/release/db/db.o -MF build/release/db/db.o.d -std=gnu++1y -g -Wall -Werror -fvisibility=hidden -pthread -I. -DHAVE_XEN -DHAVE_HWLOC -DHAVE_NUMA -O2 -I build/release/gen -c -o build/release/db/db.o db/db.cc
In file included from ./sstables.hh:4:0,
from ./database.hh:22,
from db/composites/composite.hh:27,
from db/db.cc:8:
./core/file.hh:35:64: error: ‘iovec’ was not declared in this scope
virtual future<size_t> write_dma(uint64_t pos, std::vector<iovec> iov) = 0;
Adding <sys/uio.h> to the include list of file.hh makes it includable (apparently) anywhere.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Directory listing support, using subscription<sstring> to represent the
stream of file names produced by the directory lister running in parallel
with the directory consumer.
open_directory() is similar to open_file_dma() with just the O_ flags adjusted.
list_directory() returns a subscription(), so that both the producer and
the consumer can be asynchronous.
Fix compilation errors in the shared_ptr pointer cast functions and
update shared_ptr constructor to take shared_ptr_count_base.
Suggested by Avi.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>