diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index dfb897c..c89e59c 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -54,7 +54,7 @@ #include "qcoreapplication_p.h" #include #include - +#include QT_BEGIN_NAMESPACE HINSTANCE qWinAppInst(); @@ -399,6 +399,10 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QSNDict *dict = sn_vec[type]; QSockNot *sn = dict ? dict->value(wp) : 0; + if (sn) + qDebug() << __FUNCTION__ << "WM_QT_SOCKETNOTIFIER" << sn->obj << type; + else + qDebug() << __FUNCTION__ << "WM_QT_SOCKETNOTIFIER 0" << type; if (sn) { if (type < 3) { QEvent event(QEvent::SockAct); diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 6470873..c747417 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -48,6 +48,7 @@ #include "qobject_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -180,6 +181,9 @@ public: QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent) : QObject(*new QSocketNotifierPrivate, parent) { + qDebug() << __FUNCTION__ << this << parent; + if (parent) + setObjectName(parent->objectName() + QLatin1String("QSocketNotifier ")+ QString::number(type)); Q_D(QSocketNotifier); d->sockfd = socket; d->sntype = type; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 8751107..e60e6e7 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -94,7 +94,9 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host , preConnectRequests(0) , connectionType(type) { + channels = new QHttpNetworkConnectionChannel[channelCount]; + qDebug() << __FUNCTION__ << hostName << port; } QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, @@ -110,10 +112,10 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCoun , connectionType(type) { channels = new QHttpNetworkConnectionChannel[channelCount]; + qDebug() << __FUNCTION__ << hostName << port; } - QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() { for (int i = 0; i < channelCount; ++i) { @@ -139,6 +141,15 @@ void QHttpNetworkConnectionPrivate::init() delayedConnectionTimer.setSingleShot(true); QObject::connect(&delayedConnectionTimer, SIGNAL(timeout()), q, SLOT(_q_connectDelayedChannel())); + QString o = q->objectName(); + if (o.isEmpty()) + o = QLatin1String("QHttpNetworkConnection"); + QString postfix = QLatin1Char(':') + hostName + QLatin1Char(':') + QString::number(port); + q->setObjectName(o + postfix); + for (int i = 0; i < channelCount; ++i) { + channels[i].setObjectName(QLatin1String("Channel #") + QString::number(i) + postfix); + qDebug() << __FUNCTION__ << q << channels[i].objectName(); + } } void QHttpNetworkConnectionPrivate::pauseConnection() @@ -370,6 +381,7 @@ void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket, if (reply) { // this error matters only to this reply reply->d_func()->errorString = errorDetail(errorCode, socket); + qDebug() << __FUNCTION__ << q << "ERROR #" << errorCode; emit reply->finishedWithError(errorCode, reply->d_func()->errorString); // remove the corrupt data if any reply->d_func()->eraseData(); @@ -499,6 +511,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket isProxy ? QNetworkReply::ProxyAuthenticationRequiredError : QNetworkReply::AuthenticationRequiredError; + qDebug() << __FUNCTION__ << this << "ERROR #" << errorCode; reply->d_func()->errorString = errorDetail(errorCode, socket); emit reply->finishedWithError(errorCode, reply->d_func()->errorString); // ### at this point the reply could be deleted @@ -548,6 +561,10 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor // The reply component of the pair is created initially. QHttpNetworkReply *reply = new QHttpNetworkReply(request.url()); + reply->setObjectName(request.url().toString()); + qDebug() << "created" << reply << request.url(); + + reply->setRequest(request); reply->d_func()->connection = q; reply->d_func()->connectionChannel = &channels[0]; // will have the correct one set later @@ -615,6 +632,7 @@ void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair) bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket) { + qDebug() << __FUNCTION__ << highPriorityQueue.size() << lowPriorityQueue.size(); int i = 0; if (socket) i = indexOf(socket); @@ -1198,6 +1216,7 @@ QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 QObject *parent, QSharedPointer networkSession) : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt, connectionType)), parent) { + qDebug() << __FUNCTION__ << parent; Q_D(QHttpNetworkConnection); d->networkSession = networkSession; d->init(); @@ -1210,6 +1229,7 @@ QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QS : QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt, connectionType)), parent) { + qDebug() << __FUNCTION__ << parent; Q_D(QHttpNetworkConnection); d->networkSession = networkSession; d->init(); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index fb40958..1cfc5ba 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -46,6 +46,7 @@ #include #include +#include #ifndef QT_NO_HTTP @@ -103,6 +104,8 @@ void QHttpNetworkConnectionChannel::init() socket = new QTcpSocket; #else socket = new QTcpSocket; + socket->setObjectName(objectName() + QLatin1String("_Socket")); + qDebug() << __FUNCTION__ << this << "created socket" << socket; #endif #ifndef QT_NO_BEARERMANAGEMENT //push session down to socket @@ -134,6 +137,7 @@ void QHttpNetworkConnectionChannel::init() QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::QueuedConnection); + qDebug() << __FUNCTION__ << this << "connecting socket error" << socket; QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::QueuedConnection); @@ -179,6 +183,7 @@ void QHttpNetworkConnectionChannel::init() socket->setProxy(proxy); #endif isInitialized = true; + qDebug() << __FUNCTION__ << '<'; } @@ -227,6 +232,7 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF() requeueCurrentlyPipelinedRequests(); close(); reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket); + qDebug() << __FUNCTION__ << this << "ERROR #" << QNetworkReply::RemoteHostClosedError; emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else { @@ -525,6 +531,7 @@ void QHttpNetworkConnectionChannel::handleStatus() QNetworkReply::NetworkError errorCode = (statusCode == 407) ? QNetworkReply::ProxyAuthenticationRequiredError : QNetworkReply::AuthenticationRequiredError; + qDebug() << __FUNCTION__ << this << "ERROR #" << errorCode; reply->d_func()->errorString = connection->d_func()->errorDetail(errorCode, socket); emit reply->finishedWithError(errorCode, reply->d_func()->errorString); } @@ -764,6 +771,7 @@ void QHttpNetworkConnectionChannel::_q_connected() void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socketError) { + qDebug() << __FUNCTION__ << this << socketError << "SOCK" << socket << "REPL" << reply; if (!socket) return; QNetworkReply::NetworkError errorCode = QNetworkReply::UnknownNetworkError; @@ -870,13 +878,17 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket // In the HostLookupPending state the channel should not emit the error. // This will instead be handled by the connection. - if (!connection->d_func()->shouldEmitChannelError(socket)) - return; + if (!connection->d_func()->shouldEmitChannelError(socket)) { + qDebug() << __FUNCTION__ << "BAIL OUT"; + return; + } // Need to dequeu the request so that we can emit the error. if (!reply) connection->d_func()->dequeueRequest(socket); + qDebug() << __FUNCTION__ << reply << "after dequeueRequest"; if (reply) { + qDebug() << __FUNCTION__ << this << "ERROR #" << errorCode << QThread::currentThreadId(); reply->d_func()->errorString = errorString; emit reply->finishedWithError(errorCode, errorString); reply = 0; diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index e03dcb8..45e535e 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -242,6 +242,9 @@ QHttpThreadDelegate::QHttpThreadDelegate(QObject *parent) : , httpReply(0) , synchronousRequestLoop(0) { + if (parent) + setObjectName(parent->objectName() + QLatin1String("_HttpThreadDelegate")); + qDebug() << __FUNCTION__ << this << parent; } // This is invoked as BlockingQueuedConnection from QNetworkAccessHttpBackend in the user thread @@ -273,9 +276,8 @@ void QHttpThreadDelegate::startRequestSynchronously() // This is invoked as QueuedConnection from QNetworkAccessHttpBackend in the user thread void QHttpThreadDelegate::startRequest() { -#ifdef QHTTPTHREADDELEGATE_DEBUG - qDebug() << "QHttpThreadDelegate::startRequest() thread=" << QThread::currentThreadId(); -#endif + qDebug() << "QHttpThreadDelegate::startRequest() thread=" << QThread::currentThreadId() + << httpRequest.url(); // Check QThreadStorage for the QNetworkAccessCache // If not there, create this connection cache if (!connections.hasLocalData()) { @@ -341,6 +343,7 @@ void QHttpThreadDelegate::startRequest() // Send the request to the connection httpReply = httpConnection->sendRequest(httpRequest); + qDebug() << __FUNCTION__ << this << httpConnection << httpReply; httpReply->setParent(this); // Connect the reply signals that we need to handle and then forward @@ -531,6 +534,7 @@ void QHttpThreadDelegate::finishedWithErrorSlot(QNetworkReply::NetworkError erro if (ssl) emit sslConfigurationChanged(httpReply->sslConfiguration()); #endif + qDebug() << __FUNCTION__ << this << "ERROR #" << errorCode; emit error(errorCode,detail); emit downloadFinished(); diff --git a/src/network/network.pro b/src/network/network.pro index 79e357e..2a43708 100644 --- a/src/network/network.pro +++ b/src/network/network.pro @@ -6,7 +6,7 @@ DEFINES += QT_NO_USING_NAMESPACE #DEFINES += QNETWORKDISKCACHE_DEBUG #DEFINES += QSSLSOCKET_DEBUG #DEFINES += QHOSTINFO_DEBUG -#DEFINES += QABSTRACTSOCKET_DEBUG QNATIVESOCKETENGINE_DEBUG +DEFINES += QABSTRACTSOCKET_DEBUG QNATIVESOCKETENGINE_DEBUG #DEFINES += QTCPSOCKETENGINE_DEBUG QTCPSOCKET_DEBUG QTCPSERVER_DEBUG QSSLSOCKET_DEBUG #DEFINES += QUDPSOCKET_DEBUG QUDPSERVER_DEBUG win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x64000000 diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 1ceec71..cc274de 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -885,6 +885,7 @@ bool QAbstractSocketPrivate::flush() #if defined (QABSTRACTSOCKET_DEBUG) qDebug() << "QAbstractSocketPrivate::flush() write error, aborting." << socketEngine->errorString(); #endif + qDebug() << __FUNCTION__ << q << "ERROR #" << socketError; emit q->error(socketError); // an unexpected error so close the socket. q->abort(); @@ -992,6 +993,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host) } state = QAbstractSocket::UnconnectedState; + qDebug() << __FUNCTION__ << q << "ERROR #" << socketError; emit q->error(socketError); emit q->stateChanged(state); } @@ -1050,6 +1052,7 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) socketError = QAbstractSocket::HostNotFoundError; q->setErrorString(QAbstractSocket::tr("Host not found")); emit q->stateChanged(state); + qDebug() << __FUNCTION__ << q << "ERROR #" << QAbstractSocket::HostNotFoundError; emit q->error(QAbstractSocket::HostNotFoundError); return; } @@ -1083,6 +1086,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() { Q_Q(QAbstractSocket); do { + qDebug() << __FUNCTION__ << q << "LOOP" << addresses; // Check for more pending addresses if (addresses.isEmpty()) { #if defined(QABSTRACTSOCKET_DEBUG) @@ -1108,6 +1112,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // q->setErrorString(QAbstractSocket::tr("Connection refused")); } emit q->stateChanged(state); + qDebug() << __FUNCTION__ << q << "ERRROR #" << socketError; emit q->error(socketError); return; } @@ -1115,6 +1120,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // Pick the first host address candidate host = addresses.takeFirst(); #if defined(QABSTRACTSOCKET_DEBUG) + qDebug() << __FUNCTION__ << q ; qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), connecting to %s:%i, %d left to try", host.toString().toLatin1().constData(), port, addresses.count()); #endif @@ -1133,6 +1139,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() if (socketEngine->connectToHost(host, port)) { //_q_testConnection(); fetchConnectionParameters(); + qDebug() << __FUNCTION__ << q << "SUCCESS"; return; } @@ -1231,6 +1238,7 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt() socketError = QAbstractSocket::SocketTimeoutError; q->setErrorString(QAbstractSocket::tr("Connection timed out")); emit q->stateChanged(state); + qDebug() << __FUNCTION__ << q << "ERROR #" << socketError; emit q->error(socketError); } else { _q_connectToNextAddress(); @@ -1291,6 +1299,7 @@ bool QAbstractSocketPrivate::readFromSocket() if (!socketEngine->isValid()) { socketError = socketEngine->error(); q->setErrorString(socketEngine->errorString()); + qDebug() << __FUNCTION__ << q << "ERROR #" << socketError; emit q->error(socketError); #if defined(QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::readFromSocket() read failed: %s", @@ -1521,6 +1530,7 @@ bool QAbstractSocket::bind(const QHostAddress &address, quint16 port, BindMode m if (!result) { d->socketError = d->socketEngine->error(); setErrorString(d->socketEngine->errorString()); + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError << d->errorString; emit error(d->socketError); return false; } @@ -1600,6 +1610,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, qWarning("QAbstractSocket::connectToHost() called when already looking up or connecting/connected to \"%s\"", qPrintable(hostName)); d->socketError = QAbstractSocket::OperationError; setErrorString(QAbstractSocket::tr("Trying to connect while connection is in progress")); + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError; emit error(d->socketError); return; } @@ -1630,6 +1641,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, // failed to setup the proxy d->socketError = QAbstractSocket::UnsupportedSocketOperationError; setErrorString(QAbstractSocket::tr("Operation on socket is not supported")); + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError; emit error(d->socketError); return; } @@ -2145,6 +2157,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs) qDebug("QAbstractSocket::waitForReadyRead(%i) failed (%i, %s)", msecs, d->socketError, errorString().toLatin1().constData()); #endif + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError; emit error(d->socketError); if (d->socketError != SocketTimeoutError) close(); @@ -2203,6 +2216,7 @@ bool QAbstractSocket::waitForBytesWritten(int msecs) qDebug("QAbstractSocket::waitForBytesWritten(%i) failed (%i, %s)", msecs, d->socketError, errorString().toLatin1().constData()); #endif + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError; emit error(d->socketError); if (d->socketError != SocketTimeoutError) close(); @@ -2282,6 +2296,7 @@ bool QAbstractSocket::waitForDisconnected(int msecs) qDebug("QAbstractSocket::waitForReadyRead(%i) failed (%i, %s)", msecs, d->socketError, errorString().toLatin1().constData()); #endif + qDebug() << __FUNCTION__ << this << "ERROR #" << d->socketError; emit error(d->socketError); if (d->socketError != SocketTimeoutError) close(); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 96c6c0f..df6dcb2 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -145,6 +145,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) d->error = QLocalSocket::ServerNotFoundError; setErrorString(QLocalSocket::tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer"))); d->state = UnconnectedState; + qDebug() << __FUNCTION__ << this << "ERROR #" << d->error; emit error(d->error); emit stateChanged(d->state); return; diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 6bf8626..84a2b01 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -323,6 +323,9 @@ bool QNativeSocketEnginePrivate::checkProxy(const QHostAddress &address) QNativeSocketEngine::QNativeSocketEngine(QObject *parent) : QAbstractSocketEngine(*new QNativeSocketEnginePrivate(), parent) { + if (parent) + setObjectName(parent->objectName() + QLatin1String("_NativeSocketEngine")); + qDebug() << __FUNCTION__ << this << parent; } /*! @@ -431,7 +434,7 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: if (!d->fetchConnectionParameters()) { #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEngine::initialize(socketDescriptor == %i) failed: %s", - socketDescriptor, d->socketErrorString.toLatin1().constData()); + int(socketDescriptor), d->socketErrorString.toLatin1().constData()); #endif d->socketDescriptor = -1; return false; @@ -1216,6 +1219,8 @@ void QNativeSocketEngine::setReadNotificationEnabled(bool enable) d->readNotifier->setEnabled(enable); } else if (enable && d->threadData->hasEventDispatcher()) { d->readNotifier = new QReadNotifier(d->socketDescriptor, this); + qDebug() << __FUNCTION__ << this; + d->readNotifier->setObjectName(objectName() + QLatin1String("_ReadNotifier")); d->readNotifier->setEnabled(true); } } @@ -1231,8 +1236,10 @@ void QNativeSocketEngine::setWriteNotificationEnabled(bool enable) Q_D(QNativeSocketEngine); if (d->writeNotifier) { d->writeNotifier->setEnabled(enable); - } else if (enable && d->threadData->hasEventDispatcher()) { + } else if (enable && d->threadData->hasEventDispatcher()) { d->writeNotifier = new QWriteNotifier(d->socketDescriptor, this); + qDebug() << __FUNCTION__ << this; + d->writeNotifier->setObjectName(objectName() + QLatin1String("_WriteNotifier")); d->writeNotifier->setEnabled(true); } } @@ -1250,6 +1257,8 @@ void QNativeSocketEngine::setExceptionNotificationEnabled(bool enable) d->exceptNotifier->setEnabled(enable); } else if (enable && d->threadData->hasEventDispatcher()) { d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this); + qDebug() << __FUNCTION__ << this; + d->exceptNotifier->setObjectName(objectName() + QLatin1String("_ExceptNotifier")); d->exceptNotifier->setEnabled(true); } } diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index b1c9073..d45e256 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -52,6 +52,7 @@ #include #include #include +#include //#define QNATIVESOCKETENGINE_DEBUG #if defined(QNATIVESOCKETENGINE_DEBUG) @@ -764,8 +765,10 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin default: break; } + if (socketState != QAbstractSocket::ConnectedState) { #if defined (QNATIVESOCKETENGINE_DEBUG) + qDebug() << q_func() << __FUNCTION__ << "ERROR #" << socketError << QThread::currentThreadId(); qDebug("QNativeSocketEnginePrivate::nativeConnect(%s, %i) == false (%s)", address.toString().toLatin1().constData(), port, socketState == QAbstractSocket::ConnectingState diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 2a61325..5796eb0 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -196,7 +196,10 @@ private: QNativeSocketEngine::QNativeSocketEngine(QObject *parent) : QAbstractSocketEngine(*new QNativeSocketEnginePrivate(), parent) -{ +{ + if (parent) + setObjectName(parent->objectName() + QLatin1String("NativeSocketEngine")); + qDebug() << __FUNCTION__ << this << parent; } QNativeSocketEngine::~QNativeSocketEngine()