Bryan Mason [Fri, 27 Oct 2023 18:37:02 +0000 (11:37 -0700)]
scheduler/job.c: unload job before freeing job history in cupsdDeleteJob()
With "PreserveJobHistory Off", LogLevel not set to debug (or debug2),
and "LogDebugHistory 200" (the default), cupsdDeleteJob() frees the
job history and then unloads the job. However, unload_job() calls
cupsdLogJob() which re-creates the job history and puts "Unloading..."
into it because level (debug) is greater than LogLevel (warn) and
LogDebugHistory is set to 200 messages by default. Unused (and
unreachable) job history is left behind, resulting in a memory leak.
zdohnal [Wed, 25 Oct 2023 06:07:43 +0000 (08:07 +0200)]
cups/dest.c: Raise timeout _CUPS_DNSSD_GET_DESTS
The current timeout is not able to list all network devices if there are many IPP services on mDNS (the tested number is 165 services).
Raising the timeout to 1s does not slow libcups if there are less services (Avahi returns earlier) or if Avahi does not run on the system (libcups cannot create an Avahi client in that case), and provides time frame for getting reasonable amount of IPP services (big enterprise servers will use permanent queues and printer profiles than mDNS).
Zdenek Dohnal [Mon, 23 Oct 2023 07:40:44 +0000 (09:40 +0200)]
cups/dest.c: Raise timeout _CUPS_DNSSD_GET_DESTS
The current timeout is not able to list all network devices if there are
many IPP services on mDNS (the tested number is 165 services).
Raising the timeout to 1s does not slow libcups if there are less
services (Avahi returns earlier) or if Avahi does not run on the system
(libcups cannot create an Avahi client in that case), and provides time
frame for getting reasonable amount of IPP services (big enterprise
servers will use permanent queues and printer profiles than mDNS).
Fix behavior of "reserve=rfc1179" in backend/lpd.c
In backend/lpd.c, if "reserve=rfc1179" is used in the Device URI, ports from 512-731 will be used instead of only 721=731 as per RFC 1179.
cups_rresvport() starts with the value of lport passed in to the function and decrements lport to 512 until an open port is found. Thus, if all ports from 731-721 are unavailable, cups_rresvport() will start binding to ports between 720-512.
This patch resolves this issue by adding a parameter to cups_rresvport() that defines the minimum port number that should be used and makes the appropriate changes in lpd_queue().
Michael R Sweet [Sun, 10 Sep 2023 22:48:17 +0000 (18:48 -0400)]
Add new array APIs, remove old private array header, update unit tests, update
ippfind to use new array and DNS-SD APIs, update other code as needed to not
use deprecated APIs.
We didn't check for end of buffer if it looks there is an escaped
character - check for NULL terminator there and if found, return NULL
as return value and in `ptr`, because a lone backslash is not
a valid PostScript character.
scheduler/job.c: Fix extensive logging in scheduler
Based on currently unknown trigger scheduler sometimes sets JobHistoryUpdate into past, which causes select() to timeout after one second.
It happens when job->file_time of a job without files to remove gets assigned to JobHistoryUpdate. If we check for job->num_files and assign the job->file_time only if there are any, we will fix extensive logging (and unneeded cupsd execution) in various places, e.g. cleaning jobs, expiring subscriptions, deleting temporary queues...
scheduler/job.c: Fix extensive logging in scheduler
Based on currently unknown trigger scheduler sometimes sets
JobHistoryUpdate into past, which causes `select()` to timeout after one
second.
It happens when `job->file_time` of a job without files to remove gets
assigned to `JobHistoryUpdate`. If we check for `job->num_files` and
assign the `job->file_time` only if there are any, we will fix extensive
logging (and unneeded cupsd execution) in various places, e.g. cleaning
jobs, expiring subscriptions, deleting temporary queues...
Bryan Mason [Wed, 28 Jun 2023 19:55:15 +0000 (12:55 -0700)]
Fix behavior of "reserve=rfc1179" in backend/lpd.c
In backend/lpd.c, if "reserve=rfc1179" is used in the Device URI,
ports from 512-731 will be used instead of only 721=731 as per RFC
1179.
cups_rresvport() starts with the value of lport passed in to the
function and decrements lport to 512 until an open port is found.
Thus, if all ports from 731-721 are unavailable, cups_rresvport() will
start binding to ports between 720-512.
This patch resolves this issue by adding a parameter to
cups_rresvport() that defines the minimum port number that should be
used and makes the appropriate changes in lpd_queue().
Bryan Mason [Tue, 27 Jun 2023 11:18:46 +0000 (04:18 -0700)]
Use "purge-job" instead of "purge-jobs" when canceling a single job (#742)
The command "cancel -x <job>" adds "purge-jobs true" to the Cancel-Job
operation; however, the correct attribute to use for Cancel-job is
"purge-job" (singular), not "purge-jobs" (plural). As a result, job
files are not removed from /var/spool/cups when "cancel -x <job>" is
executed.
This patch resolves the issue by adding "purge-job" when the IPP
operation is Cancel-Job and "purge-jobs" for other IPP operations
(Purge-Jobs, Cancel-Jobs, and Cancel-My-Jobs)
zdohnal [Mon, 26 Jun 2023 14:24:33 +0000 (16:24 +0200)]
Fix delays in printing to lpd when reserved ports are exhausted (Issue #741)
We use our internal implementation for BSD resvport() by default in LPD backend, which should act on port ranges 512 - 1023, however we didn't go back to the highest port number once we got under the lowest port number. This caused a delay 511s long until `lpd_queue()` got the port number to 0, which triggered the assignment of the highest port number.
The highest port number is assigned right after we cross the lowest port number, which eliminates this kind of delay.
Bryan Mason [Sat, 24 Jun 2023 19:31:23 +0000 (12:31 -0700)]
Fix delays printing to lpd when reserved ports are exhausted
cups_rresvport() doesn't reserve ports less than 512; however,
lpd_queue() continues decrementing the port number to 0. This leads
to delays of ~511 seconds once all ports between 512-1023 are
exhausted. Even when ports become available, lpd_queue() still tries
calling cups_rresvport() with port numbers less than 512, waiting one
second between each call.
Zdenek Dohnal [Wed, 14 Jun 2023 07:55:33 +0000 (09:55 +0200)]
cups/ppd-cache.c: Put cupsSingleFile into generated PPD
Some printers are not able to print multiple files in one job via IPP
Everywhere. Adding the PPD keyword enables the feature on all printers
in exchange for performance degradation (there is a 1-2s pause between
printed files).