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

* Port [2980] to 1.2.11
* Fix some minor bugs with cmd_conf. (fixes #284)


svn: 2981

Bryan Drewery 20 лет назад
Родитель
Сommit
180633c414
5 измененных файлов с 27 добавлено и 6 удалено
  1. 1 0
      doc/UPDATES
  2. 4 1
      src/cmds.c
  3. 19 4
      src/conf.c
  4. 2 1
      src/conf.h
  5. 1 0
      src/main.c

+ 1 - 0
doc/UPDATES

@@ -18,6 +18,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fix ban/invite/exempt removal flaw. (fixes #280)
 * Clean and speedup ban/exempt/invite processing. (addresses #277)
 * Fix processing of localhubs when binary is editted. (fixes #274)
+* Fix some minor bugs with cmd_conf. (fixes #284)
 
 1.2.10 - http://tracker.shatow.net/milestone/1.2.10
 * Removed old references to '+/-manop' and '+/-nomop' for chaninfo in help file.

+ 4 - 1
src/cmds.c

@@ -1747,13 +1747,15 @@ static void cmd_conf(int idx, char *par)
 #endif /* !CYGWIN_HACKS */
 
   if (listbot || !egg_strcasecmp(cmd, "list")) {
+    conf_checkpids();
     conf_bot *bot = NULL;
     unsigned int i = 0;
 
     for (bot = conf.bots; bot && bot->nick; bot = bot->next) {
       i++;
       if (!listbot || (listbot && !egg_strcasecmp(listbot, bot->nick)))
-        dprintf(idx, "%d: %s IP: %s HOST: %s IP6: %s HOST6: %s HUB: %d PID: %d\n", i,
+        dprintf(idx, "%d: %s%s IP: %s HOST: %s IP6: %s HOST6: %s HUB: %d PID: %d\n", i,
+                      bot->disabled ? "/" : "",
                       bot->nick,
                       bot->net.ip ? bot->net.ip : "",
                       bot->net.host ? bot->net.host : "",
@@ -1774,6 +1776,7 @@ static void cmd_conf(int idx, char *par)
     conf_add_userlist_bots();
     conf_checkpids();
     spawnbots(1);
+    conf_checkpids(0);
   }
 
   free_conf_bots(oldlist);

+ 19 - 4
src/conf.c

@@ -107,9 +107,10 @@ spawnbots(bool rehashed)
 
     if (bot->disabled) {
       /* kill it if running */
-      if (bot->pid)
+      if (bot->pid) {
         kill(bot->pid, SIGKILL);
-      else
+        bot->pid = 0;
+      } else
         continue;
     /* if we're updating automatically, we were called with -u and are only supposed to kill non-localhubs
       -if updating and we find our nick, skip
@@ -413,12 +414,13 @@ static void conf_compat_pids()
   }  
 }
 
-void conf_checkpids()
+void conf_checkpids(bool all)
 {
   conf_bot *bot = NULL;
 
   for (bot = conf.bots; bot && bot->nick; bot = bot->next)
-    bot->pid = checkpid(bot->nick, bot, NULL);
+    if (all || (!all && bot->pid == 0))
+      bot->pid = checkpid(bot->nick, bot, NULL);
 }
 
 /*
@@ -1213,3 +1215,16 @@ conf_bot *conf_getlocalhub(conf_bot *bots) {
 
   return !localhub->disabled ? localhub : NULL;
 }
+
+
+void conf_setmypid(pid_t pid) {
+  conf.bot->pid = pid;
+  conf_bot *bot = conf.bots;
+  if (conf.bots) {
+    for (; bot && strcmp(bot->nick, conf.bot->nick); bot = bot->next)
+     ;
+    if (bot)
+      bot->pid = pid;
+  }
+}
+  

+ 2 - 1
src/conf.h

@@ -69,11 +69,12 @@ int parseconf(bool);
 int writeconf(char *, FILE *, int);
 void fill_conf_bot();
 void bin_to_conf(bool error = 0);
-void conf_checkpids();
+void conf_checkpids(bool all = 1);
 void conf_add_userlist_bots();
 conf_bot *conf_bots_dup(conf_bot *);
 void kill_removed_bots(conf_bot *, conf_bot *);
 conf_bot *conf_getlocalhub(conf_bot *);
+void conf_setmypid(pid_t);
 
 #ifdef CYGWIN_HACKS
 extern char		cfile[DIRMAX];

+ 1 - 0
src/main.c

@@ -812,6 +812,7 @@ printf("out: %s\n", out);
 #ifndef CYGWIN_HACKS
     if (!socksfile) {
       mypid = do_fork();
+  conf_setmypid(mypid);
 
 /*
     printf("  |- %-10s (%d)\n", conf.bot->nick, pid);