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

* Only avoid cycling if possible

Bryan Drewery 16 лет назад
Родитель
Сommit
36f1c0ee3b
4 измененных файлов с 18 добавлено и 11 удалено
  1. 1 1
      src/chanprog.c
  2. 2 1
      src/chanprog.h
  3. 5 1
      src/misc.c
  4. 10 8
      src/mod/share.mod/share.c

+ 1 - 1
src/chanprog.c

@@ -63,7 +63,7 @@ char 			origbotname[NICKLEN] = "";	/* Nick to regain */
 char                    jupenick[NICKLEN] = "";
 char                    jupenick[NICKLEN] = "";
 char 			botname[NICKLEN] = "";	/* IRC nickname */
 char 			botname[NICKLEN] = "";	/* IRC nickname */
 port_t     		my_port = 0;
 port_t     		my_port = 0;
-bool			reset_chans = 0;
+int			reset_chans = 0;
 bool                    cookies_disabled = 0;
 bool                    cookies_disabled = 0;
 char s2_4[3] = "",s1_6[3] = "",s1_11[3] = "";
 char s2_4[3] = "",s1_6[3] = "",s1_11[3] = "";
 
 

+ 2 - 1
src/chanprog.h

@@ -36,6 +36,7 @@ void setup_HQ(int);
 extern struct chanset_t		*chanset, *chanset_default;
 extern struct chanset_t		*chanset, *chanset_default;
 extern char			admin[], origbotnick[HANDLEN + 1], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
 extern char			admin[], origbotnick[HANDLEN + 1], origbotname[NICKLEN], jupenick[NICKLEN], botname[NICKLEN], *def_chanset;
 extern port_t			my_port;
 extern port_t			my_port;
-extern bool			reset_chans, cookies_disabled;
+extern int			reset_chans;
+extern bool			cookies_disabled;
 
 
 #endif /* !_CHANPROG_H */
 #endif /* !_CHANPROG_H */

+ 5 - 1
src/misc.c

@@ -637,6 +637,8 @@ readsocks(const char *fname)
   stream.loadFile(fname);
   stream.loadFile(fname);
   bd::String str, type;
   bd::String str, type;
 
 
+  reset_chans = 0;
+
   while (stream.tell() < stream.length()) {
   while (stream.tell() < stream.length()) {
     str = stream.getline().chomp();
     str = stream.getline().chomp();
 //    dprintf(DP_DEBUG, "read line: %s\n", str.c_str());
 //    dprintf(DP_DEBUG, "read line: %s\n", str.c_str());
@@ -660,6 +662,7 @@ readsocks(const char *fname)
       chan->ircnet_status = atoi(ircnet_status.c_str());
       chan->ircnet_status = atoi(ircnet_status.c_str());
       chan->ircnet_status &= ~(CHAN_ACTIVE);
       chan->ircnet_status &= ~(CHAN_ACTIVE);
       chan->ircnet_status |= CHAN_PEND;
       chan->ircnet_status |= CHAN_PEND;
+      reset_chans = 2;
     }
     }
     else if (type == STR("+buildts"))
     else if (type == STR("+buildts"))
       old_buildts = strtol(str.c_str(), NULL, 10);
       old_buildts = strtol(str.c_str(), NULL, 10);
@@ -705,7 +708,8 @@ readsocks(const char *fname)
         replay_cache(servidx, NULL);
         replay_cache(servidx, NULL);
       else
       else
         dprintf(DP_DUMP, "VERSION\n");
         dprintf(DP_DUMP, "VERSION\n");
-      reset_chans = 1;
+      if (!reset_chans)
+        reset_chans = 1;
     }
     }
   }
   }
   delete[] nick;
   delete[] nick;

+ 10 - 8
src/mod/share.mod/share.c

@@ -1452,15 +1452,17 @@ static void share_read_stream(int idx, bd::Stream& stream) {
 
 
   /* If this is ever changed, do mind the restarting bool as it will prevent 001 from dumping JOINs.. */
   /* If this is ever changed, do mind the restarting bool as it will prevent 001 from dumping JOINs.. */
   if (reset_chans) {
   if (reset_chans) {
-    reset_chans = 0;
-    putlog(LOG_DEBUG, "*", "Resetting channel info for all channels...");
-    for (chan = chanset; chan; chan = chan->next) {
-      if (shouldjoin(chan) && channel_pending(chan)) { // Set when reading socksfile
-        chan->ircnet_status &= ~(CHAN_PEND); // Reset flags to force a reset
-        reset_chan_info(chan);
+    if (reset_chans == 2) {
+      putlog(LOG_DEBUG, "*", "Resetting channel info for all channels...");
+      for (chan = chanset; chan; chan = chan->next) {
+        if (shouldjoin(chan) && channel_pending(chan)) { // Set when reading socksfile
+          chan->ircnet_status &= ~(CHAN_PEND); // Reset flags to force a reset
+          reset_chan_info(chan);
+        }
       }
       }
-    }
-//    join_chans();
+    } else
+      join_chans();
+    reset_chans = 0;
   }
   }
 }
 }