mirror of
https://github.com/transmission/transmission
synced 2025-03-10 14:13:23 +00:00
(libT) revert r7099 based on forum feedback @ <http://forum.transmissionbt.com/viewtopic.php?f=4&t=6485>
This commit is contained in:
parent
9571f3b714
commit
aee1a0b9a0
1 changed files with 21 additions and 0 deletions
|
@ -22,6 +22,10 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef WIN32
|
||||
#define HAVE_GETRLIMIT
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -38,6 +42,10 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
#include <sys/time.h> /* getrlimit */
|
||||
#include <sys/resource.h> /* getrlimit */
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h> /* O_LARGEFILE */
|
||||
|
||||
|
@ -531,7 +539,20 @@ tr_fdInit( int globalPeerLimit )
|
|||
assert( gFd == NULL );
|
||||
gFd = tr_new0( struct tr_fd_s, 1 );
|
||||
gFd->lock = tr_lockNew( );
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
{
|
||||
struct rlimit rlim;
|
||||
getrlimit( RLIMIT_NOFILE, &rlim );
|
||||
rlim.rlim_cur = MIN( rlim.rlim_max,
|
||||
(rlim_t)( globalPeerLimit + NOFILE_BUFFER ) );
|
||||
setrlimit( RLIMIT_NOFILE, &rlim );
|
||||
gFd->socketMax = rlim.rlim_cur - NOFILE_BUFFER;
|
||||
tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur );
|
||||
}
|
||||
#else
|
||||
gFd->socketMax = globalPeerLimit;
|
||||
#endif
|
||||
tr_dbg( "%d usable file descriptors", globalPeerLimit );
|
||||
|
||||
for( i = 0; i < TR_MAX_OPEN_FILES; ++i )
|
||||
|
|
Loading…
Add table
Reference in a new issue