Skip to content

Commit

Permalink
Merge pull request #2336 from steemit/2302_rocksdb_shutdown_supplement
Browse files Browse the repository at this point in the history
2302 rocksdb shutdown supplement
  • Loading branch information
Michael Vandeberg committed Apr 17, 2018
2 parents c5953be + 0c39785 commit 32e7e64
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 81 deletions.
5 changes: 5 additions & 0 deletions libraries/appbase/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ void application::quit() {
}

void application::exec() {
/** To avoid killing process by broken pipe and continue regular app shutdown.
* Useful for usecase: `steemd | tee steemd.log` and pressing Ctrl+C
**/
signal(SIGPIPE, SIG_IGN);

std::shared_ptr<boost::asio::signal_set> sigint_set(new boost::asio::signal_set(*io_serv, SIGINT));
sigint_set->async_wait([sigint_set,this](const boost::system::error_code& err, int num) {
quit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace graphene { namespace net {

void send_message(const message& message_to_send);
void close_connection();
void destroy_connection();
void destroy_connection(const char* caller);

uint64_t get_total_bytes_sent() const;
uint64_t get_total_bytes_received() const;
Expand Down
4 changes: 2 additions & 2 deletions libraries/net/include/graphene/net/peer_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace graphene { namespace net
bool _currently_handling_message = false; // true while we're in the middle of handling a message from the remote system
private:
peer_connection(peer_connection_delegate* delegate);
void destroy();
void destroy(const char* caller);
public:
static peer_connection_ptr make_shared(peer_connection_delegate* delegate); // use this instead of the constructor
virtual ~peer_connection();
Expand All @@ -290,7 +290,7 @@ namespace graphene { namespace net
void send_message(const message& message_to_send, size_t message_send_time_field_offset = (size_t)-1);
void send_item(const item_id& item_to_send);
void close_connection();
void destroy_connection();
void destroy_connection(const char* caller);

uint64_t get_total_bytes_sent() const;
uint64_t get_total_bytes_received() const;
Expand Down
14 changes: 7 additions & 7 deletions libraries/net/message_oriented_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace graphene { namespace net {

void send_message(const message& message_to_send);
void close_connection();
void destroy_connection();
void destroy_connection(const char* caller);

uint64_t get_total_bytes_sent() const;
uint64_t get_total_bytes_received() const;
Expand All @@ -107,7 +107,7 @@ namespace graphene { namespace net {
message_oriented_connection_impl::~message_oriented_connection_impl()
{
VERIFY_CORRECT_THREAD();
destroy_connection();
destroy_connection(__FUNCTION__);
}

fc::tcp_socket& message_oriented_connection_impl::get_socket()
Expand All @@ -128,7 +128,7 @@ namespace graphene { namespace net {
{
VERIFY_CORRECT_THREAD();
_sock.connect_to(remote_endpoint);
assert(!_read_loop_done.valid()); // check to be sure we never launch two read loops
FC_ASSERT(!_read_loop_done.valid()); // check to be sure we never launch two read loops
_read_loop_done = fc::async([=](){ read_loop(); }, "message read_loop");
}

Expand Down Expand Up @@ -281,14 +281,14 @@ namespace graphene { namespace net {
_sock.close();
}

void message_oriented_connection_impl::destroy_connection()
void message_oriented_connection_impl::destroy_connection(const char* caller)
{
VERIFY_CORRECT_THREAD();

fc::optional<fc::ip::endpoint> remote_endpoint;
if (_sock.get_socket().is_open())
remote_endpoint = _sock.get_socket().remote_endpoint();
ilog( "in destroy_connection() for ${endpoint}", ("endpoint", remote_endpoint) );
ilog( "in destroy_connection(${caller}) for `${endpoint}'", ("caller", caller)("endpoint", remote_endpoint) );

if (_send_message_in_progress)
elog("Error: message_oriented_connection is being destroyed while a send_message is in progress. "
Expand Down Expand Up @@ -381,9 +381,9 @@ namespace graphene { namespace net {
my->close_connection();
}

void message_oriented_connection::destroy_connection()
void message_oriented_connection::destroy_connection(const char* caller)
{
my->destroy_connection();
my->destroy_connection(caller);
}

uint64_t message_oriented_connection::get_total_bytes_sent() const
Expand Down
Loading

0 comments on commit 32e7e64

Please sign in to comment.