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/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;