compatability with older C copmilers (ticket #422, patch by fizz)
This commit is contained in:
parent
46ecfe04dc
commit
92ac49d9c4
17
configure.ac
17
configure.ac
|
@ -36,6 +36,23 @@ AC_CHECK_LIB([ssl],[SSL_library_init])
|
|||
AC_SEARCH_LIBS([socket], [socket net])
|
||||
AC_SEARCH_LIBS([gethostbyname], [nsl bind])
|
||||
|
||||
dnl ----------------------------------------------------------------------------
|
||||
dnl
|
||||
dnl va_copy
|
||||
|
||||
AC_MSG_CHECKING([how to copy va_list])
|
||||
AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
|
||||
AC_MSG_RESULT([va_copy]),
|
||||
[ AH_TEMPLATE([va_copy], [define if va_copy is not available])
|
||||
AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
|
||||
[ AC_DEFINE([va_copy], [__va_copy])
|
||||
AC_MSG_RESULT([__va_copy])],
|
||||
[ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
|
||||
AC_MSG_RESULT([memcpy])]
|
||||
)
|
||||
])
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------------
|
||||
dnl
|
||||
dnl libevent fun
|
||||
|
|
|
@ -177,8 +177,8 @@ tr_torrent_stop( TrTorrent * self )
|
|||
static TrTorrent *
|
||||
maketorrent( tr_torrent * handle )
|
||||
{
|
||||
tr_torrentDisablePex( handle, !pref_flag_get( PREF_KEY_PEX ) );
|
||||
TrTorrent * tor = g_object_new( TR_TORRENT_TYPE, NULL );
|
||||
tr_torrentDisablePex( handle, !pref_flag_get( PREF_KEY_PEX ) );
|
||||
tor->handle = handle;
|
||||
return tor;
|
||||
}
|
||||
|
|
|
@ -968,9 +968,10 @@ gotError( struct bufferevent * evbuf UNUSED, short what, void * arg )
|
|||
&& ( handshake->allowUnencryptedPeers )
|
||||
&& ( !tr_peerIoReconnect( handshake->io ) ) )
|
||||
{
|
||||
dbgmsg( handshake, "handshake failed, trying plaintext..." );
|
||||
int msgSize;
|
||||
uint8_t * msg = buildHandshakeMessage( handshake, &msgSize );
|
||||
uint8_t * msg;
|
||||
dbgmsg( handshake, "handshake failed, trying plaintext..." );
|
||||
msg = buildHandshakeMessage( handshake, &msgSize );
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
setReadState( handshake, AWAITING_HANDSHAKE );
|
||||
tr_peerIoWrite( handshake->io, msg, msgSize );
|
||||
|
|
|
@ -427,10 +427,11 @@ tr_ioRecheckRemove( tr_torrent * tor )
|
|||
else
|
||||
{
|
||||
struct recheck_node tmp;
|
||||
struct recheck_node * node;
|
||||
tmp.torrent = tor;
|
||||
struct recheck_node * node = tr_list_remove( &recheckList,
|
||||
&tmp,
|
||||
compareRecheckByTorrent );
|
||||
node = tr_list_remove( &recheckList,
|
||||
&tmp,
|
||||
compareRecheckByTorrent );
|
||||
tr_free( node );
|
||||
tor->recheckState = TR_RECHECK_NONE;
|
||||
}
|
||||
|
|
|
@ -441,16 +441,18 @@ generate :
|
|||
/* TODO : We should translate link-local IPv4 adresses to external IP,
|
||||
* so that being on same local network gives us the same allowed pieces */
|
||||
|
||||
uint8_t *seed;
|
||||
char buf[4];
|
||||
uint32_t allowedPieceCount = 0;
|
||||
tr_bitfield_t * ret;
|
||||
|
||||
printf( "%d piece allowed fast set for torrent with %d pieces and hex infohash\n", setCount, pieceCount );
|
||||
printf( "%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x for node with IP %s:\n",
|
||||
infohash[0], infohash[1], infohash[2], infohash[3], infohash[4], infohash[5], infohash[6], infohash[7], infohash[8], infohash[9],
|
||||
infohash[10], infohash[11], infohash[12], infohash[13], infohash[14], infohash[15], infohash[16], infohash[7], infohash[18], infohash[19],
|
||||
inet_ntoa( *ip ) );
|
||||
|
||||
uint8_t *seed = malloc(4 + SHA_DIGEST_LENGTH);
|
||||
char buf[4];
|
||||
uint32_t allowedPieceCount = 0;
|
||||
tr_bitfield_t * ret;
|
||||
seed = malloc(4 + SHA_DIGEST_LENGTH);
|
||||
|
||||
ret = tr_bitfieldNew( pieceCount );
|
||||
|
||||
|
@ -1690,20 +1692,19 @@ reconnectPulse( void * vtorrent )
|
|||
for( i=0; i<nAdd && i<nCandidates && i<MAX_RECONNECTIONS_PER_PULSE; ++i )
|
||||
{
|
||||
tr_peerMgr * mgr = t->manager;
|
||||
|
||||
struct peer_atom * atom = candidates[i];
|
||||
|
||||
tr_peerIo * io;
|
||||
tr_handshake * handshake;
|
||||
|
||||
tordbg( t, "Starting an OUTGOING connection with %s",
|
||||
tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||
|
||||
io = tr_peerIoNewOutgoing( mgr->handle, &atom->addr, atom->port, t->hash );
|
||||
|
||||
tr_handshake * handshake = tr_handshakeNew( io,
|
||||
mgr->handle->encryptionMode,
|
||||
myHandshakeDoneCB,
|
||||
mgr );
|
||||
handshake = tr_handshakeNew( io,
|
||||
mgr->handle->encryptionMode,
|
||||
myHandshakeDoneCB,
|
||||
mgr );
|
||||
|
||||
assert( tr_peerIoGetTorrentHash( io ) != NULL );
|
||||
|
||||
|
|
|
@ -1692,6 +1692,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||
sendBitfield( m );
|
||||
else {
|
||||
/* This peer is fastpeer-enabled, send it have-all or have-none if appropriate */
|
||||
uint32_t peerProgress;
|
||||
float completion = tr_cpPercentComplete( m->torrent->completion );
|
||||
if ( completion == 0.0f ) {
|
||||
sendFastHave( m, 0 );
|
||||
|
@ -1700,7 +1701,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||
} else {
|
||||
sendBitfield( m );
|
||||
}
|
||||
uint32_t peerProgress = m->torrent->info.pieceCount * m->info->progress;
|
||||
peerProgress = m->torrent->info.pieceCount * m->info->progress;
|
||||
|
||||
if ( peerProgress < MAX_ALLOWED_SET_COUNT )
|
||||
sendFastAllowedSet( m );
|
||||
|
|
Loading…
Reference in New Issue