@@ -51,6 +51,7 @@ MockFlowExecutor::MockFlowExecutor()
51
51
: ignoreFlowMods(true ), ignoreGroupMods(true ), ignoreTlvMods(true ) {}
52
52
53
53
bool MockFlowExecutor::Execute (const FlowEdit& flowEdits) {
54
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
54
55
if (ignoreFlowMods) return true ;
55
56
56
57
FlowEdit editCopy = flowEdits;
@@ -121,10 +122,12 @@ bool MockFlowExecutor::Execute(const TlvEdit& TlvEdits) {
121
122
return true ;
122
123
}
123
124
void MockFlowExecutor::Expect (FlowEdit::type mod, const string& fe) {
125
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
124
126
ignoreFlowMods = false ;
125
127
flowMods.push_back (mod_t (mod, fe));
126
128
}
127
129
void MockFlowExecutor::Expect (FlowEdit::type mod, const vector<string>& fe) {
130
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
128
131
ignoreFlowMods = false ;
129
132
for (const string& s : fe)
130
133
flowMods.push_back (mod_t (mod, s));
@@ -145,6 +148,7 @@ void MockFlowExecutor::IgnoreTlvMods() {
145
148
tlvMods.clear ();
146
149
}
147
150
void MockFlowExecutor::IgnoreFlowMods () {
151
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
148
152
ignoreFlowMods = true ;
149
153
flowMods.clear ();
150
154
}
@@ -153,16 +157,24 @@ void MockFlowExecutor::IgnoreGroupMods() {
153
157
ignoreGroupMods = true ;
154
158
groupMods.clear ();
155
159
}
156
- bool MockFlowExecutor::IsEmpty () { return flowMods.empty () || ignoreFlowMods; }
160
+ bool MockFlowExecutor::IsEmpty () {
161
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
162
+ return flowMods.empty () || ignoreFlowMods;
163
+ }
157
164
bool MockFlowExecutor::IsGroupEmpty () {
158
165
std::lock_guard<std::mutex> guard (group_mod_mutex);
159
166
return groupMods.empty () || ignoreGroupMods;
160
167
}
161
168
bool MockFlowExecutor::IsTlvEmpty () { return tlvMods.empty () || ignoreTlvMods; }
162
169
void MockFlowExecutor::Clear () {
163
- std::lock_guard<std::mutex> guard (group_mod_mutex);
164
- flowMods.clear ();
165
- groupMods.clear ();
170
+ {
171
+ std::lock_guard<std::mutex> guard (flow_mod_mutex);
172
+ flowMods.clear ();
173
+ }
174
+ {
175
+ std::lock_guard<std::mutex> guard (group_mod_mutex);
176
+ groupMods.clear ();
177
+ }
166
178
tlvMods.clear ();
167
179
}
168
180
0 commit comments