Changeset 8727


Ignore:
Timestamp:
Jun 21, 2009, 8:57:26 AM (13 years ago)
Author:
charles
Message:

(trunk) #2222: Make DHT support a compile-time option, enabled by default

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r8723 r8727  
    196196dnl  dht
    197197
    198 DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
    199 DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
     198
     199AC_ARG_ENABLE([dht],
     200              AS_HELP_STRING([--disable-dht],[omit DHT support]),
     201              [enable_dht=${enableval}],
     202              [enable_dht=yes])
     203if test "x$enable_dht" = "xno" ; then
     204    AC_DEFINE([WITHOUT_DHT], 1)
     205    DHT_CFLAGS=""
     206    DHT_LIBS=""
     207else
     208    DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
     209    DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
     210fi
     211AM_CONDITIONAL(DHT, test "x$enable_dht" = "xyes")
    200212AC_SUBST(DHT_CFLAGS)
    201213AC_SUBST(DHT_LIBS)
     
    398410        Compiler:                      ${CXX}
    399411        System or bundled libevent:    ${libevent_source}
     412        DHT support:                   ${enable_dht}
    400413
    401414        Build OS X client:             ${build_mac}
  • trunk/gtk/tr-prefs.c

    r8671 r8727  
    545545    hig_workarea_add_wide_control( t, &row, w );
    546546
     547#ifndef WITHOUT_DHT
    547548    s = _( "Use _DHT to find more peers" );
    548549    w = new_check_button( s, TR_PREFS_KEY_DHT_ENABLED, core );
     
    550551    gtr_widget_set_tooltip_text( w, s );
    551552    hig_workarea_add_wide_control( t, &row, w );
     553#endif
    552554
    553555    hig_workarea_finish( t, &row );
  • trunk/libtransmission/handshake.c

    r8698 r8727  
    314314
    315315    /* This doesn't depend on whether the torrent is private. */
    316     if( tor && tor->session->isDHTEnabled )
     316    if( tor && tr_sessionAllowsDHT( tor->session ) )
    317317        tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
    318318
  • trunk/libtransmission/session.c

    r8698 r8727  
    838838
    839839    if( session->isDHTEnabled )
    840         tr_dhtInit(session);
     840    {
     841#ifdef WITHOUT_DHT
     842        tr_inf( "DHT disabled by packager." );
     843#else
     844        tr_dhtInit( session );
     845#endif
     846    }
    841847}
    842848
     
    15891595
    15901596tr_bool
     1597tr_sessionAllowsDHT( const tr_session * session UNUSED )
     1598{
     1599#ifdef WITHOUT_DHT
     1600    return 0;
     1601#else
     1602    return tr_sessionIsDHTEnabled( session );
     1603#endif
     1604}
     1605
     1606tr_bool
    15911607tr_sessionIsDHTEnabled( const tr_session * session )
    15921608{
  • trunk/libtransmission/session.h

    r8661 r8727  
    139139};
    140140
     141tr_bool      tr_sessionAllowsDHT( const tr_session * session );
     142
    141143tr_bool      tr_sessionGetActiveSpeedLimit( const tr_session  * session,
    142144                                            tr_direction        dir,
  • trunk/libtransmission/torrent.h

    r8709 r8727  
    289289static TR_INLINE tr_bool tr_torrentAllowsPex( const tr_torrent * tor )
    290290{
    291     return ( tor != NULL  ) && tor->session->isPexEnabled && !tr_torrentIsPrivate( tor );
     291    return ( tor != NULL )
     292        && ( tor->session->isPexEnabled )
     293        && ( !tr_torrentIsPrivate( tor ) );
    292294}
    293295
    294296static TR_INLINE tr_bool tr_torrentAllowsDHT( const tr_torrent * tor )
    295297{
    296     return ( tor != NULL  ) && tor->session->isDHTEnabled && !tr_torrentIsPrivate( tor );
    297 }
    298 
    299 static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent  * tor, tr_piece_index_t i )
     298    return ( tor != NULL )
     299        && ( tr_sessionAllowsDHT( tor->session ) )
     300        && ( !tr_torrentIsPrivate( tor ) );
     301}
     302
     303static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent  * tor,
     304                                                   tr_piece_index_t    i )
    300305{
    301306    return tr_bitfieldHasFast( &tor->checkedPieces, i );
  • trunk/libtransmission/tr-dht.c

    r8698 r8727  
    5050#include "utils.h"
    5151#include "version.h"
     52
     53#ifdef WITHOUT_DHT
     54
     55  /* These are the stubs for when we're building without DHT support */
     56  int tr_dhtInit( tr_session * session UNUSED ) { return TR_DHT_STOPPED; }
     57  void tr_dhtUninit( tr_session * session UNUSED ) { }
     58  tr_bool tr_dhtEnabled( const tr_session * session UNUSED ) { return FALSE; }
     59  tr_port tr_dhtPort ( const tr_session * sesssion UNUSED ) { return 0; }
     60  int tr_dhtStatus( tr_session * session     UNUSED,
     61                    int        * setmeCount  UNUSED ) { return TR_DHT_STOPPED; }
     62  int tr_dhtAddNode( tr_session * session    UNUSED,
     63                     tr_address * addr       UNUSED,
     64                     tr_port      port       UNUSED,
     65                     tr_bool      bootstrap  UNUSED ) { return 0; }
     66  int tr_dhtAnnounce( tr_torrent * session UNUSED,
     67                      tr_bool announce UNUSED ) { return -1; }
     68
     69
     70#else
    5271
    5372static int dht_socket;
     
    393412    return size;
    394413}
     414
     415#endif
  • trunk/third-party/Makefile.am

    r8659 r8727  
     1if DHT
     2  DHT_DIR = dht
     3else
     4  DHT_DIR =
     5endif
    16
    2 SUBDIRS = libnatpmp miniupnp dht libevent
     7SUBDIRS = libnatpmp miniupnp libevent $(DHT_DIR)
    38
    49EXTRA_DIST = macosx-libevent-config.h
Note: See TracChangeset for help on using the changeset viewer.