Explorar el Código

Merge branch 'newhub' into next

* newhub:
  * Don't rewrite binary / notify bots if the hubs didn't change
  * Signal child leaf bots to reread the binary (new hubs) when writing userfile
Bryan Drewery hace 14 años
padre
commit
30be80f687
Se han modificado 1 ficheros con 12 adiciones y 1 borrados
  1. 12 1
      src/conf.c

+ 12 - 1
src/conf.c

@@ -1024,7 +1024,7 @@ bin_to_conf(bool error)
 }
 
 void conf_update_hubs(struct userrec* list) {
-  bd::Array<bd::String> hubUsers;
+  bd::Array<bd::String> hubUsers, oldhubs(conf.hubs);
 
   // Count how many hubs there are
   for (struct userrec *u = list; u; u = u->next) {
@@ -1041,9 +1041,20 @@ void conf_update_hubs(struct userrec* list) {
     conf.hubs << bd::String::printf("%s %s %d %d", u->handle, bi->address, bi->telnet_port, bi->hublevel);
   }
 
+  // Only rewrite binary / notify bots if the hubs changed
+  if (conf.hubs == oldhubs) {
+    return;
+  }
+
   if (conf.bot->hub || conf.bot->localhub) {
     /* rewrite our binary */
     conf_to_bin(&conf, 0, -1);
+
+    /* Now signal all of the old bots with SIGUSR1
+     * They will auto die and determine new localhub, etc..
+     */
+    conf_checkpids(conf.bots);
+    conf_killbot(conf.bots, conf.bot->nick, NULL, SIGUSR1, 1); /* Don't kill me. */
   }
 }