mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
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
3 changed files with 10 additions and 8 deletions
|
@ -87,8 +87,11 @@ char * tr_clientForId( uint8_t * id )
|
|||
|
||||
if( !ret )
|
||||
{
|
||||
asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)",
|
||||
if (id[0] != 0)
|
||||
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] );
|
||||
else
|
||||
asprintf( &ret, "unknown client" );
|
||||
}
|
||||
|
||||
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_lockLock( &tor->lock );
|
||||
|
||||
*peerCount = tor->peerCount;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -526,14 +526,9 @@
|
|||
for (i = 0; i < totalPeers; 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:
|
||||
client, @"Client",
|
||||
[NSString stringWithCString: (char *) peer.client encoding: NSUTF8StringEncoding], @"Client",
|
||||
[NSNumber numberWithBool: peer.isDownloading], @"UL To",
|
||||
[NSNumber numberWithBool: peer.isUploading], @"DL From", nil]];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue