Lock and unlock while accessing peers in libtransmission.
Handle lack of client id in clients.h rather than the gui.
This commit is contained in:
parent
2eabbc90b5
commit
ebf7b6eac1
|
@ -87,8 +87,11 @@ char * tr_clientForId( uint8_t * id )
|
||||||
|
|
||||||
if( !ret )
|
if( !ret )
|
||||||
{
|
{
|
||||||
|
if (id[0] != 0)
|
||||||
asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)",
|
asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)",
|
||||||
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
|
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
|
||||||
|
else
|
||||||
|
asprintf( &ret, "unknown client" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -486,6 +486,8 @@ tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
|
||||||
|
|
||||||
tr_peer_stat_t * tr_torrentPeers( tr_torrent_t * tor, int * peerCount )
|
tr_peer_stat_t * tr_torrentPeers( tr_torrent_t * tor, int * peerCount )
|
||||||
{
|
{
|
||||||
|
tr_lockLock( &tor->lock );
|
||||||
|
|
||||||
*peerCount = tor->peerCount;
|
*peerCount = tor->peerCount;
|
||||||
|
|
||||||
tr_peer_stat_t * peers = (tr_peer_stat_t *) calloc( tor->peerCount, sizeof( tr_peer_stat_t ) );
|
tr_peer_stat_t * peers = (tr_peer_stat_t *) calloc( tor->peerCount, sizeof( tr_peer_stat_t ) );
|
||||||
|
@ -503,6 +505,8 @@ tr_peer_stat_t * tr_torrentPeers( tr_torrent_t * tor, int * peerCount )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr_lockUnlock( &tor->lock );
|
||||||
|
|
||||||
return peers;
|
return peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -527,13 +527,8 @@
|
||||||
{
|
{
|
||||||
peer = peers[i];
|
peer = peers[i];
|
||||||
|
|
||||||
client = [NSString stringWithCString: (char *) peer.client encoding: NSUTF8StringEncoding];
|
|
||||||
//get rid of strange returned client strings
|
|
||||||
if ([client hasPrefix: @"unknown client ("] && ![client hasSuffix: @")"])
|
|
||||||
client = @"unknown client";
|
|
||||||
|
|
||||||
[peerDics addObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
[peerDics addObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
client, @"Client",
|
[NSString stringWithCString: (char *) peer.client encoding: NSUTF8StringEncoding], @"Client",
|
||||||
[NSNumber numberWithBool: peer.isDownloading], @"UL To",
|
[NSNumber numberWithBool: peer.isDownloading], @"UL To",
|
||||||
[NSNumber numberWithBool: peer.isUploading], @"DL From", nil]];
|
[NSNumber numberWithBool: peer.isUploading], @"DL From", nil]];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue