diff options
author | Alberto Compagno <acompagn+fdio@cisco.com> | 2019-10-15 18:08:41 +0200 |
---|---|---|
committer | Alberto Compagno <acompagn+fdio@cisco.com> | 2019-10-22 11:01:41 +0200 |
commit | 755c6833ae2d2eee87e80ed3b84c75e968f48c46 (patch) | |
tree | 653345beb889acabc83b3b3b03e849fa34b1baac /libtransport/src/hicn/transport/utils | |
parent | 7204bac00804448a797d4e76ced04a3b84d0d741 (diff) |
[HICN-328] Reworking setSocketOption and getSocketOption to be thread-safe
Change-Id: Ie22572822b9ac1e6c300fd7982035c799546bd76
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/utils')
-rw-r--r-- | libtransport/src/hicn/transport/utils/content_store.cc | 7 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/utils/content_store.h | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/libtransport/src/hicn/transport/utils/content_store.cc b/libtransport/src/hicn/transport/utils/content_store.cc index 1e6b9fcea..8e3435507 100644 --- a/libtransport/src/hicn/transport/utils/content_store.cc +++ b/libtransport/src/hicn/transport/utils/content_store.cc @@ -85,12 +85,17 @@ void ContentStore::erase(const Name &exact_name) { } void ContentStore::setLimit(size_t max_packets) { + utils::SpinLock::Acquire locked(cs_mutex_); max_content_store_size_ = max_packets; } -std::size_t ContentStore::getLimit() const { return max_content_store_size_; } +std::size_t ContentStore::getLimit() const { + utils::SpinLock::Acquire locked(cs_mutex_); + return max_content_store_size_; +} std::size_t ContentStore::size() const { + utils::SpinLock::Acquire locked(cs_mutex_); return content_store_hash_table_.size(); } diff --git a/libtransport/src/hicn/transport/utils/content_store.h b/libtransport/src/hicn/transport/utils/content_store.h index a89403a01..f7dc41835 100644 --- a/libtransport/src/hicn/transport/utils/content_store.h +++ b/libtransport/src/hicn/transport/utils/content_store.h @@ -68,8 +68,9 @@ class ContentStore { ContentStoreHashTable content_store_hash_table_; FIFOList fifo_list_; std::shared_ptr<ContentObject> empty_reference_; - std::size_t max_content_store_size_; - utils::SpinLock cs_mutex_; + // Must be atomic + std::atomic_size_t max_content_store_size_; + mutable utils::SpinLock cs_mutex_; }; } // end namespace utils
\ No newline at end of file |