Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mckay <adenosine3p@gmail.com>2019-11-26 16:06:32 +0300
committerJohn Mckay <adenosine3p@gmail.com>2019-11-28 23:08:03 +0300
commit1d2e5b090af1a02e7bbdf8bf3bbf679635834645 (patch)
treebb9710ee6ac2cff30a36dd36b204f7689e91205c /src/murmur/MurmurGRPCImpl.cpp
parent7dd9d50efd6b8d755193ccd0612606777cd9ec45 (diff)
shudown and drain GRPC completion queue on exit
This prevents a segmentation fault in next() when it tries to call back to a deleted object.
Diffstat (limited to 'src/murmur/MurmurGRPCImpl.cpp')
-rw-r--r--src/murmur/MurmurGRPCImpl.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/murmur/MurmurGRPCImpl.cpp b/src/murmur/MurmurGRPCImpl.cpp
index f29b976f9..77c05232c 100644
--- a/src/murmur/MurmurGRPCImpl.cpp
+++ b/src/murmur/MurmurGRPCImpl.cpp
@@ -18,6 +18,8 @@
#include "Channel.h"
#include "Utils.h"
+#include <chrono>
+
#include <QtCore/QStack>
#include "MurmurRPC.proto.Wrapper.cpp"
@@ -138,10 +140,18 @@ MurmurRPCImpl::MurmurRPCImpl(const QString &address, std::shared_ptr<::grpc::Ser
m_completionQueue = builder.AddCompletionQueue();
m_server = builder.BuildAndStart();
meta->connectListener(this);
+ b_IsRunning = true;
start();
}
MurmurRPCImpl::~MurmurRPCImpl() {
+ void *ignored_tag;
+ bool ignored_ok;
+ b_IsRunning = false;
+ m_server->Shutdown(std::chrono::system_clock::now());
+ m_completionQueue->Shutdown();
+ while (m_completionQueue->Next(&ignored_tag, &ignored_ok))
+ ;
}
// ToRPC/FromRPC methods convert data to/from grpc protocol buffer messages.
@@ -1101,7 +1111,7 @@ void MurmurRPCImpl::customEvent(QEvent *evt) {
void MurmurRPCImpl::run() {
MurmurRPC::Wrapper::V1_Init(this, &m_V1Service);
- while (true) {
+ while (b_IsRunning) {
void *tag;
bool ok;
if (!m_completionQueue->Next(&tag, &ok)) {