Skip to content

Commit 0c52497

Browse files
committed
Added lock guard to submit_event of connector to protect connector status from concurrent updates
Signed-off-by: pietfried <pietgoempel@gmail.com>
1 parent 722f09b commit 0c52497

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

include/ocpp/v201/connector.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class Connector {
4444
/// \brief Component responsible for maintaining and monitoring the operational status of CS, EVSEs, and connectors.
4545
std::shared_ptr<ComponentStateManager> component_state_manager;
4646

47+
/// \brief status mutex to protect the status of the connector against concurrent updates
48+
std::mutex status_mutex;
4749
public:
4850
/// \brief Construct a new Connector object
4951
/// \param evse_id id of the EVSE the connector is ap art of

lib/ocpp/v201/connector.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Connector::Connector(const int32_t evse_id, const int32_t connector_id,
3838
}
3939

4040
void Connector::submit_event(ConnectorEvent event) {
41+
std::lock_guard lk(this->status_mutex);
4142
switch (event) {
4243
case ConnectorEvent::PlugIn:
4344
this->component_state_manager->set_connector_occupied(this->evse_id, this->connector_id, true);

0 commit comments

Comments
 (0)