* removed wait cond and mutex usage from gui ipc log reader (it was being used incorrectly anyway)
* raised the log-to-console level to DEBUG2 * added force option to ipc log buffer (to side-step the anti-recursion "mechanism") * made relauncher always relay server/client messages to ipc client (gui)
This commit is contained in:
parent
f0493351a1
commit
ecf1833f36
|
@ -22,7 +22,8 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
IpcReader::IpcReader(QTcpSocket* socket) :
|
IpcReader::IpcReader(QTcpSocket* socket) :
|
||||||
m_Socket(socket)
|
m_Socket(socket),
|
||||||
|
m_ReadyRead(false)
|
||||||
{
|
{
|
||||||
connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +35,7 @@ IpcReader::~IpcReader()
|
||||||
void IpcReader::readyRead()
|
void IpcReader::readyRead()
|
||||||
{
|
{
|
||||||
std::cout << "ready read" << std::endl;
|
std::cout << "ready read" << std::endl;
|
||||||
m_Ready.wakeAll();
|
m_ReadyRead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcReader::run()
|
void IpcReader::run()
|
||||||
|
@ -60,7 +61,7 @@ void IpcReader::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::cerr << "aborting, message invalid: " << codeBuf[0] << std::endl;
|
std::cerr << "aborting, message invalid: " << (unsigned int)codeBuf[0] << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,9 +69,6 @@ void IpcReader::run()
|
||||||
|
|
||||||
void IpcReader::readStream(char* buffer, int length)
|
void IpcReader::readStream(char* buffer, int length)
|
||||||
{
|
{
|
||||||
QMutex mutex;
|
|
||||||
mutex.lock();
|
|
||||||
|
|
||||||
QDataStream stream(m_Socket);
|
QDataStream stream(m_Socket);
|
||||||
std::cout << "reading stream" << std::endl;
|
std::cout << "reading stream" << std::endl;
|
||||||
|
|
||||||
|
@ -81,7 +79,14 @@ void IpcReader::readStream(char* buffer, int length)
|
||||||
|
|
||||||
if (got == 0) {
|
if (got == 0) {
|
||||||
std::cout << "end of buffer, waiting" << std::endl;
|
std::cout << "end of buffer, waiting" << std::endl;
|
||||||
m_Ready.wait(&mutex);
|
|
||||||
|
// i'd love nothing more than to use a wait condition here, but
|
||||||
|
// qt is such a fucker with mutexes (can't lock/unlock between
|
||||||
|
// threads?! wtf?!). i'd just rather not go there (patches welcome).
|
||||||
|
while (!m_ReadyRead) {
|
||||||
|
QThread::usleep(100);
|
||||||
|
}
|
||||||
|
m_ReadyRead = false;
|
||||||
}
|
}
|
||||||
else if (got == -1) {
|
else if (got == -1) {
|
||||||
std::cout << "socket ended, aborting" << std::endl;
|
std::cout << "socket ended, aborting" << std::endl;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QWaitCondition>
|
|
||||||
|
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
|
|
||||||
|
@ -44,5 +43,5 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTcpSocket* m_Socket;
|
QTcpSocket* m_Socket;
|
||||||
QWaitCondition m_Ready;
|
bool m_ReadyRead;
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,8 @@ public:
|
||||||
static CLog* getInstance();
|
static CLog* getInstance();
|
||||||
|
|
||||||
//! Get the console filter level (messages above this are not sent to console).
|
//! Get the console filter level (messages above this are not sent to console).
|
||||||
int getConsoleMaxLevel() const { return kDEBUG1; }
|
int getConsoleMaxLevel() const { return kDEBUG2; }
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -61,7 +61,13 @@ CIpcLogOutputter::show(bool showIfEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CIpcLogOutputter::write(ELevel, const char* text)
|
CIpcLogOutputter::write(ELevel level, const char* text)
|
||||||
|
{
|
||||||
|
return write(level, text, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CIpcLogOutputter::write(ELevel, const char* text, bool force)
|
||||||
{
|
{
|
||||||
// sending the buffer generates log messages, which we must throw
|
// sending the buffer generates log messages, which we must throw
|
||||||
// away (otherwise this would cause recursion). this is just a drawback
|
// away (otherwise this would cause recursion). this is just a drawback
|
||||||
|
@ -69,7 +75,7 @@ CIpcLogOutputter::write(ELevel, const char* text)
|
||||||
// away log messages not generated by the ipc, but it seems like it
|
// away log messages not generated by the ipc, but it seems like it
|
||||||
// would be difficult to distinguish (other than looking at the stack
|
// would be difficult to distinguish (other than looking at the stack
|
||||||
// trace somehow). perhaps a file stream might be a better option :-/
|
// trace somehow). perhaps a file stream might be a better option :-/
|
||||||
if (m_sending) {
|
if (m_sending && !force) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual void show(bool showIfEmpty);
|
virtual void show(bool showIfEmpty);
|
||||||
virtual bool write(ELevel level, const char* message);
|
virtual bool write(ELevel level, const char* message);
|
||||||
|
virtual bool write(ELevel level, const char* text, bool force);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void bufferThread(void*);
|
void bufferThread(void*);
|
||||||
|
|
|
@ -414,9 +414,11 @@ CMSWindowsRelauncher::outputLoop(void*)
|
||||||
ARCH->sleep(1);
|
ARCH->sleep(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// send process output over IPC to GUI.
|
|
||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
m_ipcLogOutputter.write(kINFO, buffer);
|
|
||||||
|
// send process output over IPC to GUI, and force it to be sent
|
||||||
|
// which bypasses the ipc logging anti-recursion mechanism.
|
||||||
|
m_ipcLogOutputter.write(kINFO, buffer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue