Пример #1
0
void
Connection::shutdown( bool waitUntilSentAll )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << waitUntilSentAll << id();
    if ( d_func()->do_shutdown )
    {
        //qDebug() << id() << " already shutting down";
        return;
    }

    d_func()->do_shutdown = true;
    if ( !waitUntilSentAll )
    {
//        qDebug() << "Shutting down immediately " << id();
        actualShutdown();
    }
    else
    {
        tDebug( LOGVERBOSE ) << "Shutting down after transfer complete " << id()
                             << "Actual/Desired" << d_func()->tx_bytes << d_func()->tx_bytes_requested;

        bytesWritten( 0 ); // trigger shutdown if we've already sent everything
        // otherwise the bytesWritten slot will call actualShutdown()
        // once all enqueued data has been properly written to the socket
    }
}
Пример #2
0
void
Connection::bytesWritten( qint64 i )
{
    d_func()->tx_bytes += i;
    // if we are waiting to shutdown, and have sent all queued data, do actual shutdown:
    if ( d_func()->do_shutdown && d_func()->tx_bytes == d_func()->tx_bytes_requested )
        actualShutdown();
}
Пример #3
0
void
Connection::socketDisconnected()
{
    tDebug() << "SOCKET DISCONNECTED" << this->name() << id()
             << "shutdown will happen after incoming queue empties."
             << "bytesavail:" << m_sock->bytesAvailable()
             << "bytesRecvd" << bytesReceived();

    m_peer_disconnected = true;
    emit socketClosed();

    if( m_msgprocessor_in.length() == 0 && m_sock->bytesAvailable() == 0 )
    {
        handleIncomingQueueEmpty();
        actualShutdown();
    }
}
Пример #4
0
void
Connection::socketDisconnected()
{
    Q_D( Connection );

    qint64 bytesAvailable = 0;
    if ( !d->sock.isNull() )
    {
        bytesAvailable = d->sock->bytesAvailable();
    }
    tDebug( LOGVERBOSE ) << "SOCKET DISCONNECTED" << this->name() << id()
                         << "shutdown will happen after incoming queue empties."
                         << "bytesavail:" << bytesAvailable
                         << "bytesRecvd" << bytesReceived();

    d->peer_disconnected = true;
    emit socketClosed();

    if ( d->msgprocessor_in.length() == 0 && bytesAvailable == 0 )
    {
        handleIncomingQueueEmpty();
        actualShutdown();
    }
}