VOL-772 close grpc stream when connection is lost
It allows for the next connecting instance to get all the messages
Change-Id: I46902c03c65772c700fb031ac76e54ba428484a5
diff --git a/src/indications.cc b/src/indications.cc
index 298f51f..0d4387a 100644
--- a/src/indications.cc
+++ b/src/indications.cc
@@ -221,7 +221,9 @@
std::cout << "onu indication, intf_id:"
<< key->intf_id
<< " serial_number:"
- << serial_number_to_str(in_serial_number) << std::endl;
+ << serial_number_to_str(in_serial_number)
+ << " oper_state:" << data->oper_status
+ << " admin_state:" << data->admin_state << std::endl;
onu_ind->set_intf_id(key->intf_id);
onu_ind->set_onu_id(key->sub_term_id);
diff --git a/src/server.cc b/src/server.cc
index 2e8bc1b..263c3a1 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -94,9 +94,15 @@
ServerWriter<openolt::Indication>* writer) override {
std::cout << "Connection to Voltha established. Indications enabled"
<< std::endl;
- while (1) {
+ bool isConnected = true;
+ while (isConnected) {
auto oltInd = oltIndQ.pop();
- writer->Write(oltInd);
+ 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);
+ }
//oltInd.release_olt_ind()
}
return Status::OK;