forked from lthn/blockchain
added preventive removal of ipc channel
This commit is contained in:
parent
ceb30464d3
commit
cd644cc851
2 changed files with 18 additions and 2 deletions
|
|
@ -744,11 +744,25 @@ void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, c
|
|||
}
|
||||
}
|
||||
|
||||
bool MainWindow::remove_ipc()
|
||||
{
|
||||
try {
|
||||
boost::interprocess::message_queue::remove(GUI_IPC_MESSAGE_CHANNEL_NAME);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::init_ipc_server()
|
||||
{
|
||||
|
||||
//in case previous instance wasn't close graceful, ipc channel will remain open and new creation will fail, so we
|
||||
//trying to close it anyway before open, to make sure there are no dead channels. If there are another running instance, it wom't
|
||||
//let channel to close, so it will fail later on creating channel
|
||||
remove_ipc();
|
||||
#define GUI_IPC_BUFFER_SIZE 10000
|
||||
try {
|
||||
//Create a message queue.
|
||||
|
|
@ -775,18 +789,19 @@ bool MainWindow::init_ipc_server()
|
|||
handle_ipc_event(buff);//todo process token
|
||||
}
|
||||
}
|
||||
boost::interprocess::message_queue::remove(GUI_IPC_MESSAGE_CHANNEL_NAME);
|
||||
remove_ipc();
|
||||
LOG_PRINT_L0("IPC Handling thread finished");
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
remove_ipc();
|
||||
boost::interprocess::message_queue::remove(GUI_IPC_MESSAGE_CHANNEL_NAME);
|
||||
LOG_ERROR("Failed to receive IPC que: " << ex.what());
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
boost::interprocess::message_queue::remove(GUI_IPC_MESSAGE_CHANNEL_NAME);
|
||||
remove_ipc();
|
||||
LOG_ERROR("Failed to receive IPC que: unknown exception");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ private:
|
|||
bool load_app_config();
|
||||
bool init_window();
|
||||
bool init_ipc_server();
|
||||
bool remove_ipc();
|
||||
|
||||
|
||||
std::string get_wallet_log_prefix(size_t wallet_id) const { return m_backend.get_wallet_log_prefix(wallet_id); }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue