Delete pending commands on reset
* If an exception is raised in the Ruby process, it's possible for Reset to be sent to the server while the previous command is still running. This ensures that pending commands are stopped when handling Reset.
This commit is contained in:
parent
d7f724d315
commit
64762b6fad
|
@ -17,6 +17,7 @@ Connection::Connection(QTcpSocket *socket, WebPageManager *manager, QObject *par
|
||||||
m_commandFactory = new CommandFactory(m_manager, this);
|
m_commandFactory = new CommandFactory(m_manager, this);
|
||||||
m_commandParser = new CommandParser(socket, m_commandFactory, this);
|
m_commandParser = new CommandParser(socket, m_commandFactory, this);
|
||||||
m_pageSuccess = true;
|
m_pageSuccess = true;
|
||||||
|
m_pendingCommand = NULL;
|
||||||
connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
|
connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
|
||||||
connect(m_commandParser, SIGNAL(commandReady(Command *)), this, SLOT(commandReady(Command *)));
|
connect(m_commandParser, SIGNAL(commandReady(Command *)), this, SLOT(commandReady(Command *)));
|
||||||
connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
|
||||||
|
@ -28,10 +29,13 @@ void Connection::commandReady(Command *command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::startCommand(Command *command) {
|
void Connection::startCommand(Command *command) {
|
||||||
|
if (m_pendingCommand) {
|
||||||
|
m_pendingCommand->deleteLater();
|
||||||
|
}
|
||||||
if (m_pageSuccess) {
|
if (m_pageSuccess) {
|
||||||
command = new TimeoutCommand(new PageLoadingCommand(command, m_manager, this), m_manager, this);
|
m_pendingCommand = new TimeoutCommand(new PageLoadingCommand(command, m_manager, this), m_manager, this);
|
||||||
connect(command, SIGNAL(finished(Response *)), this, SLOT(finishCommand(Response *)));
|
connect(m_pendingCommand, SIGNAL(finished(Response *)), this, SLOT(finishCommand(Response *)));
|
||||||
command->start();
|
m_pendingCommand->start();
|
||||||
} else {
|
} else {
|
||||||
writePageLoadFailure();
|
writePageLoadFailure();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +56,7 @@ void Connection::finishCommand(Response *response) {
|
||||||
m_pageSuccess = true;
|
m_pageSuccess = true;
|
||||||
writeResponse(response);
|
writeResponse(response);
|
||||||
sender()->deleteLater();
|
sender()->deleteLater();
|
||||||
|
m_pendingCommand = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::writeResponse(Response *response) {
|
void Connection::writeResponse(Response *response) {
|
||||||
|
|
|
@ -32,5 +32,6 @@ class Connection : public QObject {
|
||||||
CommandFactory *m_commandFactory;
|
CommandFactory *m_commandFactory;
|
||||||
bool m_pageSuccess;
|
bool m_pageSuccess;
|
||||||
WebPage *currentPage();
|
WebPage *currentPage();
|
||||||
|
Command *m_pendingCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue