[mythtv-commits] Ticket #10254: [PATCH] libmythdb: Fix 5 second pause on mythfrontend exit
MythTV
noreply at mythtv.org
Thu Jan 12 12:08:04 UTC 2012
#10254: [PATCH] libmythdb: Fix 5 second pause on mythfrontend exit
----------------------------------+----------------------------
Reporter: lvr@… | Owner: danielk
Type: Patch - Bug Fix | Status: infoneeded
Priority: minor | Milestone: unknown
Component: MythTV - General | Version: 0.24-fixes
Severity: medium | Resolution:
Keywords: | Ticket locked: 0
----------------------------------+----------------------------
Comment (by lvr@…):
The following log is from yesterdays git fixes/0.24 mythfrontend with a
small patch to output the name of the thread that opened the DB
connections. Notice the 5 second pause while deleting the last pooled
connection.
NB this bug report doesn't apply to git master, only to fixes/0.24 which
doesn't have MThread.
{{{
2012-01-12 12:56:19.989 Deleting UPnP client...
2012-01-12 12:56:19.990 UPnp - Destructor
2012-01-12 12:56:19.990 UPnp::CleanUp() - disabling SSDP notifications
2012-01-12 12:56:20.530 UPnp::CleanUp() - deleted SSDP
2012-01-12 12:56:20.604 Deleting gContext...
2012-01-12 12:56:20.605 MythSocket(852b388:46): DownRef: -1
2012-01-12 12:56:20.605 MythSocket(852b388:46): state change Connected ->
Idle
2012-01-12 12:56:20.605 MythSocket(852b388:-1): delete socket
2012-01-12 12:56:20.605 MythSocket(853c3a0:47): DownRef: 0
2012-01-12 12:56:20.605 ~MDBManager deleting pool connection opened by
main
2012-01-12 12:56:20.605 ~MDBManager deletied pool connection
2012-01-12 12:56:20.605 ~MDBManager deleting pool connection opened by
ImageLoadThread shared/4_stars.png
2012-01-12 12:56:20.605 ~MDBManager deletied pool connection
2012-01-12 12:56:20.605 ~MDBManager deleting pool connection opened by
ImageLoadThread shared/9_stars.png
2012-01-12 12:56:20.605 ~MDBManager deletied pool connection
2012-01-12 12:56:20.605 ~MDBManager deleting pool connection opened by
ImageLoadThread shared/2_stars.png
2012-01-12 12:56:20.605 ~MDBManager deletied pool connection
2012-01-12 12:56:20.605 ~MDBManager deleting pool connection opened by
ImageLoadThread shared/5_stars.png
Error in my_thread_global_end(): 3 threads didn't exit
2012-01-12 12:56:25.605 ~MDBManager deletied pool connection
2012-01-12 12:56:25.607 Deleted gContext.
2012-01-12 12:56:25.620 MythSocketThread: readyread thread exit
}}}
This is the patch to print the thread names:
{{{
diff --git a/mythtv/libs/libmythdb/mythdbcon.cpp
b/mythtv/libs/libmythdb/mythdbcon.cpp
index aa7c231..14ba232 100644
--- a/mythtv/libs/libmythdb/mythdbcon.cpp
+++ b/mythtv/libs/libmythdb/mythdbcon.cpp
@@ -8,6 +8,7 @@
#include <QSqlError>
#include <QSqlField>
#include <QSqlRecord>
+#include <QThread>
// MythTV
#include "compat.h"
@@ -115,6 +116,7 @@ bool MSqlDatabase::OpenDatabase()
}
if (connected)
{
+ m_owner = QThread::currentThread()->objectName();
VERBOSE(VB_GENERAL,
QString("Connected to database '%1' at host: %2")
.arg(m_db.databaseName()).arg(m_db.hostName()));
@@ -235,7 +237,12 @@ MDBManager::MDBManager()
MDBManager::~MDBManager()
{
while (!m_pool.isEmpty())
- delete m_pool.takeFirst();
+ {
+ MSqlDatabase *db = m_pool.takeFirst();
+ VERBOSE(VB_IMPORTANT, "~MDBManager deleting pool connection
opened by " + db->m_owner);
+ delete db;
+ VERBOSE(VB_IMPORTANT, "~MDBManager deletied pool connection");
+ }
delete m_sem;
delete m_schedCon;
diff --git a/mythtv/libs/libmythdb/mythdbcon.h
b/mythtv/libs/libmythdb/mythdbcon.h
index 8bc921d..aada908 100644
--- a/mythtv/libs/libmythdb/mythdbcon.h
+++ b/mythtv/libs/libmythdb/mythdbcon.h
@@ -34,6 +34,7 @@ class MPUBLIC MSqlDatabase
QString m_name;
QSqlDatabase m_db;
QDateTime m_lastDBKick;
+ QString m_owner;
};
/// \brief DB connection pool, used by MSqlQuery. Do not use directly.
diff --git a/mythtv/libs/libmythui/mythuiimage.cpp
b/mythtv/libs/libmythui/mythuiimage.cpp
index 3ffd4e6..4734c5d 100644
--- a/mythtv/libs/libmythui/mythuiimage.cpp
+++ b/mythtv/libs/libmythui/mythuiimage.cpp
@@ -84,6 +84,7 @@ class ImageLoadThread : public QRunnable
void run()
{
+ QThread::currentThread()->setObjectName("ImageLoadThread " +
m_filename);
QString tmpFilename;
if (!(m_filename.startsWith("myth://")))
tmpFilename = m_filename;
diff --git a/mythtv/programs/mythfrontend/main.cpp
b/mythtv/programs/mythfrontend/main.cpp
index 0335dda..0aa2112 100644
--- a/mythtv/programs/mythfrontend/main.cpp
+++ b/mythtv/programs/mythfrontend/main.cpp
@@ -155,8 +155,10 @@ namespace
g_pUPnp = NULL;
}
+ VERBOSE(VB_GENERAL, "Deleting gContext...");
delete gContext;
gContext = NULL;
+ VERBOSE(VB_GENERAL, "Deleted gContext.");
signal(SIGHUP, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
@@ -1071,6 +1073,7 @@ static void log_rotate_handler(int)
int main(int argc, char **argv)
{
+ QThread::currentThread()->setObjectName("main");
bool bPromptForBackend = false;
bool bBypassAutoDiscovery = false;
bool upgradeAllowed = false;
}}}
--
Ticket URL: <http://code.mythtv.org/trac/ticket/10254#comment:3>
MythTV <http://code.mythtv.org/trac>
MythTV Media Center
More information about the mythtv-commits
mailing list