Permalink
Browse files

Split the logserver into two threads

It seems under stress, the heartbeats get lost, causing all of the clients to
reconnect.  To combat this, I have moved the reception into its own thread,
and the logging into another.  In doing this, I have created two separate
ZeroMQ contexts as well, and changed the polling interval for the TCP reception
to 1ms rather than the default 10ms.
  • Loading branch information...
1 parent 2cc4bdc commit edce592897ea4dbb300404be5ab4314010436b01 @Beirdo Beirdo committed May 11, 2012
@@ -293,17 +293,8 @@ void LoggerThread::run(void)
m_initialWaiting = true;
pingLogServer();
- // wait up to 100ms for mythlogserver to respond
- qApp->processEvents(QEventLoop::WaitForMoreEvents, 100);
- if (m_initialWaiting)
- {
- // Got no response from mythlogserver, let's assume it's dead and
- // start // it up
- launchLogServer();
- }
-
- LOG(VB_GENERAL, LOG_INFO,
- "Added logging to mythlogserver at TCP:35327");
+ // wait up to 150ms for mythlogserver to respond
+ QTimer::singleShot(150, this, SLOT(initialTimeout()));
}
else
LOG(VB_GENERAL, LOG_INFO, "Added logging to mythlogserver locally");
@@ -356,6 +347,19 @@ void LoggerThread::run(void)
RunEpilog();
}
+/// \brief Handles the initial startup timeout when waiting for the log server
+/// to show signs of life
+void LoggerThread::initialTimeout(void)
+{
+ if (m_initialWaiting)
+ {
+ // Got no response from mythlogserver, let's assume it's dead and
+ // start it up
+ launchLogServer();
+ }
+
+ LOG(VB_GENERAL, LOG_INFO, "Added logging to mythlogserver at TCP:35327");
+}
/// \brief Handles heartbeat checking once a second. If the server is not
/// heard from for at least 5s, restart it
@@ -182,7 +182,7 @@ class LoggerThread : public QObject, public MThread
/// Protected by logQueueMutex
bool m_aborted; ///< Flag to abort the thread.
/// Protected by logQueueMutex
- bool m_initialWaiting; ///< Waiting for the initial response from
+ volatile bool m_initialWaiting; ///< Waiting for the initial response from
/// mythlogserver
QString m_filename; ///< Filename of debug logfile
bool m_progress; ///< show only LOG_ERR and more important (console only)
@@ -198,6 +198,7 @@ class LoggerThread : public QObject, public MThread
nzmqt::ZMQContext *m_zmqContext; ///< ZeroMQ context to use
nzmqt::ZMQSocket *m_zmqSocket; ///< ZeroMQ socket to talk to
/// mythlogserver
+
protected:
bool logConsole(LoggingItem *item);
void launchLogServer(void);
@@ -206,6 +207,7 @@ class LoggerThread : public QObject, public MThread
protected slots:
void messageReceived(const QList<QByteArray>&);
void checkHeartBeat(void);
+ void initialTimeout(void);
};
#endif
Oops, something went wrong.

0 comments on commit edce592

Please sign in to comment.