-CHANGES.txt - 02/03/2003
+CHANGES.txt - 02/05/2003
------------------------
CHANGES IN CUPS V1.1.19
+ - The scheduler now allocates its select() sets to
+ support larger numbers of clients on systems that
+ support it.
- The scheduler now sets the CFProcessPath environment
variable under MacOS X.
- The cupsLangDefault() function now uses the
/*
- * "$Id: client.c,v 1.142 2003/02/03 02:33:42 mike Exp $"
+ * "$Id: client.c,v 1.143 2003/02/05 21:10:15 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
LogMessage(L_DEBUG2, "AcceptClient: Adding fd %d to InputSet...",
con->http.fd);
- FD_SET(con->http.fd, &InputSet);
+ FD_SET(con->http.fd, InputSet);
NumClients ++;
LogMessage(L_DEBUG2, "CloseClient: Removing fd %d from InputSet and OutputSet...",
con->http.fd);
close(con->http.fd);
- FD_CLR(con->http.fd, &InputSet);
- FD_CLR(con->http.fd, &OutputSet);
+ FD_CLR(con->http.fd, InputSet);
+ FD_CLR(con->http.fd, OutputSet);
con->http.fd = 0;
}
{
LogMessage(L_DEBUG2, "CloseClient: Removing fd %d from InputSet...",
con->file);
- FD_CLR(con->file, &InputSet);
+ FD_CLR(con->file, InputSet);
}
if (con->file)
LogMessage(L_DEBUG2, "CloseClient: %d Removing fd %d from InputSet.",
con->http.fd, con->file);
- FD_CLR(con->file, &InputSet);
+ FD_CLR(con->file, InputSet);
close(con->file);
con->file = 0;
}
LogMessage(L_DEBUG2, "SendCommand: Adding fd %d to OutputSet...",
con->http.fd);
- FD_SET(con->file, &InputSet);
- FD_SET(con->http.fd, &OutputSet);
+ FD_SET(con->file, InputSet);
+ FD_SET(con->http.fd, OutputSet);
if (!SendHeader(con, HTTP_OK, NULL))
return (0);
LogMessage(L_DEBUG2, "SendFile: Adding fd %d to OutputSet...", con->http.fd);
- FD_SET(con->http.fd, &OutputSet);
+ FD_SET(con->http.fd, OutputSet);
return (1);
}
LogMessage(L_DEBUG2, "ShutdownClient: Removing fd %d from InputSet...",
con->http.fd);
- FD_CLR(con->http.fd, &InputSet);
+ FD_CLR(con->http.fd, InputSet);
}
LogMessage(L_DEBUG2, "WriteClient: Removing fd %d from OutputSet...",
con->http.fd);
- FD_CLR(con->http.fd, &OutputSet);
+ FD_CLR(con->http.fd, OutputSet);
if (con->file)
{
LogMessage(L_DEBUG2, "WriteClient: Removing fd %d from InputSet...",
con->file);
- FD_CLR(con->file, &InputSet);
+ FD_CLR(con->file, InputSet);
if (con->pipe_pid)
kill(con->pipe_pid, SIGTERM);
/*
- * End of "$Id: client.c,v 1.142 2003/02/03 02:33:42 mike Exp $".
+ * End of "$Id: client.c,v 1.143 2003/02/05 21:10:15 mike Exp $".
*/
/*
- * "$Id: conf.c,v 1.123 2003/02/04 19:02:25 mike Exp $"
+ * "$Id: conf.c,v 1.124 2003/02/05 21:10:15 mike Exp $"
*
* Configuration routines for the Common UNIX Printing System (CUPS).
*
#include <stdarg.h>
#include <pwd.h>
#include <grp.h>
-#include <sys/resource.h>
#ifdef HAVE_CDSASSL
# include <Security/SecureTransport.h>
*slash; /* Directory separator */
char type[MIME_MAX_SUPER + MIME_MAX_TYPE];
/* MIME type name */
- struct rlimit limit; /* Runtime limit */
char *language; /* Language string */
struct passwd *user; /* Default user */
struct group *group; /* Default group */
* Check the MaxClients setting, and then allocate memory for it...
*/
- getrlimit(RLIMIT_NOFILE, &limit);
+ if (MaxClients > (MaxFDs / 3) || MaxClients <= 0)
+ {
+ if (MaxClients > 0)
+ LogMessage(L_INFO, "MaxClients limited to 1/3 of the file descriptor limit (%d)...",
+ MaxFDs);
- if (MaxClients > (limit.rlim_max / 3) || MaxClients <= 0)
- MaxClients = limit.rlim_max / 3;
+ MaxClients = MaxFDs / 3;
+ }
if ((Clients = calloc(sizeof(client_t), MaxClients)) == NULL)
{
/*
- * End of "$Id: conf.c,v 1.123 2003/02/04 19:02:25 mike Exp $".
+ * End of "$Id: conf.c,v 1.124 2003/02/05 21:10:15 mike Exp $".
*/
/*
- * "$Id: cupsd.h,v 1.41 2003/01/29 19:54:50 mike Exp $"
+ * "$Id: cupsd.h,v 1.42 2003/02/05 21:10:15 mike Exp $"
*
* Main header file for the Common UNIX Printing System (CUPS) scheduler.
*
* WWW: http://www.cups.org
*/
+/*
+ * Define FD_SETSIZE to 2048; on platforms that support this, this will
+ * ensure that the correct version of select() is used for large numbers
+ * of file descriptors.
+ */
+
+#define FD_SETSIZE 2048
+
+
/*
* Include necessary headers.
*/
* Globals...
*/
-VAR int MaxFDs; /* Maximum number of files */
-VAR fd_set InputSet, /* Input files for select() */
- OutputSet; /* Output files for select() */
+VAR int MaxFDs, /* Maximum number of files */
+ SetSize; /* The size of the input/output sets */
+VAR fd_set *InputSet, /* Input files for select() */
+ *OutputSet; /* Output files for select() */
VAR int NeedReload VALUE(TRUE);
/* Need to load configuration? */
/*
- * End of "$Id: cupsd.h,v 1.41 2003/01/29 19:54:50 mike Exp $".
+ * End of "$Id: cupsd.h,v 1.42 2003/02/05 21:10:15 mike Exp $".
*/
/*
- * "$Id: dirsvc.c,v 1.107 2003/01/31 01:26:31 mike Exp $"
+ * "$Id: dirsvc.c,v 1.108 2003/02/05 21:10:16 mike Exp $"
*
* Directory services routines for the Common UNIX Printing System (CUPS).
*
LogMessage(L_DEBUG2, "StartBrowsing: Adding fd %d to InputSet...",
BrowseSocket);
- FD_SET(BrowseSocket, &InputSet);
+ FD_SET(BrowseSocket, InputSet);
}
#ifdef HAVE_LIBSLP
LogMessage(L_DEBUG2, "StartPolling: Adding fd %d to InputSet...",
PollPipe);
- FD_SET(PollPipe, &InputSet);
+ FD_SET(PollPipe, InputSet);
}
LogMessage(L_DEBUG2, "StopBrowsing: Removing fd %d from InputSet...",
BrowseSocket);
- FD_CLR(BrowseSocket, &InputSet);
+ FD_CLR(BrowseSocket, InputSet);
BrowseSocket = 0;
}
}
LogMessage(L_DEBUG2, "StopPolling: removing fd %d from InputSet.",
PollPipe);
- FD_CLR(PollPipe, &InputSet);
+ FD_CLR(PollPipe, InputSet);
PollPipe = -1;
}
/*
- * End of "$Id: dirsvc.c,v 1.107 2003/01/31 01:26:31 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.108 2003/02/05 21:10:16 mike Exp $".
*/
/*
- * "$Id: ipp.c,v 1.186 2003/01/31 17:48:23 mike Exp $"
+ * "$Id: ipp.c,v 1.187 2003/02/05 21:10:16 mike Exp $"
*
* IPP routines for the Common UNIX Printing System (CUPS) scheduler.
*
LogMessage(L_DEBUG2, "ProcessIPPRequest: Adding fd %d to OutputSet...",
con->http.fd);
- FD_SET(con->http.fd, &OutputSet);
+ FD_SET(con->http.fd, OutputSet);
/*
* Tell the caller the response header was sent successfully...
/*
- * End of "$Id: ipp.c,v 1.186 2003/01/31 17:48:23 mike Exp $".
+ * End of "$Id: ipp.c,v 1.187 2003/02/05 21:10:16 mike Exp $".
*/
/*
- * "$Id: job.c,v 1.185 2003/02/04 05:27:23 mike Exp $"
+ * "$Id: job.c,v 1.186 2003/02/05 21:10:17 mike Exp $"
*
* Job management routines for the Common UNIX Printing System (CUPS).
*
LogMessage(L_DEBUG2, "StartJob: Adding fd %d to InputSet...", current->pipe);
- FD_SET(current->pipe, &InputSet);
+ FD_SET(current->pipe, InputSet);
}
current->pipe);
close(current->pipe);
- FD_CLR(current->pipe, &InputSet);
+ FD_CLR(current->pipe, InputSet);
current->pipe = 0;
}
job->pipe);
close(job->pipe);
- FD_CLR(job->pipe, &InputSet);
+ FD_CLR(job->pipe, InputSet);
job->pipe = 0;
}
/*
- * End of "$Id: job.c,v 1.185 2003/02/04 05:27:23 mike Exp $".
+ * End of "$Id: job.c,v 1.186 2003/02/05 21:10:17 mike Exp $".
*/
/*
- * "$Id: listen.c,v 1.16 2003/01/23 16:26:38 mike Exp $"
+ * "$Id: listen.c,v 1.17 2003/02/05 21:10:17 mike Exp $"
*
* Server listening routines for the Common UNIX Printing System (CUPS)
* scheduler.
listener_t *lis; /* Current listening socket */
- if (!FD_ISSET(Listeners[0].fd, &InputSet))
+ if (!FD_ISSET(Listeners[0].fd, InputSet))
return;
if (NumClients == MaxClients)
LogMessage(L_DEBUG2, "PauseListening: Removing fd %d from InputSet...",
lis->fd);
- FD_CLR(lis->fd, &InputSet);
+ FD_CLR(lis->fd, InputSet);
}
}
listener_t *lis; /* Current listening socket */
- if (FD_ISSET(Listeners[0].fd, &InputSet))
+ if (FD_ISSET(Listeners[0].fd, InputSet))
return;
if (NumClients >= (MaxClients - 1))
LogMessage(L_DEBUG2, "ResumeListening: Adding fd %d to InputSet...",
lis->fd);
- FD_SET(lis->fd, &InputSet);
+ FD_SET(lis->fd, InputSet);
}
}
/*
- * End of "$Id: listen.c,v 1.16 2003/01/23 16:26:38 mike Exp $".
+ * End of "$Id: listen.c,v 1.17 2003/02/05 21:10:17 mike Exp $".
*/
/*
- * "$Id: main.c,v 1.89 2003/01/31 01:26:32 mike Exp $"
+ * "$Id: main.c,v 1.90 2003/02/05 21:10:17 mike Exp $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
# include <malloc.h>
#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
-#ifndef FD_SETSIZE
-# define FD_SETSIZE 1024
-#endif /* !FD_SETSIZE */
-
/*
* Local functions...
int i; /* Looping var */
char *opt; /* Option character */
int fg; /* Run in the foreground */
- fd_set input, /* Input set for select() */
- output; /* Output set for select() */
+ fd_set *input, /* Input set for select() */
+ *output; /* Output set for select() */
client_t *con; /* Current client */
job_t *job, /* Current job */
*next; /* Next job */
*/
getrlimit(RLIMIT_NOFILE, &limit);
- if (limit.rlim_max > FD_SETSIZE) /* Can't exceed size of FD set! */
- MaxFDs = FD_SETSIZE;
- else
- MaxFDs = limit.rlim_max;
-
- limit.rlim_cur = MaxFDs;
+ limit.rlim_cur = MaxFDs = limit.rlim_max;
setrlimit(RLIMIT_NOFILE, &limit);
+ /*
+ * Allocate memory for the input and output sets...
+ */
+
+ SetSize = (MaxFDs + 7) / 8;
+ InputSet = (fd_set *)calloc(1, SetSize);
+ OutputSet = (fd_set *)calloc(1, SetSize);
+ input = (fd_set *)calloc(1, SetSize);
+ output = (fd_set *)calloc(1, SetSize);
+
+ if (InputSet == NULL || OutputSet == NULL || input == NULL || output == NULL)
+ {
+ syslog(LOG_LPR, "Unable to allocate memory for select() sets - exiting!");
+ return (1);
+ }
+
/*
* Catch hangup and child signals and ignore broken pipes...
*/
sigset(SIGHUP, sigterm_handler);
else
sigset(SIGHUP, sighup_handler);
+
sigset(SIGPIPE, SIG_IGN);
sigset(SIGTERM, sigterm_handler);
#elif defined(HAVE_SIGACTION)
* times.
*/
- input = InputSet;
- output = OutputSet;
+ memcpy(input, InputSet, SetSize);
+ memcpy(output, OutputSet, SetSize);
for (i = NumClients, con = Clients; i > 0; i --, con ++)
if (con->http.used > 0)
timeout.tv_usec = 0;
}
- if ((i = select(MaxFDs, &input, &output, NULL, &timeout)) < 0)
+ if ((i = select(MaxFDs, input, output, NULL, &timeout)) < 0)
{
char s[16384], /* String buffer */
*sptr; /* Pointer into buffer */
sptr = s + 10;
for (i = 0; i < MaxFDs; i ++)
- if (FD_ISSET(i, &InputSet))
+ if (FD_ISSET(i, InputSet))
{
snprintf(sptr, sizeof(s) - slen, " %d", i);
slen += strlen(sptr);
sptr = s + 11;
for (i = 0; i < MaxFDs; i ++)
- if (FD_ISSET(i, &OutputSet))
+ if (FD_ISSET(i, OutputSet))
{
snprintf(sptr, sizeof(s) - slen, " %d", i);
slen += strlen(sptr);
}
for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
- if (FD_ISSET(lis->fd, &input))
+ if (FD_ISSET(lis->fd, input))
AcceptClient(lis);
for (i = NumClients, con = Clients; i > 0; i --, con ++)
* Process the input buffer...
*/
- if (FD_ISSET(con->http.fd, &input) || con->http.used)
+ if (FD_ISSET(con->http.fd, input) || con->http.used)
if (!ReadClient(con))
{
con --;
* Write data as needed...
*/
- if (FD_ISSET(con->http.fd, &output) &&
- (!con->pipe_pid || FD_ISSET(con->file, &input)))
+ if (FD_ISSET(con->http.fd, output) &&
+ (!con->pipe_pid || FD_ISSET(con->file, input)))
if (!WriteClient(con))
{
con --;
{
next = job->next;
- if (job->pipe && FD_ISSET(job->pipe, &input))
+ if (job->pipe && FD_ISSET(job->pipe, input))
{
/*
* Clear the input bit to avoid updating the next job
* using the same status pipe file descriptor...
*/
- FD_CLR(job->pipe, &input);
+ FD_CLR(job->pipe, input);
/*
* Read any status messages from the filters...
if (Browsing && BrowseProtocols)
{
- if (BrowseSocket >= 0 && FD_ISSET(BrowseSocket, &input))
+ if (BrowseSocket >= 0 && FD_ISSET(BrowseSocket, input))
UpdateCUPSBrowse();
- if (PollPipe >= 0 && FD_ISSET(PollPipe, &input))
+ if (PollPipe >= 0 && FD_ISSET(PollPipe, input))
UpdatePolling();
#ifdef HAVE_LIBSLP
/*
- * End of "$Id: main.c,v 1.89 2003/01/31 01:26:32 mike Exp $".
+ * End of "$Id: main.c,v 1.90 2003/02/05 21:10:17 mike Exp $".
*/
/*
- * "$Id: server.c,v 1.6 2003/01/15 04:15:49 mike Exp $"
+ * "$Id: server.c,v 1.7 2003/02/05 21:10:18 mike Exp $"
*
* Server start/stop routines for the Common UNIX Printing System (CUPS).
*
* Clear the input and output sets...
*/
- FD_ZERO(&InputSet);
- FD_ZERO(&OutputSet);
+ memset(InputSet, 0, SetSize);
+ memset(OutputSet, 0, SetSize);
}
/*
- * End of "$Id: server.c,v 1.6 2003/01/15 04:15:49 mike Exp $".
+ * End of "$Id: server.c,v 1.7 2003/02/05 21:10:18 mike Exp $".
*/