Configuration fixes. Repair automatic outbound connects.
[ircu2.10.12-pk.git] / ircd / ircd.c
index 363903ebdde8a37f30a4b5e9f8f18d85324795db..d43f2b33062d8cb12d845f194705b6d84063fe39 100644 (file)
@@ -260,7 +260,6 @@ static void try_connections(struct Event* ev) {
      */
     if (!(aconf->status & CONF_SERVER)
         || aconf->address.port == 0
-        || aconf->hold == 0
         || ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe)))
       continue;
 
@@ -278,11 +277,10 @@ static void try_connections(struct Event* ev) {
      * or if connect rules forbid a link now.
      */
     if (hold
-        || (Links(cltmp) >= MaxLinks(cltmp))
+        || (Links(cltmp) > MaxLinks(cltmp))
         || FindServer(aconf->name)
-        || conf_eval_crule(aconf->name, CRULE_MASK)) {
+        || conf_eval_crule(aconf->name, CRULE_MASK))
       continue;
-    }
 
     /* Ensure it is at the end of the list for future checks. */
     if (aconf->next) {
@@ -464,7 +462,7 @@ static void parse_command_line(int argc, char** argv) {
    */
   while ((opt = getopt(argc, argv, options)) != EOF)
     switch (opt) {
-    case 'k':  thisServer.bootopt |= BOOT_CHKCONF;     break;
+    case 'k':  thisServer.bootopt |= BOOT_CHKCONF | BOOT_TTY; break;
     case 'n':
     case 't':  thisServer.bootopt |= BOOT_TTY;         break;
     case 'd':  dpath      = optarg;                    break;
@@ -639,6 +637,11 @@ int main(int argc, char **argv) {
 
   close_connections(!(thisServer.bootopt & (BOOT_DEBUG | BOOT_TTY | BOOT_CHKCONF)));
 
+  /* daemon_init() must be before event_init() because kqueue() FDs
+   * are, perversely, not inherited across fork().
+   */
+  daemon_init(thisServer.bootopt & BOOT_TTY);
+
   event_init(MAXCONNECTIONS);
 
   setup_signals();
@@ -677,7 +680,6 @@ int main(int argc, char **argv) {
   }
 
   debug_init(thisServer.bootopt & BOOT_TTY);
-  daemon_init(thisServer.bootopt & BOOT_TTY);
   if (check_pid()) {
     Debug((DEBUG_FATAL, "Failed to acquire PID file lock after fork"));
     exit(2);