Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes on addon destruction. #348

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="4.2.10"
version="4.2.11"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down Expand Up @@ -182,6 +182,6 @@
<disclaimer lang="zh_CN">这是不稳定版的软件!作者不对录像失败、错误定时造成时间浪费或其它不良影响负责。</disclaimer>
<disclaimer lang="zh_TW">這是測試版軟體!其原創作者並無法對於以下情況負責,包含:錄影失敗,不正確的定時設定,多餘時數,或任何產生的其它不良影響...</disclaimer>
<platform>@PLATFORM@</platform>
<news>Implemented GetStreamTimes API function for recordings.</news>
<news>Fixed crashes on addon destruction</news>
</extension>
</addon>
3 changes: 3 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
4.2.11
- Fixed crashes on addon destruction

4.2.10
- PVR API v5.5.0: Implemented GetStreamTimes for recordings

Expand Down
27 changes: 18 additions & 9 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ CTvheadend::CTvheadend(PVR_PROPERTIES *pvrProps)
CTvheadend::~CTvheadend()
{
for (auto *dmx : m_dmx)
{
delete dmx;
}

m_conn->Stop();
StopThread();
delete m_conn;
delete m_vfs;
}
Expand All @@ -73,6 +69,15 @@ void CTvheadend::Start ( void )
m_conn->Start();
}

void CTvheadend::Stop ( void )
{
for (auto *dmx : m_dmx)
dmx->Close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also do a delete?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, delete's are only done in the dtor. Stop just "resets".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course


m_conn->Stop();
StopThread(0);
}

/* **************************************************************************
* Miscellaneous
* *************************************************************************/
Expand Down Expand Up @@ -1690,13 +1695,15 @@ void* CTvheadend::Process ( void )
// this is a bit horrible, but meh
bool bSuccess = m_queue.Pop(msg, 2000);

if (IsStopped())
continue;

// check for expired predictive tuning subscriptions and close those
CloseExpiredSubscriptions();

if (!bSuccess)
continue;
if (!msg.GetMessage())
if (!bSuccess || !msg.GetMessage())
continue;

method = msg.GetMethod().c_str();

SHTSPEventList eventsCopy;
Expand Down Expand Up @@ -1786,6 +1793,9 @@ void* CTvheadend::Process ( void )
/* Manual delete rather than waiting */
msg.ClearMessage();

if (IsStopped())
continue;

/* Process events
* Note: due to potential deadly embrace this must be done without the
* m_mutex held!
Expand Down Expand Up @@ -1814,8 +1824,7 @@ void* CTvheadend::Process ( void )
}
}

/* Local */
return NULL;
return nullptr;
}

void CTvheadend::TriggerChannelGroupsUpdate()
Expand Down
1 change: 1 addition & 0 deletions src/Tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class CTvheadend
~CTvheadend() override;

void Start ( void );
void Stop ( void );

// IHTSPConnectionListener implementation
void Disconnected() override;
Expand Down
7 changes: 3 additions & 4 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ ADDON_STATUS ADDON_GetStatus()
void ADDON_Destroy()
{
CLockObject lock(g_mutex);
tvh->Stop();
SAFE_DELETE(tvh);
SAFE_DELETE(PVR);
SAFE_DELETE(XBMC);
Expand All @@ -143,14 +144,12 @@ ADDON_STATUS ADDON_SetSetting

void OnSystemSleep()
{
if (tvh)
tvh->OnSleep();
tvh->OnSleep();
}

void OnSystemWake()
{
if (tvh)
tvh->OnWake();
tvh->OnWake();
}

void OnPowerSavingActivated()
Expand Down