protect _new_inventory with mutex
This commit is contained in:
parent
cff6cbec26
commit
8e391f5a5b
3 changed files with 22 additions and 6 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -1,4 +1,4 @@
|
|||
FROM ubuntu:18.04
|
||||
FROM ubuntu:20.04
|
||||
MAINTAINER PeerPlays Blockchain Standards Association
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
|
|
@ -59,7 +59,7 @@ RUN \
|
|||
cd build/release && \
|
||||
cmake \
|
||||
-DBOOST_ROOT="$BOOST_ROOT" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
../.. && \
|
||||
make witness_node cli_wallet && \
|
||||
install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \
|
||||
|
|
@ -82,10 +82,16 @@ VOLUME ["/var/lib/peerplays", "/etc/peerplays"]
|
|||
# rpc service:
|
||||
EXPOSE 8090
|
||||
# p2p service:
|
||||
EXPOSE 1776
|
||||
EXPOSE 9777
|
||||
EXPOSE 19777
|
||||
EXPOSE 29777
|
||||
EXPOSE 39777
|
||||
EXPOSE 49777
|
||||
EXPOSE 59777
|
||||
|
||||
# default exec/config files
|
||||
ADD docker/default_config.ini /etc/peerplays/config.ini
|
||||
ADD docker/logging.ini /etc/peerplays/logging.ini
|
||||
ADD docker/peerplaysentry.sh /usr/local/bin/peerplaysentry.sh
|
||||
RUN chmod a+x /usr/local/bin/peerplaysentry.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ fi
|
|||
## Link the peerplays config file into home
|
||||
## This link has been created in Dockerfile, already
|
||||
ln -f -s /etc/peerplays/config.ini /var/lib/peerplays
|
||||
ln -f -s /etc/peerplays/logging.ini /var/lib/peerplays
|
||||
|
||||
# Plugins need to be provided in a space-separated list, which
|
||||
# makes it necessary to write it like this
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ namespace graphene { namespace net { namespace detail {
|
|||
// @{
|
||||
fc::promise<void>::ptr _retrigger_advertise_inventory_loop_promise;
|
||||
fc::future<void> _advertise_inventory_loop_done;
|
||||
fc::mutex _new_inventory_mutex; /// mutex to protect _new_inventory
|
||||
std::unordered_set<item_id> _new_inventory; /// list of items we have received but not yet advertised to our peers
|
||||
// @}
|
||||
|
||||
|
|
@ -1239,7 +1240,11 @@ namespace graphene { namespace net { namespace detail {
|
|||
dlog("beginning an iteration of advertise inventory");
|
||||
// swap inventory into local variable, clearing the node's copy
|
||||
std::unordered_set<item_id> inventory_to_advertise;
|
||||
inventory_to_advertise.swap(_new_inventory);
|
||||
|
||||
{
|
||||
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||
inventory_to_advertise.swap(_new_inventory);
|
||||
}
|
||||
|
||||
// process all inventory to advertise and construct the inventory messages we'll send
|
||||
// first, then send them all in a batch (to avoid any fiber interruption points while
|
||||
|
|
@ -1295,7 +1300,8 @@ namespace graphene { namespace net { namespace detail {
|
|||
iter->first->send_message(iter->second);
|
||||
inventory_messages_to_send.clear();
|
||||
|
||||
if (_new_inventory.empty())
|
||||
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||
if (_new_inventory.empty())
|
||||
{
|
||||
_retrigger_advertise_inventory_loop_promise = fc::promise<void>::ptr(new fc::promise<void>("graphene::net::retrigger_advertise_inventory_loop"));
|
||||
_retrigger_advertise_inventory_loop_promise->wait();
|
||||
|
|
@ -4964,7 +4970,10 @@ namespace graphene { namespace net { namespace detail {
|
|||
message_hash_type hash_of_item_to_broadcast = item_to_broadcast.id();
|
||||
|
||||
_message_cache.cache_message( item_to_broadcast, hash_of_item_to_broadcast, propagation_data, hash_of_message_contents );
|
||||
_new_inventory.insert( item_id(item_to_broadcast.msg_type, hash_of_item_to_broadcast ) );
|
||||
{
|
||||
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||
_new_inventory.insert( item_id(item_to_broadcast.msg_type, hash_of_item_to_broadcast ) );
|
||||
}
|
||||
trigger_advertise_inventory_loop();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue