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.
Terminate a running memcached instance with a SIGTERM instead of a
SIGKILL to allow the process to close in a cleaner manner
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
A user may be waiting for data, but we never we never notify them if we
receive an RST. As a result the tcb, connection, and any user data structures
will hang around in memory.
Fix by notifying the user if they are waiting, and marking the connection as
nuked so they don't try to read again.
Reviewed-by: Asias He <asias@cloudius-systems.com>
This is not 1:1 conversion because some Term inner classes derive from
Term itself which is not allowed in C++. I therefore moved some of the
inner class definitions outside of Term.
Another painpoint is Terminal.bind() method which returns 'this'. I
changed the API to require callers to pass shared_ptr<terminal> which is
returned in place of 'this'. I went for shared_ptr because I wasn't able
to convince myself that the lifetime rules allow unique_ptr...
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
There are cf_statement derived classes that pass 'null' as 'cf_name'.
Switch to unique_ptr to allow that.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
The conversion is not 1:1 because 'enum class' in C++ does not support
methods. As the methods are rather simple, I moved them out of the class
as standalone functions.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
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>
In the original Java code, MurmurHash was in the "utils" package, not
"util", so move it to a new "utils" directory (and namespace), not
"util".
Signed-off-by: Nadav Har'El <nyh@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>
We cannot keep a C++ reference to the statement object because we then
lose ownership information. Start using unique_ptr as suggested by Avi
instead.
Signed-off-by: Pekka Enberg <penberg@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.