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>
The current shared_ptr implementation is efficient, but does not support
polymorphic types.
Rename it in order to make room for a polymorphic shared_ptr.
Tcp protects tcbs using a shared_ptr, but in some cases captures an
unprotected [this] in lambdas, which can outlive the shared_ptr.
Introduce and use enable_shared_from_this to fix.
Reviewed-by: Asias He <asias@cloudius-systems.com>
std::to_string() can also convert a floating-point argument to string,
using the "%f" printf format (see
http://en.cppreference.com/w/cpp/string/basic_string/to_string )
So add this support to our to_sstring() as well.
Note that if you want to use a different format, e.g., "%g", you can,
by using the to_sstring_sprintf function, for example
to_sstring_sprintf(12345678.9, "%g")
results in "1.23457e+07".
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Unfortunately at_exit() cannot be used to delete objects since when
it runs the reactor is still active and deleted object may still been used.
We need another API that runs its task after reactor is already stopped.
at_destroy() will be such api.
The constructor from "const char_type *" wouldn't really work when
char_type != char, because strlen() won't work on such pointers.
It is more convenient to have a constructor from an ordinary const char *
(e.g., a C string literal), and solve the type problem with an ugly cast.
This only makes sense when sizeof(char_type)==1 (i.e., it is char, unsigned
char, or signed char), but I think we make this assumption in other places
as well (e.g., in determining the size we need to allocate).
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
std::string has an operator[] to get access (read or modify) to one
character in the string. This patch adds the same operator for our
sstring.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
The basic_sstring<> template allows picking char_type - which instead of
being just "char" could be chosen to be something similar, like "unsigned char"
or "signed char".
Unfortunately some hard-coded uses of "char" were left in the code. This
did not cause any problems for existing code because of implicit conversions,
but it does cause problems once I try to implement operator[] when char_type
is not char. This results in an attempt to return a reference to the result
of a conversion, which is not allowed.
So this patch fixes the leftover uses of "char" to "char_type".
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Remove pre-poll-mode code, from Gleb:
"This series moves most of eventfd users to use other form of notification
which can be polled without entering the kernel and moving epoll in its own
poller which is enabled only if there is an fd that needs to be polled."
[avi: add -lrt to linker command line]
sstring's std::string conversion uses c_str() to construct the value,
but the conversion is broken if the value contains NUL - both sstring and
std::string can contain NULs, but C strings use them as a terminator.
Fix by using the size+length std::string constructor.
1) Make --dpdk-pmd parameter to be a flag instead of a (key, value).
2) Default to a default hugetlbfs DPDK settings when --hugepages is not
given and --dpdk-pmd is set.
This will allow a more friendly user experience in general and when one doesn't
want to provide a --hugepages parameter in particular.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
- Move the smp::dpdk_eal_init() code into the dpdk::eal::init() where it belongs.
- Removed the unused "opts" parameter of dpdk::dpdk_device constructor - all its usage
has been moved to dpdk::eal::init().
- Cleanup in reactor.cc: #if HAVE_DPDK -> #ifdef HAVE_DPDK; since we give a -DHAVE_DPDK
option to a compiler.
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
DPDK initialization creates its own threads and assumes that application
uses them, otherwise things do not work correctly (rte_lcore_id()
returns incorrect value for instance). This patch uses DPDK threads to
run seastar main loop making DPDK APIs work as expected.
register_poller() (and unregister_poller()) adjusts _pollers, but it may be
called while iterating it, and since std::vector<> mutations invalidate
iterators, corruption occurs.
Fix by deferring manipulation of _pollers into a task, which is executed at
a time where _pollers is not touched.
Currently, reactor::_pollers holds reactor::poller pointers; since these
are movable types, it's hard to maintain _pollers, as the pointers can keep
changing.
Refactor poller so that _pollers points at an internal type, which does not
move when a reactor::poller moves. This requires getting rid of
std::function, since it lacks a comparison operator.
When we have an object acting as resource guard for memory, we can convert
it into a deleter using
make_deleter([obj = std::move(obj)] {})
introduce a simpler interface
make_object_deleter(std::move(obj))
for doing the same thing.