Changeset d56ee38


Ignore:
Timestamp:
2008-05-06T00:20:11Z (17 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).

Files:
3 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 );
  • dcc.h

    r29c1456 rd56ee38  
    4747#define DCC_PACKET_SIZE 1024
    4848
     49/* Time in seconds that a DCC transfer can be stalled before being aborted.
     50 * By handling this here individual protocols don't have to think about this. */
     51#define DCC_MAX_STALL 120
     52
    4953typedef struct dcc_file_transfer {
    5054
     
    6468        gint watch_out;  /* writable */
    6569       
     70        /* the progress watcher cancels any file transfer if nothing happens within DCC_MAX_STALL */
     71        gint progress_timeout;
     72        size_t progress_bytes_last;
     73
    6674        /*
    6775         * The total amount of bytes that have been sent to the irc client.
  • protocols/jabber/si.c

    r29c1456 rd56ee38  
    5555{
    5656        struct jabber_transfer *tf = ft->data;
    57 
    58         imcb_log( tf->ic, "File %s transferred successfully!" , ft->file_name );
     57        time_t diff = time( NULL ) - ft->started;
     58
     59        imcb_log( tf->ic, "File %s transferred successfully at %d kb/s!" , ft->file_name, (int) ( ft->bytes_transferred / 1024 / diff ) );
    5960}
    6061
Note: See TracChangeset for help on using the changeset viewer.