1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 09:49:42 +01: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

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

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

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

@ -70,9 +70,7 @@ Servent::Servent( QObject* parent )
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 );
{
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac =
@ -384,6 +382,7 @@ Servent::readyRead()
if( conntype == "accept-offer" || "push-offer" )
{
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() );
if( !conn )
{
@ -417,11 +416,11 @@ closeconnection:
void
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( 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(),
key,
new_conn );
@ -450,7 +449,7 @@ Servent::socketConnected()
{
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();
handoverSocket( conn, sock );
@ -599,6 +598,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
Connection*
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" );
// magic key for stream connections: