remove unused socket exception notification

doubles as performance optimization for sockets (QTcpServer and QUdpSocket)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-27 21:41:19 +02:00
parent a202bf3621
commit a52b32965c
4 changed files with 7 additions and 66 deletions

View file

@ -55,7 +55,6 @@ public:
// from QAbstractSocketEngineReceiver
inline void readNotification() { canReadNotification(); }
inline void writeNotification() { canWriteNotification(); }
inline void exceptionNotification() {}
void connectionNotification();
bool canReadNotification();

View file

@ -126,30 +126,6 @@ bool QWriteNotifier::event(QEvent *e)
return QSocketNotifier::event(e);
}
class QExceptionNotifier : public QSocketNotifier
{
public:
QExceptionNotifier(int fd, QAbstractSocketEngine *parent)
: QSocketNotifier(fd, QSocketNotifier::Exception, parent) { engine = parent; }
protected:
bool event(QEvent *);
QAbstractSocketEngine *engine;
};
bool QExceptionNotifier::event(QEvent *e)
{
if (e->type() == QEvent::SockAct) {
if (engine->state() == QAbstractSocket::ConnectingState)
engine->connectionNotification();
else
engine->exceptionNotification();
return true;
}
return QSocketNotifier::event(e);
}
/*! \internal
Constructs the private class and initializes all data members.
*/
@ -157,7 +133,6 @@ QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate()
: socketDescriptor(-1)
, readNotifier(0)
, writeNotifier(0)
, exceptNotifier(0)
, socketError(QAbstractSocket::UnknownSocketError)
, hasSetSocketError(false)
, socketErrorString(QLatin1String(QT_TRANSLATE_NOOP(QSocketLayer, "Unknown error")))
@ -236,12 +211,6 @@ void QAbstractSocketEngine::writeNotification()
receiver->writeNotification();
}
void QAbstractSocketEngine::exceptionNotification()
{
if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver)
receiver->exceptionNotification();
}
/*!
If there's a connection activity on the socket, process it. Then
notify our parent if there really was activity.
@ -903,8 +872,6 @@ void QAbstractSocketEngine::close()
d->readNotifier->setEnabled(false);
if (d->writeNotifier)
d->writeNotifier->setEnabled(false);
if (d->exceptNotifier)
d->exceptNotifier->setEnabled(false);
if(d->socketDescriptor != -1) {
d->nativeClose();
@ -924,10 +891,6 @@ void QAbstractSocketEngine::close()
delete d->writeNotifier;
d->writeNotifier = 0;
}
if (d->exceptNotifier) {
delete d->exceptNotifier;
d->exceptNotifier = 0;
}
}
/*!
@ -1077,23 +1040,6 @@ void QAbstractSocketEngine::setWriteNotificationEnabled(bool enable)
}
}
bool QAbstractSocketEngine::isExceptionNotificationEnabled() const
{
Q_D(const QAbstractSocketEngine);
return d->exceptNotifier && d->exceptNotifier->isEnabled();
}
void QAbstractSocketEngine::setExceptionNotificationEnabled(bool enable)
{
Q_D(QAbstractSocketEngine);
if (d->exceptNotifier) {
d->exceptNotifier->setEnabled(enable);
} else if (enable && d->threadData->eventDispatcher) {
d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this);
d->exceptNotifier->setEnabled(true);
}
}
QT_END_NAMESPACE
#include "moc_qabstractsocketengine_p.h"

View file

@ -47,11 +47,10 @@ class QSocketNotifier;
class QAbstractSocketEngineReceiver {
public:
virtual ~QAbstractSocketEngineReceiver(){}
virtual void readNotification()= 0;
virtual void writeNotification()= 0;
virtual void exceptionNotification()= 0;
virtual void connectionNotification()= 0;
virtual ~QAbstractSocketEngineReceiver() {}
virtual void readNotification() = 0;
virtual void writeNotification() = 0;
virtual void connectionNotification() = 0;
};
class Q_AUTOTEST_EXPORT QAbstractSocketEngine : public QObject
@ -136,13 +135,10 @@ public:
void setReadNotificationEnabled(bool enable);
bool isWriteNotificationEnabled() const;
void setWriteNotificationEnabled(bool enable);
bool isExceptionNotificationEnabled() const;
void setExceptionNotificationEnabled(bool enable);
public Q_SLOTS:
void readNotification();
void writeNotification();
void exceptionNotification();
void connectionNotification();
public:
@ -239,7 +235,7 @@ public:
bool fetchConnectionParameters();
int socketDescriptor;
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
QSocketNotifier *readNotifier, *writeNotifier;
QAbstractSocket::SocketError socketError;
bool hasSetSocketError;
QString socketErrorString;

View file

@ -109,7 +109,6 @@ public:
// from QAbstractSocketEngineReceiver
void readNotification();
inline void writeNotification() {}
inline void exceptionNotification() {}
inline void connectionNotification() {}
};
@ -372,8 +371,9 @@ QHostAddress QTcpServer::serverAddress() const
bool QTcpServer::waitForNewConnection(int msec, bool *timedOut)
{
Q_D(QTcpServer);
if (!isListening())
if (!isListening()) {
return false;
}
if (!d->socketEngine->waitForRead(msec, timedOut)) {
return false;