mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 02:33:07 +02:00
Show error message instead of exception crash when unable to bind RPC port
Fixes issue #875
This commit is contained in:
committed by
Luke Dashjr
parent
527b512cf7
commit
1f56046fd5
@@ -2161,6 +2161,10 @@ void ThreadRPCServer(void* parg)
|
||||
printf("ThreadRPCServer exiting\n");
|
||||
}
|
||||
|
||||
#ifdef QT_GUI
|
||||
extern bool HACK_SHUTDOWN;
|
||||
#endif
|
||||
|
||||
void ThreadRPCServer2(void* parg)
|
||||
{
|
||||
printf("ThreadRPCServer started\n");
|
||||
@@ -2196,9 +2200,27 @@ void ThreadRPCServer2(void* parg)
|
||||
|
||||
asio::io_service io_service;
|
||||
ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332));
|
||||
#ifndef QT_GUI
|
||||
ip::tcp::acceptor acceptor(io_service, endpoint);
|
||||
|
||||
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
|
||||
#else
|
||||
ip::tcp::acceptor acceptor(io_service);
|
||||
try
|
||||
{
|
||||
acceptor.open(endpoint.protocol());
|
||||
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
|
||||
acceptor.bind(endpoint);
|
||||
acceptor.listen(socket_base::max_connections);
|
||||
}
|
||||
catch(system::system_error &e)
|
||||
{
|
||||
HACK_SHUTDOWN = true;
|
||||
ThreadSafeMessageBox(strprintf(_("An error occured while setting up the RPC port %i for listening: %s"), endpoint.port(), e.what()),
|
||||
_("Error"), wxOK | wxMODAL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSL
|
||||
ssl::context context(io_service, ssl::context::sslv23);
|
||||
|
||||
@@ -516,12 +516,16 @@ void BitcoinGUI::refreshStatusBar()
|
||||
setNumBlocks(clientModel->getNumBlocks());
|
||||
}
|
||||
|
||||
bool HACK_SHUTDOWN = false;
|
||||
|
||||
void BitcoinGUI::error(const QString &title, const QString &message, bool modal)
|
||||
{
|
||||
// Report errors from network/worker thread
|
||||
if (modal)
|
||||
{
|
||||
QMessageBox::critical(this, title, message, QMessageBox::Ok, QMessageBox::Ok);
|
||||
if (HACK_SHUTDOWN)
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
||||
} else {
|
||||
notificator->notify(Notificator::Critical, title, message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user