mirror of https://github.com/qt/qtgrpc.git
QGrpcHttp2Channel: add more debug logging
Easily allows to have a deeper inspection of the system by adding more debug prints, which can be enabled with the logging category. Change-Id: I86d7f6c0c53c412a79a3d66f515fa1cd6757a023 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit7e06d79d6d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commitf48600b44b) (cherry picked from commitb214760208)
This commit is contained in:
parent
a462c05372
commit
e56545b318
|
|
@ -487,6 +487,8 @@ void Http2Handler::attachStream(QHttp2Stream *stream_)
|
||||||
// In case we are Cancelled or Finished, a
|
// In case we are Cancelled or Finished, a
|
||||||
// finished has been emitted already and the
|
// finished has been emitted already and the
|
||||||
// Handler should get deleted here.
|
// Handler should get deleted here.
|
||||||
|
qCDebug(lcStream, "[%p] Ignoring headers - already closed (state=%s)",
|
||||||
|
this, QDebug::toBytes(m_state).constData());
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -672,6 +674,8 @@ void Http2Handler::sendInitialRequest()
|
||||||
connect(&m_deadlineTimer, &QTimer::timeout, this, &Http2Handler::deadlineTimeout);
|
connect(&m_deadlineTimer, &QTimer::timeout, this, &Http2Handler::deadlineTimeout);
|
||||||
m_deadlineTimer.start(*deadline);
|
m_deadlineTimer.start(*deadline);
|
||||||
}
|
}
|
||||||
|
qCDebug(lcStream, "[%p] Sending initial request (deadline=%s)", this,
|
||||||
|
deadline ? qPrintable(QString::number(deadline->count()) + " ms"_L1) : "None");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The core logic for sending the already serialized data through the HTTP/2 stream.
|
// The core logic for sending the already serialized data through the HTTP/2 stream.
|
||||||
|
|
@ -682,8 +686,11 @@ void Http2Handler::processQueue()
|
||||||
if (!m_stream)
|
if (!m_stream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_stream->isUploadingDATA())
|
if (m_stream->isUploadingDATA()) {
|
||||||
|
qCDebug(lcStream, "[%p] Stream busy uploading (queue size=%" PRIdQSIZETYPE ")", this,
|
||||||
|
m_queue.size());
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -715,6 +722,7 @@ void Http2Handler::cancelWithStatus(const QGrpcStatus &status)
|
||||||
{
|
{
|
||||||
if (m_state >= State::Cancelled)
|
if (m_state >= State::Cancelled)
|
||||||
return;
|
return;
|
||||||
|
qCDebug(lcStream, "[%p] Cancelling (state=%s)", this, QDebug::toBytes(m_state).data());
|
||||||
m_state = State::Cancelled;
|
m_state = State::Cancelled;
|
||||||
|
|
||||||
// Client cancelled the stream before the deadline exceeded.
|
// Client cancelled the stream before the deadline exceeded.
|
||||||
|
|
@ -734,6 +742,8 @@ void Http2Handler::writesDone()
|
||||||
return;
|
return;
|
||||||
m_writesDoneSent = true;
|
m_writesDoneSent = true;
|
||||||
|
|
||||||
|
qCDebug(lcStream, "[%p] Writes done received (streamClosed=%d)", this, isStreamClosedForSending());
|
||||||
|
|
||||||
// Stream is already (half)closed, skip sending the DATA frame with the end-of-stream flag.
|
// Stream is already (half)closed, skip sending the DATA frame with the end-of-stream flag.
|
||||||
if (isStreamClosedForSending())
|
if (isStreamClosedForSending())
|
||||||
return;
|
return;
|
||||||
|
|
@ -926,7 +936,9 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
&QGrpcHttp2ChannelPrivate::handleLocalSocketError);
|
&QGrpcHttp2ChannelPrivate::handleLocalSocketError);
|
||||||
|
|
||||||
m_reconnectFunction = [localSocket, this] {
|
m_reconnectFunction = [localSocket, this] {
|
||||||
localSocket->connectToServer(hostUri.host() + hostUri.path());
|
const auto name = hostUri.host() + hostUri.path();
|
||||||
|
qCDebug(lcChannel, "[%p] Connecting to local socket at: %s", this, qPrintable(name));
|
||||||
|
localSocket->connectToServer(name);
|
||||||
};
|
};
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -958,6 +970,8 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
||||||
|
|
||||||
m_reconnectFunction = [sslSocket, this] {
|
m_reconnectFunction = [sslSocket, this] {
|
||||||
|
qCDebug(lcChannel, "[%p] Connecting to SSL endpoint at: %s:%d", this,
|
||||||
|
qPrintable(hostUri.host()), hostUri.port());
|
||||||
sslSocket->connectToHostEncrypted(hostUri.host(), static_cast<quint16>(hostUri.port()));
|
sslSocket->connectToHostEncrypted(hostUri.host(), static_cast<quint16>(hostUri.port()));
|
||||||
};
|
};
|
||||||
} else
|
} else
|
||||||
|
|
@ -977,6 +991,8 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
||||||
|
|
||||||
m_reconnectFunction = [httpSocket, this] {
|
m_reconnectFunction = [httpSocket, this] {
|
||||||
|
qCDebug(lcChannel, "[%p] Connecting to TCP endpoint at: %s:%d", this,
|
||||||
|
qPrintable(hostUri.host()), hostUri.port());
|
||||||
httpSocket->connectToHost(hostUri.host(), static_cast<quint16>(hostUri.port()));
|
httpSocket->connectToHost(hostUri.host(), static_cast<quint16>(hostUri.port()));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1001,6 +1017,8 @@ void QGrpcHttp2ChannelPrivate::processOperation(QGrpcOperationContext *operation
|
||||||
|
|
||||||
// Send the finished signals asynchronously, so user connections work correctly.
|
// Send the finished signals asynchronously, so user connections work correctly.
|
||||||
if (!m_socket->isWritable() && m_state == ConnectionState::Connected) {
|
if (!m_socket->isWritable() && m_state == ConnectionState::Connected) {
|
||||||
|
qCWarning(lcChannel, "[%p] Socket not writable for operation to %s (error=%s)", this,
|
||||||
|
qPrintable(hostUri.toString()), qPrintable(m_socket->errorString()));
|
||||||
QTimer::singleShot(0, operationContext,
|
QTimer::singleShot(0, operationContext,
|
||||||
[operationContext, err = m_socket->errorString()]() {
|
[operationContext, err = m_socket->errorString()]() {
|
||||||
emit operationContext->finished({ StatusCode::Unavailable, err });
|
emit operationContext->finished({ StatusCode::Unavailable, err });
|
||||||
|
|
@ -1037,6 +1055,7 @@ void QGrpcHttp2ChannelPrivate::processOperation(QGrpcOperationContext *operation
|
||||||
m_reconnectFunction();
|
m_reconnectFunction();
|
||||||
}
|
}
|
||||||
m_state = ConnectionState::Connecting;
|
m_state = ConnectionState::Connecting;
|
||||||
|
qCDebug(lcChannel, "[%p] State changed to 'Connecting'. Reconnection initiated.", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1061,7 +1080,10 @@ void QGrpcHttp2ChannelPrivate::createHttp2Connection()
|
||||||
Q_ASSERT_X(m_connection, "QGrpcHttp2ChannelPrivate", "Unable to create the HTTP/2 connection");
|
Q_ASSERT_X(m_connection, "QGrpcHttp2ChannelPrivate", "Unable to create the HTTP/2 connection");
|
||||||
QObject::connect(m_socket.get(), &QAbstractSocket::readyRead, m_connection,
|
QObject::connect(m_socket.get(), &QAbstractSocket::readyRead, m_connection,
|
||||||
&QHttp2Connection::handleReadyRead);
|
&QHttp2Connection::handleReadyRead);
|
||||||
|
|
||||||
m_state = ConnectionState::Connected;
|
m_state = ConnectionState::Connected;
|
||||||
|
qCDebug(lcChannel, "[%p] Created new HTTP/2 connection to %s", this,
|
||||||
|
qPrintable(hostUri.toString()));
|
||||||
|
|
||||||
QObject::connect(m_connection, &QHttp2Connection::settingsFrameReceived, this, [this] {
|
QObject::connect(m_connection, &QHttp2Connection::settingsFrameReceived, this, [this] {
|
||||||
if (m_state == ConnectionState::SettingsReceived) {
|
if (m_state == ConnectionState::SettingsReceived) {
|
||||||
|
|
@ -1071,6 +1093,7 @@ void QGrpcHttp2ChannelPrivate::createHttp2Connection()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_state = ConnectionState::SettingsReceived;
|
m_state = ConnectionState::SettingsReceived;
|
||||||
|
qCDebug(lcChannel, "[%p] SETTINGS frame received. Connection ready for use.", this);
|
||||||
for_each_non_expired_handler([](Http2Handler *handler) { handler->sendInitialRequest(); });
|
for_each_non_expired_handler([](Http2Handler *handler) { handler->sendInitialRequest(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue