}
static int tr_handshakeDone( tr_handshake * handshake,
- int isConnected );
+ tr_bool isConnected );
enum
{
static int
fireDoneFunc( tr_handshake * handshake,
- int isConnected )
+ tr_bool isConnected )
{
const uint8_t * peer_id = isConnected && handshake->havePeerID
? handshake->peer_id
static int
tr_handshakeDone( tr_handshake * handshake,
- int isOK )
+ tr_bool isOK )
{
tr_bool success;
/* returns true on success, false on error */
typedef tr_bool ( *handshakeDoneCB )( struct tr_handshake * handshake,
struct tr_peerIo * io,
- int isConnected,
+ tr_bool isConnected,
const uint8_t * peerId,
void * userData );
}
void
-tr_peerIoRef( tr_peerIo * io )
+tr_peerIoRefImpl( const char * file, int line, tr_peerIo * io )
{
assert( tr_isPeerIo( io ) );
+ dbgmsg( io, "%s:%d is incrementing the IO's refcount from %d to %d\n",
+ file, line, io->refCount, io->refCount+1 );
+
++io->refCount;
}
void
-tr_peerIoUnref( tr_peerIo * io )
+tr_peerIoUnrefImpl( const char * file, int line, tr_peerIo * io )
{
assert( tr_isPeerIo( io ) );
+ dbgmsg( io, "%s:%d is decrementing the IO's refcount from %d to %d\n",
+ file, line, io->refCount, io->refCount+1 );
+
if( !--io->refCount )
tr_peerIoFree( io );
}
const tr_address*
-tr_peerIoGetAddress( const tr_peerIo * io,
- tr_port * port )
+tr_peerIoGetAddress( const tr_peerIo * io, tr_port * port )
{
assert( tr_isPeerIo( io ) );
tr_port port,
int socket );
-void tr_peerIoRef ( tr_peerIo * io );
+void tr_peerIoRefImpl ( const char * file,
+ int line,
+ tr_peerIo * io );
-void tr_peerIoUnref ( tr_peerIo * io );
+#define tr_peerIoRef(io) tr_peerIoRefImpl( __FILE__, __LINE__, (io) );
+
+void tr_peerIoUnrefImpl ( const char * file,
+ int line,
+ tr_peerIo * io );
+
+#define tr_peerIoUnref(io) tr_peerIoUnrefImpl( __FILE__, __LINE__, (io) );
tr_bool tr_isPeerIo ( const tr_peerIo * io );
static tr_bool
myHandshakeDoneCB( tr_handshake * handshake,
tr_peerIo * io,
- int isConnected,
+ tr_bool isConnected,
const uint8_t * peer_id,
void * vmanager )
{
tr_handshake * ours;
assert( io );
- assert( isConnected == 0 || isConnected == 1 );
+ assert( tr_isBool( ok ) );
t = tr_peerIoHasTorrentHash( io )
? getExistingTorrent( manager, tr_peerIoGetTorrentHash( io ) )