neighbor/smbclient: call Run() with locked mutex
This commit is contained in:
parent
e740f8d969
commit
c75a0f7c75
@ -76,7 +76,11 @@ public:
|
|||||||
List GetList() const noexcept override;
|
List GetList() const noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Caller must lock the mutex.
|
||||||
|
*/
|
||||||
void Run() noexcept;
|
void Run() noexcept;
|
||||||
|
|
||||||
void ThreadFunc() noexcept;
|
void ThreadFunc() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -189,9 +193,12 @@ FindBeforeServerByURI(NeighborExplorer::List::const_iterator prev,
|
|||||||
inline void
|
inline void
|
||||||
SmbclientNeighborExplorer::Run() noexcept
|
SmbclientNeighborExplorer::Run() noexcept
|
||||||
{
|
{
|
||||||
List found = DetectServers(), lost;
|
List found, lost;
|
||||||
|
|
||||||
mutex.lock();
|
{
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
found = DetectServers();
|
||||||
|
}
|
||||||
|
|
||||||
const auto found_before_begin = found.before_begin();
|
const auto found_before_begin = found.before_begin();
|
||||||
const auto found_end = found.end();
|
const auto found_end = found.end();
|
||||||
@ -216,7 +223,7 @@ SmbclientNeighborExplorer::Run() noexcept
|
|||||||
i != found_end; prev = i, i = std::next(prev))
|
i != found_end; prev = i, i = std::next(prev))
|
||||||
list.push_front(*i);
|
list.push_front(*i);
|
||||||
|
|
||||||
mutex.unlock();
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
for (auto &i : lost)
|
for (auto &i : lost)
|
||||||
listener.LostNeighbor(i);
|
listener.LostNeighbor(i);
|
||||||
@ -233,11 +240,8 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept
|
|||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
mutex.unlock();
|
|
||||||
|
|
||||||
Run();
|
Run();
|
||||||
|
|
||||||
mutex.lock();
|
|
||||||
if (quit)
|
if (quit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user