#49 - Check to see if embedded zcashd escaped into background
This commit is contained in:
@@ -29,7 +29,7 @@ void ConnectionLoader::loadConnection() {
|
|||||||
d->exec();
|
d->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionLoader::doAutoConnect() {
|
void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) {
|
||||||
// Priority 1: Try to connect to detect zcash.conf and connect to it.
|
// Priority 1: Try to connect to detect zcash.conf and connect to it.
|
||||||
auto config = autoDetectZcashConf();
|
auto config = autoDetectZcashConf();
|
||||||
|
|
||||||
@@ -39,18 +39,29 @@ void ConnectionLoader::doAutoConnect() {
|
|||||||
refreshZcashdState(connection, [=] () {
|
refreshZcashdState(connection, [=] () {
|
||||||
// Refused connection. So try and start embedded zcashd
|
// Refused connection. So try and start embedded zcashd
|
||||||
if (Settings::getInstance()->useEmbedded()) {
|
if (Settings::getInstance()->useEmbedded()) {
|
||||||
this->showInformation("Starting embedded zcashd");
|
if (tryEzcashdStart) {
|
||||||
if (this->startEmbeddedZcashd()) {
|
this->showInformation("Starting embedded zcashd");
|
||||||
// Embedded zcashd started up. Wait a second and then refresh the connection
|
if (this->startEmbeddedZcashd()) {
|
||||||
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
|
// Embedded zcashd started up. Wait a second and then refresh the connection
|
||||||
|
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
|
||||||
|
} else {
|
||||||
|
// Something is wrong. This is happenening intermittently on Mac platforms.
|
||||||
|
// - We tried to start zcashd
|
||||||
|
// - QProcess started
|
||||||
|
// - QProcess ended, but the embedded zcashd is still in the background.
|
||||||
|
// We're going to attempt to connect to the one in the background one last time
|
||||||
|
// and see if that works, else throw an error
|
||||||
|
doAutoConnect(/* don't attempt to start ezcashd */ false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Errored out, show error and exit
|
// We tried to start ezcashd previously, and it didn't work. So, show the error.
|
||||||
QString explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
QString explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
||||||
"Did you previously start zcashd with custom arguments not in zcash.conf? Or maybe the zcash-params are corrupt?\n" %
|
"Did you previously start zcashd with custom arguments not in zcash.conf? Or maybe the zcash-params are corrupt?\n" %
|
||||||
"Please delete your zcash-params directory and restart.\n\n" %
|
"Please delete your zcash-params directory and restart.\n\n" %
|
||||||
(ezcashd ? "The process returned:\n\n" % ezcashd->errorString() : QString(""));
|
(ezcashd ? "The process returned:\n\n" % ezcashd->errorString() : QString(""));
|
||||||
this->showError(explanation);
|
this->showError(explanation);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// zcash.conf exists, there's no connection, and the user asked us not to start zcashd. Error!
|
// zcash.conf exists, there's no connection, and the user asked us not to start zcashd. Error!
|
||||||
QString explanation = QString() % "Couldn't connect to zcashd configured in zcash.conf.\n\n" %
|
QString explanation = QString() % "Couldn't connect to zcashd configured in zcash.conf.\n\n" %
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ private:
|
|||||||
|
|
||||||
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
|
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
|
||||||
|
|
||||||
void doAutoConnect();
|
void doAutoConnect(bool tryEzcashdStart = true);
|
||||||
void doManualConnect();
|
void doManualConnect();
|
||||||
|
|
||||||
void createZcashConf();
|
void createZcashConf();
|
||||||
@@ -114,6 +114,10 @@ public:
|
|||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
if (shutdownInProgress) {
|
||||||
|
// Ignoring callback because shutdown in progress
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto all = reply->readAll();
|
auto all = reply->readAll();
|
||||||
auto parsed = json::parse(all.toStdString(), nullptr, false);
|
auto parsed = json::parse(all.toStdString(), nullptr, false);
|
||||||
@@ -135,11 +139,16 @@ public:
|
|||||||
|
|
||||||
auto waitTimer = new QTimer(main);
|
auto waitTimer = new QTimer(main);
|
||||||
QObject::connect(waitTimer, &QTimer::timeout, [=]() {
|
QObject::connect(waitTimer, &QTimer::timeout, [=]() {
|
||||||
|
if (shutdownInProgress) {
|
||||||
|
waitTimer->stop();
|
||||||
|
waitTimer->deleteLater();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all responses have arrived, return
|
||||||
if (responses->size() == totalSize) {
|
if (responses->size() == totalSize) {
|
||||||
waitTimer->stop();
|
waitTimer->stop();
|
||||||
|
|
||||||
cb(responses);
|
cb(responses);
|
||||||
|
|
||||||
waitTimer->deleteLater();
|
waitTimer->deleteLater();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user