]> granicus.if.org Git - transmission/commitdiff
eliminate the clamp function for now, allow peer connections once again
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 21 Dec 2009 14:30:43 +0000 (14:30 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 21 Dec 2009 14:30:43 +0000 (14:30 +0000)
libtransmission/fdlimit.c

index 75a2f852a64a96ffdb59f11f2e2514b5ffe91167..10c4456a49c25d137893f2500b879dec59249560 100644 (file)
@@ -815,13 +815,6 @@ tr_fdGetFileLimit( const tr_session * session )
 {
     return session && session->fdInfo ? session->fdInfo->openFileLimit : -1;
 }
-
-static TR_INLINE int clamp( int val, int lo, int hi )
-{
-    if( val < lo ) val = lo;
-    if( val > hi ) val = hi;
-    return val;
-}
     
 
 void
@@ -839,7 +832,7 @@ tr_fdSetPeerLimit( tr_session * session, int socketLimit )
         const int NOFILE_BUFFER = 512;
         const int open_max = sysconf( _SC_OPEN_MAX );
         getrlimit( RLIMIT_NOFILE, &rlim );
-        rlim.rlim_cur = clamp( open_max, 1024, rlim.rlim_max );
+        rlim.rlim_cur = MIN( MAX( 1024, open_max ), rlim.rlim_max );
         setrlimit( RLIMIT_NOFILE, &rlim );
         tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur );
         gFd->socketLimit = MIN( socketLimit, (int)rlim.rlim_cur - NOFILE_BUFFER );