Skip to content

Commit

Permalink
src/socketpair.cpp: remove dataCheck timer
Browse files Browse the repository at this point in the history
Now that the race conditions in starting the signal handling are
resolved, we can get rid of the dataCheck timer, and just use the
readyRead signal from the serverConnection socket.
  • Loading branch information
HED-jzignego committed Mar 11, 2022
1 parent fa27da4 commit 84ca3a7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
8 changes: 1 addition & 7 deletions src/socketpair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
SocketPair::SocketPair(QObject *parent)
: QObject(parent)
{
dataCheck = new QTimer();
dataCheck->setInterval(100);
}

bool SocketPair::create()
{
connect(dataCheck, SIGNAL(timeout()), this, SLOT(readServerData()));
connect(&server, SIGNAL(newConnection()), this, SLOT(newConnection()), Qt::QueuedConnection);

connect(&server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(logServerError(QAbstractSocket::SocketError)));
Expand Down Expand Up @@ -55,9 +52,7 @@ void SocketPair::newConnection()
serverConnection->setSocketOption( QAbstractSocket::KeepAliveOption, 1 );
serverConnection->setReadBufferSize( 1 );

dataCheck->start();

// connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readServerData()));
connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readServerData()));
server.close();
emit clientConnected();
}
Expand All @@ -72,7 +67,6 @@ void SocketPair::readServerData()

void SocketPair::close()
{
dataCheck->stop();
clientConnection.close();
if (serverConnection) {
serverConnection->close();
Expand Down
1 change: 0 additions & 1 deletion src/socketpair.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public slots:
void readServerData();

private:
QTimer *dataCheck;
QTcpSocket *serverConnection;
QTcpSocket clientConnection;
QTcpServer server;
Expand Down

0 comments on commit 84ca3a7

Please sign in to comment.