VOL-1150 A single threaded implementation for the OpenOLT driver
Stats collection is driven from the main thread.
Change-Id: I773a4aeb0e840f2a36895e39b999b2dcaf2adaa6
diff --git a/src/server.cc b/src/server.cc
index 709eb31..8cd83ff 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -151,18 +151,26 @@
ServerContext* context,
const ::openolt::Empty* request,
ServerWriter<openolt::Indication>* writer) override {
+
std::cout << "Connection to Voltha established. Indications enabled"
<< std::endl;
- state::connect();
- while (state::is_connected) {
- auto oltInd = oltIndQ.pop();
+ state.connect();
+
+ while (state.is_connected()) {
+ std::pair<openolt::Indication, bool> ind = oltIndQ.pop(COLLECTION_PERIOD);
+ if (ind.second == false) {
+ /* timeout - do lower priority periodic stuff like stats */
+ stats_collection();
+ continue;
+ }
+ openolt::Indication oltInd = ind.first;
bool isConnected = writer->Write(oltInd);
if (!isConnected) {
//Lost connectivity to this Voltha instance
//Put the indication back in the queue for next connecting instance
oltIndQ.push(oltInd);
- state::disconnect();
+ state.disconnect();
}
//oltInd.release_olt_ind()
}