mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk libT) #4165 "__FD_SETSIZE impact on open-file-limit and peer-limit-global" -- add safety guard in the file cache to prevent too many open files.
This commit is contained in:
parent
64b2cd64fa
commit
f9d5e7a72c
1 changed files with 12 additions and 0 deletions
|
@ -746,8 +746,20 @@ tr_fdGetFileLimit( tr_session * session )
|
|||
void
|
||||
tr_fdSetFileLimit( tr_session * session, int limit )
|
||||
{
|
||||
int max;
|
||||
|
||||
/* This is a vaguely arbitrary number.
|
||||
It takes announcer.c's MAX_CONCURRENT_TASKS into account,
|
||||
plus extra positions for the listening sockets,
|
||||
plus a few more just to be safe */
|
||||
const int buffer_slots = 128;
|
||||
|
||||
ensureSessionFdInfoExists( session );
|
||||
|
||||
max = __FD_SETSIZE - session->fdInfo->socket_limit - buffer_slots;
|
||||
if( limit > max )
|
||||
limit = max;
|
||||
|
||||
if( limit != tr_fdGetFileLimit( session ) )
|
||||
{
|
||||
struct tr_fileset * set = get_fileset( session );
|
||||
|
|
Loading…
Reference in a new issue