Răsfoiți Sursa

* Added actually support for refreshing binary on SIGUSR1 in get_checksum

svn: 1880
Bryan Drewery 21 ani în urmă
părinte
comite
f45c76868b
3 a modificat fișierele cu 26 adăugiri și 3 ștergeri
  1. 24 0
      src/binary.c
  2. 1 1
      src/conf.c
  3. 1 2
      src/debug.c

+ 24 - 0
src/binary.c

@@ -75,6 +75,30 @@ bin_checksum(const char *fname, int todo)
     OPENSSL_cleanse(&ctx, sizeof(ctx));
   }
 
+  if (todo == GET_CONF) {
+    char *oldhash = strdup(settings.hash);
+
+    if (!(f = fopen(fname, "rb")))
+      werr(ERR_BINSTAT);
+
+    while ((len = fread(buf, 1, sizeof buf - 1, f)))
+      if (!memcmp(buf, &settings.prefix, PREFIXLEN))
+        break;
+
+    char *tmpbuf = (char *) calloc(1, SIZE_PACK);
+ 
+    if ((len = fread(tmpbuf, 1, SIZE_PACK, f))) {
+      edpack(&settings, oldhash, PACK_ENC);
+      len = fread(&settings.bots, 1, SIZE_CONF, f);
+      edpack(&settings, oldhash, PACK_DEC);
+    } else
+      return NULL;
+
+    free(oldhash);
+    fclose(f);
+    return settings.hash;
+  }
+
   if (todo & WRITE_CHECKSUM) {
     Tempfile *newbin = new Tempfile("bin");
     char *fname_bak = NULL;

+ 1 - 1
src/conf.c

@@ -448,6 +448,7 @@ free_conf()
 {
   free_conf_bots();
   free_bot(conf.bot);
+  conf.bot = NULL;
   free(conf.localhub);
   free(conf.uname);
   free(conf.username);
@@ -804,7 +805,6 @@ fill_conf_bot()
     werr(ERR_BADBOT);
 
   free(mynick);
-
   /* for future, we may just want to make this a pointer to ->bots if we do an emech style currentbot-> */
   conf.bot = (conf_bot *) my_calloc(1, sizeof(conf_bot));
   conf_bot_dup(conf.bot, me);

+ 1 - 2
src/debug.c

@@ -287,8 +287,7 @@ got_hup(int z)
 static void
 got_usr1(int z)
 {
-  putlog(LOG_MISC, "*", "GOT SIGUSR1 -- RECHECKING BINARY");
-  
+  putlog(LOG_DEBUG, "*", "GOT SIGUSR1 -- RECHECKING BINARY");
   reload_bin_data();
 }