Skip to content
Snippets Groups Projects
Commit c4fc51a2 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Andreas Traczyk
Browse files

upnp: fix early crash by std::terminate


In NAP-PMP implementation, a std::thread member of
UPnPContext class is placed before member used by the thread.
This thread is run during the class initialization (ctor).
So the thread can start and access to these members when
they are not initialized.

The consequence is a std::terminate() call causing the stop
of daemon.

Fix that by moving the thread member after *ALL* used members.

Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Change-Id: Ibb7334e653a9c80c566ffc3944c93a6ef64e0a8b
parent 72735404
No related branches found
Tags android/release_218
No related merge requests found
...@@ -158,11 +158,11 @@ private: ...@@ -158,11 +158,11 @@ private:
uint16_t chooseRandomPort(const IGD& igd, PortType type); uint16_t chooseRandomPort(const IGD& igd, PortType type);
#if HAVE_LIBNATPMP #if HAVE_LIBNATPMP
std::thread pmpThread_ {};
std::mutex pmpMutex_ {}; std::mutex pmpMutex_ {};
std::condition_variable pmpCv_ {}; std::condition_variable pmpCv_ {};
std::shared_ptr<PMPIGD> pmpIGD_ {}; std::shared_ptr<PMPIGD> pmpIGD_ {};
std::atomic_bool pmpRun_ {true}; std::atomic_bool pmpRun_ {true};
std::thread pmpThread_ {};
void PMPsearchForIGD(const std::shared_ptr<PMPIGD>& pmp_igd, natpmp_t& natpmp); void PMPsearchForIGD(const std::shared_ptr<PMPIGD>& pmp_igd, natpmp_t& natpmp);
void PMPaddPortMapping(const PMPIGD& pmp_igd, natpmp_t& natpmp, GlobalMapping& mapping, bool remove=false) const; void PMPaddPortMapping(const PMPIGD& pmp_igd, natpmp_t& natpmp, GlobalMapping& mapping, bool remove=false) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment