diff options
Diffstat (limited to 'src/rpc.cpp')
| -rw-r--r-- | src/rpc.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rpc.cpp b/src/rpc.cpp index c382926..a9eca8a 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp | |||
| @@ -962,6 +962,14 @@ static void LoadPaying() | |||
| 962 | fclose(f); | 962 | fclose(f); |
| 963 | try { | 963 | try { |
| 964 | nlohmann::json arr = nlohmann::json::parse(s); | 964 | nlohmann::json arr = nlohmann::json::parse(s); |
| 965 | // gPaying and gPayingNextId are both annotated as guarded by | ||
| 966 | // gPayoutExecMutex and this was mutating them without it. Safe today | ||
| 967 | // -- LoadPaying only runs at startup, before the payout thread is | ||
| 968 | // spawned -- but "safe because of where it is called from" is a fact | ||
| 969 | // about the caller, not about this function, and the annotation is | ||
| 970 | // what every other reader will trust. The mutex is uncontended here by | ||
| 971 | // construction, so taking it costs nothing. | ||
| 972 | std::lock_guard<std::mutex> lk(gPayoutExecMutex); | ||
| 965 | for (const auto& obj : arr) { | 973 | for (const auto& obj : arr) { |
| 966 | PayingRecord r; | 974 | PayingRecord r; |
| 967 | r.address = obj["address"].get<std::string>(); | 975 | r.address = obj["address"].get<std::string>(); |