Ignore:
Timestamp:
May 1, 2010, 4:37:52 AM (12 years ago)
Author:
charles
Message:

(1.9x libT) backport r10524 for #2842 "crashes on ARM-based Synology NAS"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.9x/libtransmission/peer-io.c

    r10567 r10583  
    7676    tr_bool  isPieceData;
    7777    size_t   length;
    78     struct __tr_list head;
    7978};
    8079
     
    8887     while( bytes_transferred && tr_isPeerIo( io ) )
    8988     {
    90         struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next, struct tr_datatype, head );
     89        struct tr_datatype * next = io->outbuf_datatypes->data;
     90
    9191        const size_t payload = MIN( next->length, bytes_transferred );
    9292        const size_t overhead = guessPacketOverhead( payload );
     
    105105            next->length -= payload;
    106106            if( !next->length ) {
    107                 __tr_list_remove( io->outbuf_datatypes.next );
     107                tr_list_pop_front( &io->outbuf_datatypes );
    108108                tr_free( next );
    109109            }
     
    399399    event_set( &io->event_write, io->socket, EV_WRITE, event_write_cb, io );
    400400
    401     __tr_list_init( &io->outbuf_datatypes );
    402 
    403401    return io;
    404402}
     
    449447    assert( io->session != NULL );
    450448    assert( io->session->events != NULL );
     449    assert( io->socket >= 0 );
    451450    assert( event_initialized( &io->event_read ) );
    452451    assert( event_initialized( &io->event_write ) );
     
    512511****
    513512***/
    514 
    515 static void
    516 trDatatypeFree( void * data )
    517 {
    518     struct tr_datatype * dt = __tr_list_entry( data, struct tr_datatype, head );
    519     tr_free(dt);
    520 }
    521513
    522514static void
     
    536528    tr_netClose( io->session, io->socket );
    537529    tr_cryptoFree( io->crypto );
    538     __tr_list_destroy( &io->outbuf_datatypes, trDatatypeFree );
     530    tr_list_free( &io->outbuf_datatypes, tr_free );
    539531
    540532    memset( io, ~0, sizeof( tr_peerIo ) );
     
    801793    datatype->isPieceData = isPieceData != 0;
    802794    datatype->length = byteCount;
    803 
    804     __tr_list_init( &datatype->head );
    805     __tr_list_append( &io->outbuf_datatypes, &datatype->head );
     795    tr_list_append( &io->outbuf_datatypes, datatype );
    806796
    807797    switch( io->encryptionMode )
     
    982972{
    983973    size_t byteCount = 0;
    984     struct __tr_list * walk;
    985     struct __tr_list * fencepost = &io->outbuf_datatypes;
     974    tr_list * it;
    986975
    987976    /* count up how many bytes are used by non-piece-data messages
    988977       at the front of our outbound queue */
    989     for( walk=fencepost->next; walk!=fencepost; walk=walk->next ) {
    990         struct tr_datatype * d = __tr_list_entry( walk, struct tr_datatype, head );
     978    for( it=io->outbuf_datatypes; it!=NULL; it=it->next )
     979    {
     980        struct tr_datatype * d = it->data;
     981
    991982        if( d->isPieceData )
    992983            break;
     984
    993985        byteCount += d->length;
    994986    }
Note: See TracChangeset for help on using the changeset viewer.