Skip to content

Commit

Permalink
peering_sharded_service: prevent over-run the container
Browse files Browse the repository at this point in the history
The container pointer can be over run when using copy constructor or
assignment operator.

This patch removes those (and leave the default and move) to prevent
unexpected results from users of the class.

Signed-off-by: Amnon Heiman <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
amnonh authored and avikivity committed Aug 9, 2017
1 parent 55a2c40 commit cf55c9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/sharded.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ protected:
/// can call its peers.
template <typename Service>
class peering_sharded_service {
sharded<Service>* _container;
sharded<Service>* _container = nullptr;
private:
template <typename T> friend class sharded;
void set_container(sharded<Service>* container) { _container = container; }
public:
peering_sharded_service() = default;
peering_sharded_service(peering_sharded_service<Service>&&) = default;
peering_sharded_service(const peering_sharded_service<Service>&) = delete;
peering_sharded_service& operator=(const peering_sharded_service<Service>&) = delete;
sharded<Service>& container() { return *_container; }
const sharded<Service>& container() const { return *_container; }
};
Expand Down

0 comments on commit cf55c9c

Please sign in to comment.