Changeset 7138


Ignore:
Timestamp:
Nov 23, 2008, 5:05:44 PM (12 years ago)
Author:
charles
Message:

(libT) revert r7099 based on forum feedback @ <http://forum.transmissionbt.com/viewtopic.php?f=4&t=6485>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r7129 r7138  
    2323 *****************************************************************************/
    2424
     25#ifndef WIN32
     26 #define HAVE_GETRLIMIT
     27#endif
     28
    2529#include <assert.h>
    2630#include <errno.h>
     
    3943#include <sys/types.h>
    4044#include <sys/stat.h>
     45#ifdef HAVE_GETRLIMIT
     46 #include <sys/time.h> /* getrlimit */
     47 #include <sys/resource.h> /* getrlimit */
     48#endif
    4149#include <unistd.h>
    4250#include <fcntl.h> /* O_LARGEFILE */
     
    532540    gFd = tr_new0( struct tr_fd_s, 1 );
    533541    gFd->lock = tr_lockNew( );
     542
     543#ifdef HAVE_GETRLIMIT
     544    {
     545        struct rlimit rlim;
     546        getrlimit( RLIMIT_NOFILE, &rlim );
     547        rlim.rlim_cur = MIN( rlim.rlim_max,
     548                            (rlim_t)( globalPeerLimit + NOFILE_BUFFER ) );
     549        setrlimit( RLIMIT_NOFILE, &rlim );
     550        gFd->socketMax = rlim.rlim_cur - NOFILE_BUFFER;
     551        tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur );
     552    }
     553#else
    534554    gFd->socketMax = globalPeerLimit;
     555#endif
    535556    tr_dbg( "%d usable file descriptors", globalPeerLimit );
    536557
Note: See TracChangeset for help on using the changeset viewer.