/*
- * "$Id: listen.c 6649 2007-07-11 21:46:42Z mike $"
+ * "$Id: listen.c 7918 2008-09-08 22:03:01Z mike $"
*
* Server listening routines for the Common UNIX Printing System (CUPS)
* scheduler.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
if (cupsArrayCount(Clients) == MaxClients)
cupsdLogMessage(CUPSD_LOG_WARN,
"Max clients reached, holding new connections...");
+ else if (errno == ENFILE || errno == EMFILE)
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Too many open files, holding new connections for "
+ "30 seconds...");
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdPauseListening: Clearing input bits...");
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
cupsdRemoveSelect(lis->fd);
+
+ ListeningPaused = time(NULL) + 30;
}
if (cupsArrayCount(Listeners) < 1)
return;
- if (cupsArrayCount(Clients) >= (MaxClients - 1))
- cupsdLogMessage(CUPSD_LOG_WARN, "Resuming new connection processing...");
-
+ cupsdLogMessage(CUPSD_LOG_INFO, "Resuming new connection processing...");
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdResumeListening: Setting input bits...");
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
cupsdAddSelect(lis->fd, (cupsd_selfunc_t)cupsdAcceptClient, NULL, lis);
+
+ ListeningPaused = 0;
}
httpAddrFreeList(ServerAddrs);
if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL)
+ {
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to find IP address for server name \"%s\"!\n",
+ "Unable to find IP address for server name \"%s\"!",
ServerName);
+ if (FatalErrors & CUPSD_FATAL_LISTEN)
+ cupsdEndProcess(getpid(), 0);
+ }
+
/*
* Setup socket listeners...
*/
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to open listen socket for address %s:%d - %s.",
s, p, strerror(errno));
+
+#ifdef AF_INET6
+ /*
+ * IPv6 is often disabled while DNS returns IPv6 addresses...
+ */
+
+ if (lis->address.addr.sa_family != AF_INET6 &&
+ (FatalErrors & CUPSD_FATAL_LISTEN))
+ cupsdEndProcess(getpid(), 0);
+#else
+ if (FatalErrors & CUPSD_FATAL_LISTEN)
+ cupsdEndProcess(getpid(), 0);
+#endif /* AF_INET6 */
+
continue;
}
s, p, strerror(errno));
close(lis->fd);
lis->fd = -1;
+
+ if (FatalErrors & CUPSD_FATAL_LISTEN)
+ cupsdEndProcess(getpid(), 0);
+
continue;
}
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to listen for clients on address %s:%d - %s.",
s, p, strerror(errno));
- exit(errno);
+
+ close(lis->fd);
+ lis->fd = -1;
+
+ if (FatalErrors & CUPSD_FATAL_LISTEN)
+ cupsdEndProcess(getpid(), 0);
+
+ continue;
}
}
"No Listen or Port lines were found to allow access via "
"localhost!");
- /*
- * Commit suicide...
- */
-
- cupsdEndProcess(getpid(), 0);
+ if (FatalErrors & (CUPSD_FATAL_CONFIG | CUPSD_FATAL_LISTEN))
+ cupsdEndProcess(getpid(), 0);
}
/*
/*
- * End of "$Id: listen.c 6649 2007-07-11 21:46:42Z mike $".
+ * End of "$Id: listen.c 7918 2008-09-08 22:03:01Z mike $".
*/