mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-18 08:34:30 +00:00
Fixed data race
This commit is contained in:
parent
6e68714c26
commit
8d65a99fe4
2 changed files with 15 additions and 3 deletions
6
.github/workflows/c-cpp.yml
vendored
6
.github/workflows/c-cpp.yml
vendored
|
@ -33,8 +33,10 @@ jobs:
|
||||||
apk add git cmake gcc g++ make
|
apk add git cmake gcc g++ make
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
run: |
|
uses: actions/checkout@v3
|
||||||
git clone --recursive --shallow-submodules --filter=blob:none https://github.com/${{ github.repository }}
|
with:
|
||||||
|
submodules: true
|
||||||
|
path: p2pool
|
||||||
|
|
||||||
- name: Build libcurl
|
- name: Build libcurl
|
||||||
shell: alpine.sh {0}
|
shell: alpine.sh {0}
|
||||||
|
|
|
@ -778,11 +778,12 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v
|
||||||
|
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
FORCEINLINE Data() : counter(0) {}
|
FORCEINLINE Data() : blockMinerWallet(nullptr), counter(0) {}
|
||||||
Data(Data&&) = delete;
|
Data(Data&&) = delete;
|
||||||
Data& operator=(Data&&) = delete;
|
Data& operator=(Data&&) = delete;
|
||||||
|
|
||||||
std::vector<MinerShare> tmpShares;
|
std::vector<MinerShare> tmpShares;
|
||||||
|
Wallet blockMinerWallet;
|
||||||
hash txkeySec;
|
hash txkeySec;
|
||||||
std::atomic<int> counter;
|
std::atomic<int> counter;
|
||||||
};
|
};
|
||||||
|
@ -817,6 +818,7 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v
|
||||||
}
|
}
|
||||||
|
|
||||||
data = std::make_shared<Data>();
|
data = std::make_shared<Data>();
|
||||||
|
data->blockMinerWallet = block->m_minerWallet;
|
||||||
data->txkeySec = block->m_txkeySec;
|
data->txkeySec = block->m_txkeySec;
|
||||||
|
|
||||||
if (!get_shares(block, data->tmpShares) || !split_reward(total_reward, data->tmpShares, tmpRewards) || (tmpRewards.size() != data->tmpShares.size())) {
|
if (!get_shares(block, data->tmpShares) || !split_reward(total_reward, data->tmpShares, tmpRewards) || (tmpRewards.size() != data->tmpShares.size())) {
|
||||||
|
@ -830,6 +832,14 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v
|
||||||
// Helper jobs call get_eph_public_key with indices in descending order
|
// Helper jobs call get_eph_public_key with indices in descending order
|
||||||
// Current thread will process indices in ascending order so when they meet, everything will be cached
|
// Current thread will process indices in ascending order so when they meet, everything will be cached
|
||||||
if (loop) {
|
if (loop) {
|
||||||
|
// Avoid accessing block->m_minerWallet from other threads in "parallel_run" below
|
||||||
|
for (MinerShare& share : data->tmpShares) {
|
||||||
|
if (share.m_wallet == &block->m_minerWallet) {
|
||||||
|
share.m_wallet = &data->blockMinerWallet;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parallel_run(loop, [data]() {
|
parallel_run(loop, [data]() {
|
||||||
Data* d = data.get();
|
Data* d = data.get();
|
||||||
hash eph_public_key;
|
hash eph_public_key;
|
||||||
|
|
Loading…
Reference in a new issue