1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Lots of debug and half the fixes for fixing hostnames

This commit is contained in:
Jeff Mitchell
2011-11-18 17:12:45 -05:00
parent 362f8fc622
commit 7cc4632761
4 changed files with 34 additions and 22 deletions

View File

@@ -18,8 +18,8 @@
#include "connection.h" #include "connection.h"
#include <QTime> #include <QtCore/QTime>
#include <QThread> #include <QtCore/QThread>
#include "network/servent.h" #include "network/servent.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -82,7 +82,8 @@ Connection::handleIncomingQueueEmpty()
// << "m_peer_disconnected" << m_peer_disconnected // << "m_peer_disconnected" << m_peer_disconnected
// << "bytes rx" << bytesReceived(); // << "bytes rx" << bytesReceived();
if( m_sock->bytesAvailable() == 0 && m_peer_disconnected ) tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
if( !m_sock.isNull() && m_sock->bytesAvailable() == 0 && m_peer_disconnected )
{ {
qDebug() << "No more data to read, peer disconnected. shutting down connection." qDebug() << "No more data to read, peer disconnected. shutting down connection."
<< "bytesavail" << m_sock->bytesAvailable() << "bytesavail" << m_sock->bytesAvailable()
@@ -152,6 +153,7 @@ Connection::actualShutdown()
if ( !m_sock.isNull() && m_sock->isOpen() ) if ( !m_sock.isNull() && m_sock->isOpen() )
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
m_sock->disconnectFromHost(); m_sock->disconnectFromHost();
} }
@@ -177,6 +179,7 @@ Connection::start( QTcpSocket* sock )
Q_ASSERT( sock->isValid() ); Q_ASSERT( sock->isValid() );
m_sock = sock; m_sock = sock;
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
if( m_name.isEmpty() ) if( m_name.isEmpty() )
{ {
@@ -226,6 +229,7 @@ Connection::doSetup()
m_statstimer_mark.start(); m_statstimer_mark.start();
m_sock->moveToThread( thread() ); m_sock->moveToThread( thread() );
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
connect( m_sock.data(), SIGNAL( bytesWritten( qint64 ) ), connect( m_sock.data(), SIGNAL( bytesWritten( qint64 ) ),
SLOT( bytesWritten( qint64 ) ), Qt::QueuedConnection ); SLOT( bytesWritten( qint64 ) ), Qt::QueuedConnection );
@@ -266,6 +270,7 @@ Connection::socketDisconnected()
<< "bytesavail:" << m_sock->bytesAvailable() << "bytesavail:" << m_sock->bytesAvailable()
<< "bytesRecvd" << bytesReceived(); << "bytesRecvd" << bytesReceived();
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
m_peer_disconnected = true; m_peer_disconnected = true;
emit socketClosed(); emit socketClosed();
@@ -426,6 +431,7 @@ Connection::sendMsg_now( msg_ptr msg )
Q_ASSERT( QThread::currentThread() == thread() ); Q_ASSERT( QThread::currentThread() == thread() );
// Q_ASSERT( this->isRunning() ); // Q_ASSERT( this->isRunning() );
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() ) if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() )
{ {
qDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****"; qDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****";

View File

@@ -19,17 +19,17 @@
#ifndef CONNECTION_H #ifndef CONNECTION_H
#define CONNECTION_H #define CONNECTION_H
#include <QSharedPointer> #include <QtCore/QSharedPointer>
#include <QTcpSocket> #include <QtNetwork/QTcpSocket>
#include <QHostAddress> #include <QtNetwork/QHostAddress>
#include <QVariant> #include <QtCore/QVariant>
#include <QVariantMap> #include <QtCore/QVariantMap>
#include <QString> #include <QtCore/QString>
#include <QDataStream> #include <QtCore/QDataStream>
#include <QtEndian> #include <QtCore/QtEndian>
#include <QTimer> #include <QtCore/QTimer>
#include <QTime> #include <QtCore/QTime>
#include <QPointer> #include <QtCore/QPointer>
#include <qjson/parser.h> #include <qjson/parser.h>
#include <qjson/serializer.h> #include <qjson/serializer.h>

View File

@@ -82,6 +82,7 @@ ControlConnection::clone()
void void
ControlConnection::setup() ControlConnection::setup()
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
qDebug() << Q_FUNC_INFO << id() << name(); qDebug() << Q_FUNC_INFO << id() << name();
if ( !m_source.isNull() ) if ( !m_source.isNull() )
@@ -125,6 +126,7 @@ ControlConnection::setup()
void void
ControlConnection::registerSource() ControlConnection::registerSource()
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
qDebug() << Q_FUNC_INFO << m_source->id(); qDebug() << Q_FUNC_INFO << m_source->id();
Source* source = (Source*) sender(); Source* source = (Source*) sender();
Q_UNUSED( source ) Q_UNUSED( source )
@@ -147,6 +149,7 @@ ControlConnection::registerSource()
void void
ControlConnection::setupDbSyncConnection( bool ondemand ) ControlConnection::setupDbSyncConnection( bool ondemand )
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
qDebug() << Q_FUNC_INFO << ondemand << m_source->id() << m_dbconnkey << m_dbsyncconn << m_registered; qDebug() << Q_FUNC_INFO << ondemand << m_source->id() << m_dbconnkey << m_dbsyncconn << m_registered;
if ( m_dbsyncconn || !m_registered ) if ( m_dbsyncconn || !m_registered )
@@ -189,6 +192,7 @@ ControlConnection::setupDbSyncConnection( bool ondemand )
void void
ControlConnection::dbSyncConnFinished( QObject* c ) ControlConnection::dbSyncConnFinished( QObject* c )
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
qDebug() << Q_FUNC_INFO << "DBSync connection closed (for now)"; qDebug() << Q_FUNC_INFO << "DBSync connection closed (for now)";
if( (DBSyncConnection*)c == m_dbsyncconn ) if( (DBSyncConnection*)c == m_dbsyncconn )
{ {
@@ -203,6 +207,7 @@ ControlConnection::dbSyncConnFinished( QObject* c )
DBSyncConnection* DBSyncConnection*
ControlConnection::dbSyncConnection() ControlConnection::dbSyncConnection()
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
qDebug() << Q_FUNC_INFO << m_source->id(); qDebug() << Q_FUNC_INFO << m_source->id();
if ( !m_dbsyncconn ) if ( !m_dbsyncconn )
{ {
@@ -217,6 +222,7 @@ ControlConnection::dbSyncConnection()
void void
ControlConnection::handleMsg( msg_ptr msg ) ControlConnection::handleMsg( msg_ptr msg )
{ {
tDebug() << Q_FUNC_INFO << "m_sock peer address: " << m_sock->peerAddress().toIPv4Address();
if ( msg->is( Msg::PING ) ) if ( msg->is( Msg::PING ) )
{ {
// qDebug() << "Received Connection PING, nice." << m_pingtimer_mark.elapsed(); // qDebug() << "Received Connection PING, nice." << m_pingtimer_mark.elapsed();

View File

@@ -70,8 +70,6 @@ Servent::Servent( QObject* parent )
new ACLSystem( this ); new ACLSystem( this );
// Don't use system default proxy, so if SOCKS 5 specified, use that, otherwise set no proxy
if ( TomahawkSettings::instance()->proxyHost().isEmpty() )
setProxy( QNetworkProxy::NoProxy ); setProxy( QNetworkProxy::NoProxy );
{ {
@@ -384,6 +382,7 @@ Servent::readyRead()
if( conntype == "accept-offer" || "push-offer" ) if( conntype == "accept-offer" || "push-offer" )
{ {
sock->_msg.clear(); sock->_msg.clear();
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << key << nodeid << "socket peer address = " << sock->peerAddress() << "socket peer name = " << sock->peerName();
Connection* conn = claimOffer( cc, nodeid, key, sock->peerAddress() ); Connection* conn = claimOffer( cc, nodeid, key, sock->peerAddress() );
if( !conn ) if( !conn )
{ {
@@ -417,11 +416,11 @@ closeconnection:
void void
Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key ) Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key )
{ {
tDebug( LOGVERBOSE ) << "Servent::createParallelConnection, key:" << key << thread() << orig_conn; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << ", key:" << key << thread() << orig_conn;
// if we can connect to them directly: // if we can connect to them directly:
if( orig_conn && orig_conn->outbound() ) if( orig_conn && orig_conn->outbound() )
{ {
connectToPeer( orig_conn->socket()->peerAddress().toString(), connectToPeer( orig_conn->socket()->peerAddress().isNull() ? orig_conn->socket()->peerName() : orig_conn->socket()->peerAddress().toString(),
orig_conn->peerPort(), orig_conn->peerPort(),
key, key,
new_conn ); new_conn );
@@ -450,7 +449,7 @@ Servent::socketConnected()
{ {
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender(); QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
tDebug( LOGVERBOSE ) << "Servent::SocketConnected" << thread() << "socket:" << sock; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << thread() << "socket: " << sock << ", hostaddr: " << sock->peerAddress() << ", hostname: " << sock->peerName();
Connection* conn = sock->_conn.data(); Connection* conn = sock->_conn.data();
handoverSocket( conn, sock ); handoverSocket( conn, sock );
@@ -599,6 +598,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
Connection* Connection*
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer ) Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
{ {
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << " peer is " << peer.toString();
bool noauth = qApp->arguments().contains( "--noauth" ); bool noauth = qApp->arguments().contains( "--noauth" );
// magic key for stream connections: // magic key for stream connections: