diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index c2d059b..be4ab5e 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <atomic> | 14 | #include <atomic> |
| 15 | #include <mutex> | 15 | #include <mutex> |
| 16 | #include <thread> | 16 | #include <thread> |
| 17 | #include <system_error> | ||
| 17 | #include "bip32.h" | 18 | #include "bip32.h" |
| 18 | #include "btfaddr.h" | 19 | #include "btfaddr.h" |
| 19 | #include "btftunnel.h" | 20 | #include "btftunnel.h" |
| @@ -3899,9 +3900,32 @@ connected: | |||
| 3899 | std::vector<ParticipantShareHit> shareHits; | 3900 | std::vector<ParticipantShareHit> shareHits; |
| 3900 | std::mutex shareHitsMtx; | 3901 | std::mutex shareHitsMtx; |
| 3901 | std::vector<std::thread> hashThreads; | 3902 | std::vector<std::thread> hashThreads; |
| 3902 | for (int i = 0; i < nWorkers; i++) | 3903 | try |
| 3903 | hashThreads.emplace_back(ParticipantHashWorker, &jobShared, i, nWorkers, | 3904 | { |
| 3904 | &shareHits, &shareHitsMtx); | 3905 | for (int i = 0; i < nWorkers; i++) |
| 3906 | hashThreads.emplace_back(ParticipantHashWorker, &jobShared, i, nWorkers, | ||
| 3907 | &shareHits, &shareHitsMtx); | ||
| 3908 | } | ||
| 3909 | catch (const std::system_error& e) | ||
| 3910 | { | ||
| 3911 | // A refused pthread_create used to reach std::terminate here and | ||
| 3912 | // kill the worker mid-session -- observed twice on an otherwise | ||
| 3913 | // healthy participant. Stop the workers that did start the same way | ||
| 3914 | // the disconnect path below does, drop this pool connection, and let | ||
| 3915 | // the caller's reconnect loop try again once the pressure clears. | ||
| 3916 | LogPrint("worker", "[worker] cannot spawn hash threads (%s)" | ||
| 3917 | " -- dropping pool connection\n", e.what()); | ||
| 3918 | SetParticipantMiningStatus("hash thread spawn failed"); | ||
| 3919 | { | ||
| 3920 | std::lock_guard<std::mutex> lk(jobShared.mtx); | ||
| 3921 | jobShared.stop = true; | ||
| 3922 | jobShared.haveJob = false; | ||
| 3923 | } | ||
| 3924 | for (std::thread& t : hashThreads) | ||
| 3925 | t.join(); | ||
| 3926 | closesocket(s); | ||
| 3927 | return false; | ||
| 3928 | } | ||
| 3905 | LogPrint("worker", "[worker] spawned %d hash threads on shared RandomX dataset\n", | 3929 | LogPrint("worker", "[worker] spawned %d hash threads on shared RandomX dataset\n", |
| 3906 | nWorkers); | 3930 | nWorkers); |
| 3907 | const uint64 sessionStartHashes = gParticipantHashes.load(); | 3931 | const uint64 sessionStartHashes = gParticipantHashes.load(); |