diff --git a/ChangeLog b/ChangeLog index e3f929275..66acadf7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 6 12:32:44 EEST 2009 (edwin) +------------------------------------- + * docs/man/clamd.conf.5.in, etc/clamd.conf, shared/optparser.c: fix + documentation of formula to reflect reality. + Mon Apr 6 12:26:04 EEST 2009 (edwin) ------------------------------------- * clamconf/clamconf.c, docs/man/clamd.conf.5.in, etc/clamd.conf, diff --git a/clamd/server-th.c b/clamd/server-th.c index a2ddfa594..18038bd2d 100644 --- a/clamd/server-th.c +++ b/clamd/server-th.c @@ -945,6 +945,8 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi #if !defined(C_WINDOWS) && defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { /* don't warn if default value is too high, silently fix it */ + unsigned maxrec; + int max_max_queue; unsigned warn = optget(opts, "MaxQueue")->active; const unsigned clamdfiles = 6; /* Condition to not run out of file descriptors: @@ -952,16 +954,16 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi * CLAMDFILES is 6: 3 standard FD + logfile + 2 FD for reloading the DB * */ opt = optget(opts,"MaxRecursion"); - unsigned maxrec = opt->numarg; - int max_max_queue = rlim.rlim_cur - maxrec * max_threads - clamdfiles + max_threads; + maxrec = opt->numarg; + max_max_queue = rlim.rlim_cur - maxrec * max_threads - clamdfiles + max_threads; if (max_queue < max_threads) { max_queue = max_threads; if (warn) logg("^MaxQueue value too low, increasing to: %d\n", max_queue); } if (max_max_queue < max_threads) { - logg("^MaxThreads * MaxRecursion is too high: %d, open file descriptor limit is: %d\n", - maxrec*max_threads, rlim.rlim_cur); + logg("^MaxThreads * MaxRecursion is too high: %d, open file descriptor limit is: %lu\n", + maxrec*max_threads, (unsigned long)rlim.rlim_cur); max_max_queue = max_threads; } if (max_queue > max_max_queue) { diff --git a/docs/man/clamd.conf.5.in b/docs/man/clamd.conf.5.in index 5218e1046..1e65ec44e 100644 --- a/docs/man/clamd.conf.5.in +++ b/docs/man/clamd.conf.5.in @@ -136,7 +136,7 @@ It is recommended to have this value at least twice MaxThreads if possible. .br \fBWARNING: you shouldn't increase this too much to avoid running out of file descriptors, the following condition should hold: -MaxThreads*MaxRecursion + MaxQueue < RLIMIT_NOFILE.\fR +MaxThreads*MaxRecursion + MaxQueue - MaxThreads + 6 < RLIMIT_NOFILE.\fR RLIMIT_NOFILE is the maximum number of open file descriptors (usually 1024), set by \fBulimit -n\fR. .br diff --git a/etc/clamd.conf b/etc/clamd.conf index 850d5bab2..1f7139602 100644 --- a/etc/clamd.conf +++ b/etc/clamd.conf @@ -129,7 +129,7 @@ LocalSocket /tmp/clamd.socket # It is recommended to have this value at least twice MaxThreads if possible. # WARNING: you shouldn't increase this too much to avoid running out of file descriptors, # the following condition should hold: -# MaxThreads*MaxRecursion + MaxQueue < RLIMIT_NOFILE (usual max is 1024) +# MaxThreads*MaxRecursion + (MaxQueue - MaxThreads) + 6< RLIMIT_NOFILE (usual max is 1024) # # Default: 100 #MaxQueue 200 diff --git a/shared/optparser.c b/shared/optparser.c index e57c7dcf9..9a6602235 100644 --- a/shared/optparser.c +++ b/shared/optparser.c @@ -197,7 +197,7 @@ const struct clam_option clam_options[] = { { "ReadTimeout", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, 120, NULL, 0, OPT_MILTER, "Waiting for data from clamd will timeout after this time (seconds).\nValue of 0 disables the timeout.", "300" }, - { "MaxQueue", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, 100, NULL, 0, OPT_CLAMD, "Maximum number of queued items (including those being processed by MaxThreads threads)\nIt is recommended to have this value at least twice MaxThreads if possible.\nWARNING: you shouldn't increase this too much to avoid running out of file descriptors,\n the following condition should hold:\n MaxThreads*MaxRecursion + MaxQueue < RLIMIT_NOFILE (usual max is 1024)\n", "200" }, + { "MaxQueue", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, 100, NULL, 0, OPT_CLAMD, "Maximum number of queued items (including those being processed by MaxThreads threads)\nIt is recommended to have this value at least twice MaxThreads if possible.\nWARNING: you shouldn't increase this too much to avoid running out of file descriptors,\n the following condition should hold:\n MaxThreads*MaxRecursion + MaxQueue - MaxThreads + 6 < RLIMIT_NOFILE (usual max is 1024)\n", "200" }, { "IdleTimeout", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, 30, NULL, 0, OPT_CLAMD, "This option specifies how long (in seconds) the process should wait\nfor a new job.", "60" },