diff options
Diffstat (limited to 'src/gui.cpp')
| -rw-r--r-- | src/gui.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/gui.cpp b/src/gui.cpp index 2a7f350..ff6059a 100644 --- a/src/gui.cpp +++ b/src/gui.cpp | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <atomic> | 20 | #include <atomic> |
| 21 | #include <mutex> | 21 | #include <mutex> |
| 22 | #include <thread> | 22 | #include <thread> |
| 23 | #include <system_error> | ||
| 23 | #include "bip32.h" | 24 | #include "bip32.h" |
| 24 | #include "walletcmd.h" | 25 | #include "walletcmd.h" |
| 25 | #include "font_roboto.h" | 26 | #include "font_roboto.h" |
| @@ -919,8 +920,16 @@ static void DrawOptionsDialog() | |||
| 919 | 920 | ||
| 920 | if (nMineMode == MINE_OPERATOR) { | 921 | if (nMineMode == MINE_OPERATOR) { |
| 921 | if (!gPoolServerRunning) { | 922 | if (!gPoolServerRunning) { |
| 922 | gPoolServerRunning = true; | 923 | // Claim the server is up only once it is. The flag used to |
| 923 | _beginthread(ThreadRPCServer, 0, NULL); | 924 | // be set first and the result never looked at, so a refused |
| 925 | // spawn left an operator with a pool that reports itself | ||
| 926 | // running, no RPC server for miners to reach, and nothing | ||
| 927 | // anywhere saying why. The flag also latches: with it set, | ||
| 928 | // this branch is never retried. | ||
| 929 | if (_beginthread(ThreadRPCServer, 0, NULL) == (uintptr_t)-1) | ||
| 930 | printf("Error: _beginthread(ThreadRPCServer) failed -- pool server not started\n"); | ||
| 931 | else | ||
| 932 | gPoolServerRunning = true; | ||
| 924 | } else if (!gPoolRunning) { | 933 | } else if (!gPoolRunning) { |
| 925 | gPoolRunning = true; | 934 | gPoolRunning = true; |
| 926 | } | 935 | } |
| @@ -1133,11 +1142,28 @@ static void DrawRestorePhraseDialog() | |||
| 1133 | } | 1142 | } |
| 1134 | g_restoreDerived.store(0); | 1143 | g_restoreDerived.store(0); |
| 1135 | g_restoreRecovered.store(0); | 1144 | g_restoreRecovered.store(0); |
| 1145 | // Set before the spawn, not after: RestoreThread clears this | ||
| 1146 | // flag itself when it finishes, and a short restore can beat | ||
| 1147 | // us back here and have its `false` overwritten, leaving the | ||
| 1148 | // dialog disabled forever. | ||
| 1136 | g_restoreRunning.store(true); | 1149 | g_restoreRunning.store(true); |
| 1137 | // On its own thread: a restore walks the whole chain once per | 1150 | // On its own thread: a restore walks the whole chain once per |
| 1138 | // batch and would otherwise freeze the window for as long as it | 1151 | // batch and would otherwise freeze the window for as long as it |
| 1139 | // takes. | 1152 | // takes. A refused spawn is one restore that does not happen, |
| 1140 | std::thread(RestoreThread, std::string(g_restoreInput)).detach(); | 1153 | // not a reason to take the window down with an uncaught |
| 1154 | // std::system_error -- and the flag has to come back off, or | ||
| 1155 | // the dialog sits greyed out reporting a search nobody is | ||
| 1156 | // running. | ||
| 1157 | try | ||
| 1158 | { | ||
| 1159 | std::thread(RestoreThread, std::string(g_restoreInput)).detach(); | ||
| 1160 | } | ||
| 1161 | catch (const std::system_error& e) | ||
| 1162 | { | ||
| 1163 | g_restoreRunning.store(false); | ||
| 1164 | std::lock_guard<std::mutex> lock(g_restoreResultMutex); | ||
| 1165 | g_restoreResult = std::string("Could not start the search: ") + e.what(); | ||
| 1166 | } | ||
| 1141 | } | 1167 | } |
| 1142 | } | 1168 | } |
| 1143 | if (fBusy) | 1169 | if (fBusy) |