Changeset d56ee38 for dcc.c


Ignore:
Timestamp:
2008-05-06T00:20:11Z (14 years ago)
Author:
ulim <a.sporto+bee@…>
Branches:
master
Children:
44961cb
Parents:
29c1456
Message:

timeout of transfers after 120 seconds of no progress (bytes received/sent).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dcc.c

    r29c1456 rd56ee38  
    8585gboolean dccs_recv_proto( gpointer data, gint fd, b_input_condition cond);
    8686gboolean dccs_recv_write_request( file_transfer_t *ft );
     87gboolean dcc_progress( gpointer data, gint fd, b_input_condition cond );
    8788
    8889/* As defined in ft.h */
     
    152153        df->ic->irc->file_transfers = g_slist_prepend( df->ic->irc->file_transfers, file );
    153154
     155        df->progress_timeout = b_timeout_add( DCC_MAX_STALL * 1000, dcc_progress, df );
     156
    154157        return file;
    155158}
     
    168171        if( file->canceled )
    169172                file->canceled( file, msg );
    170         else
    171                 imcb_log( df->ic, "DCC transfer aborted: %s", msg );
     173
     174        imcb_log( df->ic, "File %s: DCC transfer aborted: %s", file->file_name, msg );
    172175
    173176        g_free( msg );
     
    176179
    177180        return FALSE;
     181}
     182
     183gboolean dcc_progress( gpointer data, gint fd, b_input_condition cond )
     184{
     185        struct dcc_file_transfer *df = data;
     186
     187        if( df->ft->bytes_transferred == df->progress_bytes_last )
     188        {
     189                /* no progress. cancel */
     190                if( df->bytes_sent == 0 )
     191                        return dcc_abort( df, "Couldnt establish transfer within %d seconds", DCC_MAX_STALL );
     192                else
     193                        return dcc_abort( df, "Transfer stalled for %d seconds at %d kb", DCC_MAX_STALL, df->ft->bytes_transferred / 1024 );
     194
     195        }
     196
     197        df->progress_bytes_last = df->ft->bytes_transferred;
     198
     199        return TRUE;
    178200}
    179201
     
    435457        ft->write_request = dccs_recv_write_request;
    436458
     459        df->progress_timeout = b_timeout_add( DCC_MAX_STALL * 1000, dcc_progress, df );
     460
    437461        return TRUE;
    438462}
     
    573597        if( df->watch_out )
    574598                b_event_remove( df->watch_out );
     599       
     600        if( df->progress_timeout )
     601                b_event_remove( df->progress_timeout );
    575602       
    576603        df->ic->irc->file_transfers = g_slist_remove( df->ic->irc->file_transfers, file );
Note: See TracChangeset for help on using the changeset viewer.