summaryrefslogtreecommitdiffstats
path: root/abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch')
-rw-r--r--abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch b/abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch
new file mode 100644
index 0000000..6b12a79
--- /dev/null
+++ b/abs/core/mythtv/stable-29/mythtv/0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch
@@ -0,0 +1,98 @@
+From f2226b56c1c03ab76d90b9b081b2c1eb526e71f5 Mon Sep 17 00:00:00 2001
+From: Lawrence Rust <lvr@softsystem.co.uk>
+Date: Wed, 5 Jun 2013 10:52:56 +0100
+Subject: [PATCH] UPnP: Reduce startup latency by moving blocking code to own
+ thread
+
+Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
+---
+ mythtv/libs/libmythupnp/ssdp.cpp | 20 ++++++++++----------
+ mythtv/libs/libmythupnp/upnptasknotify.cpp | 9 ++++++++-
+ mythtv/libs/libmythupnp/upnptasknotify.h | 4 +++-
+ 3 files changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/mythtv/libs/libmythupnp/ssdp.cpp b/mythtv/libs/libmythupnp/ssdp.cpp
+index cf54274..07b5a07 100644
+--- a/mythtv/libs/libmythupnp/ssdp.cpp
++++ src/mythtv/libs/libmythupnp/ssdp.cpp
+@@ -168,21 +168,21 @@ void SSDP::EnableNotifications( int nServicePort )
+ // ------------------------------------------------------------------
+
+ LOG(VB_UPNP, LOG_INFO,
+- "SSDP::EnableNotifications() - sending NTS_byebye");
+- m_pNotifyTask->SetNTS( NTS_byebye );
+- m_pNotifyTask->Execute( NULL );
+-
+- m_bAnnouncementsEnabled = true;
++ "SSDP::EnableNotifications() - sending NTS_byebye2");
++ m_pNotifyTask->SetNTS( NTS_byebye2 );
+ }
++ else
++ {
++ LOG(VB_UPNP, LOG_INFO,
++ "SSDP::EnableNotifications() - sending NTS_alive");
++ m_pNotifyTask->SetNTS( NTS_alive );
++ }
++
++ m_bAnnouncementsEnabled = true;
+
+ // ------------------------------------------------------------------
+ // Add Announcement Task to the Queue
+ // ------------------------------------------------------------------
+-
+- LOG(VB_UPNP, LOG_INFO, "SSDP::EnableNotifications() - sending NTS_alive");
+-
+- m_pNotifyTask->SetNTS( NTS_alive );
+-
+ TaskQueue::Instance()->AddTask(m_pNotifyTask);
+
+ LOG(VB_UPNP, LOG_INFO,
+diff --git a/mythtv/libs/libmythupnp/upnptasknotify.cpp b/mythtv/libs/libmythupnp/upnptasknotify.cpp
+index 3f9b3bd..129a2e8 100644
+--- a/mythtv/libs/libmythupnp/upnptasknotify.cpp
++++ src/mythtv/libs/libmythupnp/upnptasknotify.cpp
+@@ -128,7 +128,9 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
+
+ pSocket->writeBlock( scPacket, scPacket.length(),
+ pSocket->address(), pSocket->port() );
+- std::this_thread::sleep_for(std::chrono::milliseconds(random() % 250));
++ // Only wait if not sending final bybbye. This speeds up shutdown
++ if (m_eNTS != NTS_byebye)
++ std::this_thread::sleep_for(std::chrono::milliseconds(random() % 250));
+ pSocket->writeBlock( scPacket, scPacket.length(),
+ pSocket->address(), pSocket->port() );
+ }
+@@ -169,6 +171,11 @@ void UPnpNotifyTask::Execute( TaskQueue *pQueue )
+
+ if (m_eNTS == NTS_alive)
+ pQueue->AddTask( (m_nMaxAge / 2) * 1000, (Task *)this );
++ else if (m_eNTS == NTS_byebye2)
++ {
++ m_eNTS = NTS_alive;
++ pQueue->AddTask( this );
++ }
+
+ m_mutex.unlock();
+
+diff --git a/mythtv/libs/libmythupnp/upnptasknotify.h b/mythtv/libs/libmythupnp/upnptasknotify.h
+index 15c23fb..7a6a485 100644
+--- a/mythtv/libs/libmythupnp/upnptasknotify.h
++++ src/mythtv/libs/libmythupnp/upnptasknotify.h
+@@ -37,7 +37,8 @@ class UPnpDevice;
+ typedef enum
+ {
+ NTS_alive = 0,
+- NTS_byebye = 1
++ NTS_byebye = 1,
++ NTS_byebye2
+
+ } UPnpNotifyNTS;
+
+@@ -89,6 +90,7 @@ class UPnpNotifyTask : public Task
+ {
+ case NTS_alive : return( "ssdp:alive" );
+ case NTS_byebye: return( "ssdp:byebye" );
++ case NTS_byebye2: return( "ssdp:byebye" );
+ }
+ return( "unknown" );
+ }