neighbor/udisks2: move Open()/Close() calls into the I/O thread

Fixes assertion failure.
This commit is contained in:
Max Kellermann 2018-06-03 10:08:11 +02:00
parent c60b50b1ae
commit 32064a23c1
1 changed files with 18 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include "neighbor/Explorer.hxx" #include "neighbor/Explorer.hxx"
#include "neighbor/Listener.hxx" #include "neighbor/Listener.hxx"
#include "neighbor/Info.hxx" #include "neighbor/Info.hxx"
#include "event/Call.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "thread/SafeSingleton.hxx" #include "thread/SafeSingleton.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
@ -107,6 +108,9 @@ public:
List GetList() const noexcept override; List GetList() const noexcept override;
private: private:
void DoOpen();
void DoClose() noexcept;
void Insert(UdisksObject &&o) noexcept; void Insert(UdisksObject &&o) noexcept;
void Remove(const std::string &path) noexcept; void Remove(const std::string &path) noexcept;
@ -125,8 +129,8 @@ private:
void *user_data) noexcept; void *user_data) noexcept;
}; };
void inline void
UdisksNeighborExplorer::Open() UdisksNeighborExplorer::DoOpen()
{ {
using namespace ODBus; using namespace ODBus;
@ -160,10 +164,14 @@ UdisksNeighborExplorer::Open()
} }
void void
UdisksNeighborExplorer::Close() noexcept UdisksNeighborExplorer::Open()
{ {
using namespace ODBus; BlockingCall(GetEventLoop(), [this](){ DoOpen(); });
}
inline void
UdisksNeighborExplorer::DoClose() noexcept
{
if (pending_list_call) { if (pending_list_call) {
pending_list_call.Cancel(); pending_list_call.Cancel();
} }
@ -174,6 +182,12 @@ UdisksNeighborExplorer::Close() noexcept
dbus_glue.Destruct(); dbus_glue.Destruct();
} }
void
UdisksNeighborExplorer::Close() noexcept
{
BlockingCall(GetEventLoop(), [this](){ DoClose(); });
}
template<typename I> template<typename I>
gcc_pure gcc_pure
static const char * static const char *