Browse Source

when in shutdown exit this loop

ENGINE-781 Release_2.1.0-RC13
Volker Birk 5 years ago
parent
commit
ebae3dee3e
  1. 9
      Adapter.cc
  2. 1
      Adapter.hh
  3. 3
      callback_dispatcher.cc
  4. 8
      locked_queue.hh
  5. 4
      pc_container.hh

9
Adapter.cc

@ -144,5 +144,14 @@ namespace pEp {
{
return _sync_thread != nullptr;
}
bool in_shutdown()
{
SYNC_EVENT ev = q.back();
if (ev)
return false;
else
return true;
}
}
}

1
Adapter.hh

@ -51,6 +51,7 @@ namespace pEp {
void shutdown();
bool is_sync_running();
bool in_shutdown();
}
}

3
callback_dispatcher.cc

@ -94,6 +94,9 @@ namespace pEp {
if (Adapter::on_sync_thread() && !msg) {
semaphore.try_wait();
if (Adapter::in_shutdown())
return PEP_SYNC_NO_CHANNEL;
PEP_STATUS status = PassphraseCache::config_next_passphrase();
// if the cache has no valid passphrase ask the app

8
locked_queue.hh

@ -3,7 +3,7 @@
#pragma once
#include <list>
#include <deque>
#include <condition_variable>
#include <mutex>
@ -17,7 +17,7 @@ namespace utility
Mutex _mtx;
std::condition_variable_any _cv;
std::list<T> _q;
std::deque<T> _q;
public:
~locked_queue()
@ -39,14 +39,14 @@ namespace utility
}
// undefined behavior when queue empty
T& back()
T back()
{
Lock lg(_mtx);
return _q.back();
}
// undefined behavior when queue empty
T& front()
T front()
{
Lock lg(_mtx);
return _q.front();

4
pc_container.hh

@ -17,7 +17,7 @@ enum class PC_State { Illegal = 0, Created = 1, Deleted = 2, Changed = 3 };
// Producer/Consumer container.
//
// The "Producer" works on a std::list: inserts, changes, erases elements and
// The "Producer" works on a std::deque: inserts, changes, erases elements and
// informs a "Consumer" via a queue about the changes.
//
// The "Consumer" can poll for changes and process them asynchronously.
@ -36,7 +36,7 @@ public:
PC_State state() const noexcept { return PC_State((pdata!=nullptr) + (cdata!=nullptr)*2); }
};
typedef std::list<PC> Container;
typedef std::deque<PC> Container;
typename Container::const_iterator cbegin() const noexcept { return c.cbegin(); }
typename Container::const_iterator cend() const noexcept { return c.cend(); }

Loading…
Cancel
Save