Просмотр исходного кода

* Raised maxdcc and maxfd to 300
* Attempt to close fd when >= 50
Auto-restart if >= 150 are detected.
Warn every 10 fd between 100 and 150


svn: 1389

Bryan Drewery 21 лет назад
Родитель
Сommit
659fa81c8b
5 измененных файлов с 23 добавлено и 26 удалено
  1. 2 0
      doc/UPDATES
  2. 1 6
      src/dccutil.c
  3. 2 2
      src/debug.c
  4. 1 1
      src/net.c
  5. 17 17
      src/shell.c

+ 2 - 0
doc/UPDATES

@@ -49,6 +49,8 @@ This is a summary of ChangeLog basically.
 * cmd_chaninfo/chanset didn't check for +private access correctly.
 * cmd_chaninfo/chanset didn't check for +private access correctly.
 * hubs now enforce binpath/binname as leaf bots do.
 * hubs now enforce binpath/binname as leaf bots do.
 * Made a solution to what to do when the fds max, from 100-130, bot will WARN once a min, >=180 -> auto restart.
 * Made a solution to what to do when the fds max, from 100-130, bot will WARN once a min, >=180 -> auto restart.
+* Raised max dcc/fd to 300.
+* Bots will auto-restart if 150 or more bogus fd are detected.
 
 
 1.1.9
 1.1.9
 
 

+ 1 - 6
src/dccutil.c

@@ -31,12 +31,7 @@ static struct portmap 	*root = NULL;
 
 
 time_t	connect_timeout = 15;		/* How long to wait before a telnet
 time_t	connect_timeout = 15;		/* How long to wait before a telnet
 					   connection times out */
 					   connection times out */
-#ifdef HUB
-int         max_dcc = 200;
-#endif /* HUB */
-#ifdef LEAF
-int         max_dcc = 30;
-#endif /* LEAF */
+int         max_dcc = 299;
 
 
 static int         dcc_flood_thr = 3;
 static int         dcc_flood_thr = 3;
 
 

+ 2 - 2
src/debug.c

@@ -66,8 +66,8 @@ void setlimits()
 #endif /* !DEBUG_MEM */
 #endif /* !DEBUG_MEM */
   setrlimit(RLIMIT_CORE, &corelim);
   setrlimit(RLIMIT_CORE, &corelim);
   setrlimit(RLIMIT_NPROC, &plim);
   setrlimit(RLIMIT_NPROC, &plim);
-  fdlim.rlim_cur = 200;
-  fdlim.rlim_max = 200;
+  fdlim.rlim_cur = 300;
+  fdlim.rlim_max = 300;
   setrlimit(RLIMIT_NOFILE, &fdlim);
   setrlimit(RLIMIT_NOFILE, &fdlim);
 #endif /* !CYGWIN_HACKS */
 #endif /* !CYGWIN_HACKS */
 }
 }

+ 1 - 1
src/net.c

@@ -1511,7 +1511,7 @@ void tputs(register int z, char *s, size_t len)
 int findanysnum(register int sock)
 int findanysnum(register int sock)
 {
 {
   if (sock != -1)
   if (sock != -1)
-    for (int i = 0; i < MAXSOCKS; i++)
+    for (int i = 0; i < socks_total; i++)
       if ((socklist[i].sock == sock) && !(socklist[i].flags & SOCK_UNUSED))
       if ((socklist[i].sock == sock) && !(socklist[i].flags & SOCK_UNUSED))
         return i;
         return i;
 
 

+ 17 - 17
src/shell.c

@@ -107,32 +107,32 @@ int clear_tmp()
 #ifdef LEAF
 #ifdef LEAF
 void check_maxfiles()
 void check_maxfiles()
 {
 {
-  char file[DIRMAX] = "";
-  int fd, nondcc = 0, failed_close = 0;
+  int sock = -1, sock1 = -1 , bogus = 0, failed_close = 0;
 
 
-  sprintf(file, "%s.%lu", tempdir, randint(10000));
-
-  fd = open(file, O_WRONLY | O_CREAT, 0);
-
-  if (fd == -1)
+  sock1 = getsock(0, AF_INET);		/* fill up any lower avail */
+  sock = getsock(0, AF_INET);
+  
+  if (sock == -1)
     fatal("MAXFD reached.", 0);		/* this shouldnt happen */
     fatal("MAXFD reached.", 0);		/* this shouldnt happen */
-  else {
-    close(fd);
-    unlink(file);
-  }
+  else
+    killsock(sock);
+  if (sock1 != -1)
+    killsock(sock1);
+  bogus = sock - socks_total;	
 
 
-  nondcc = fd - dcc_total;		/* nondcc will be the total of BOGUS fd */
+  sdprintf("SOCK: %d BOGUS: %d SOCKS_TOTAL: %d", sock, bogus, socks_total);
 
 
-  if (nondcc >= 50) {			/* Attempt to close them */
-    for (int i = 0; i < fd; i++)
-      if (!findanyidx(i))
+  if (bogus >= 50) {			/* Attempt to close them */
+    for (int i = 10; i < sock; i++)	/* dont close lower sockets, they're probably legit */
+      if (!findanysnum(i))
         if ((close(i)) == -1)			/* try to close the BOGUS fd (likely a KQUEUE) */
         if ((close(i)) == -1)			/* try to close the BOGUS fd (likely a KQUEUE) */
           failed_close++;
           failed_close++;
-
-    if (failed_close >= 50) {
+    if (bogus >= 150 || failed_close >= 50) {
       nuke_server("Max FD reached, restarting...");
       nuke_server("Max FD reached, restarting...");
       cycle_time = 0;
       cycle_time = 0;
       restart(-1);
       restart(-1);
+    } else if (bogus >= 100 && (bogus % 10) == 0) {
+      putlog(LOG_WARN, "*", "* WARNING: $b%d$b bogus file descriptors detected, auto restart at 150", bogus);
     }
     }
   }
   }
 }
 }