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

* Sort of a solution to the max fd problem

svn: 1379
Bryan Drewery 21 лет назад
Родитель
Сommit
b64bec7fbe
5 измененных файлов с 31 добавлено и 1 удалено
  1. 2 1
      doc/UPDATES
  2. 1 0
      src/main.c
  3. 1 0
      src/misc.c
  4. 26 0
      src/shell.c
  5. 1 0
      src/shell.h

+ 2 - 1
doc/UPDATES

@@ -46,8 +46,9 @@ This is a summary of ChangeLog basically.
 * Simple autoaway on dcc after 10 minutes, will be customizable in the future.
 * Fixed a problem with what ip was bined when using '.' as the ip.
 * Fixed some problems with special characters in conf files.
-* 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.
+* Made a solution to what to do when the fds max, from 100-130, bot will WARN once a min, >=180 -> auto restart.
 
 1.1.9
 

+ 1 - 0
src/main.c

@@ -500,6 +500,7 @@ static void core_minutely()
   send_timesync(-1);
 #endif /* HUB */
 #ifdef LEAF
+  check_maxfiles();
   check_mypid();
 #endif
   check_bind_time(&nowtm);

+ 1 - 0
src/misc.c

@@ -606,6 +606,7 @@ restart(int idx)
 #endif /* HUB */
 #ifdef LEAF
   nuke_server((char *) reason);		/* let's drop the server connection ASAP */
+  cycle_time = 0;
 #endif /* LEAF */
   if (tands > 0) {
     botnet_send_chat(-1, conf.bot->nick, (char *) reason);

+ 26 - 0
src/shell.c

@@ -104,6 +104,32 @@ int clear_tmp()
 }
 
 #ifdef LEAF
+void check_maxfiles()
+{
+  char file[DIRMAX] = "";
+  int fd;
+
+  sprintf(file, "%s.%d", tempdir, randint(10000));
+
+  fd = open(file, O_WRONLY | O_CREAT, 0);
+
+  if (fd == -1)
+    fatal("MAXFD reached.", 0);		/* this shouldnt happen */
+  else {
+    close(fd);
+    unlink(file);
+  }
+
+  if (fd >= 100 && fd <= 130)		/* a warning range */
+    putlog(LOG_MISC, "* Warning, FD:%d, at >=180, the bot will auto restart", fd);
+
+  if (fd >= 180) {
+    nuke_server("Max FD reached, restarting...");
+    cycle_time = 0;
+    restart(-1);
+  }
+}
+
 void check_mypid()
 { 
   pid_t pid = 0;

+ 1 - 0
src/shell.h

@@ -40,6 +40,7 @@
 #define DET_DIE 	3
 #define DET_SUICIDE 	4
 
+void check_maxfiles();
 void check_mypid();
 int clear_tmp();
 char *homedir();