zdohnal [Thu, 14 Dec 2023 16:33:40 +0000 (17:33 +0100)]
httpAddrConnect2: Check for error if POLLHUP is in valid revents
Some Linux kernel versions put POLLOUT|POLLHUP into revents when client tries to connect with httpAddrConnect2(), which makes the connection fail.
Let's check the option SO_ERROR before scratching the attempt - if there is no error, remove POLLHUP from revents.
I've re-purposed previously Solaris-only code to be used everywhere if the conditions are met - this should prevent bigger delays than necessary.
Slightly different issue than #827, but with similar symptoms (kernel sending POLLOUT|POLLHUP).
Zdenek Dohnal [Thu, 14 Dec 2023 08:37:22 +0000 (09:37 +0100)]
httpAddrConnect2: Check for error if POLLHUP is in valid revents
Some Linux kernel versions put POLLOUT|POLLHUP into revents when client tries to connect with httpAddrConnect2(), which makes the connection fail.
Let's check the option SO_ERROR before scratching the attempt - if there is no error, remove POLLHUP from revents.
I've re-purposed previously Solaris-only code to be used everywhere if the conditions are met - this should prevent bigger delays than necessary.
Slightly different issue than #827, but with similar symptoms (kernel sending POLLOUT|POLLHUP).
zdohnal [Wed, 29 Nov 2023 14:07:18 +0000 (15:07 +0100)]
scheduler: Fix build failure on Linux with '-Werror -Wall'
The string which we add into array stays const after fixing #814 (because strdup(), which caused memory leak returned char *) and compiler fails because of it if it runs with '-Werror -Wall'.
Zdenek Dohnal [Mon, 27 Nov 2023 09:05:55 +0000 (10:05 +0100)]
scheduler: Fix build failure on Linux with '-Werror -Wall'
The string which we add into array stays `const` after fixing #814
(because `strdup()`, which caused memory leak returned `char *`)
and compiler fails because of it if it runs with '-Werror -Wall'.
zdohnal [Fri, 24 Nov 2023 06:26:31 +0000 (07:26 +0100)]
lpstat.c: Implement successful filter for jobs
Introduce a new argument value 'successful' in lpstat to get jobs which completed successfully without introducing a new IPP value for IPP attribute 'which-jobs'
zdohnal [Fri, 24 Nov 2023 05:08:51 +0000 (06:08 +0100)]
scheduler/colorman.c: Fix memory leak during creating color profile
Since the array profiles is set to use strdup() as a copy function, we don't have to use strdup() on the element which is passed as parameter of cupsArrayAdd() - using the strdup() as we used till now causes memory leak.
zdohnal [Thu, 23 Nov 2023 15:42:09 +0000 (16:42 +0100)]
scheduler: Report warning if destination doesn't follow IPP spec
Report warning if the destination can't answer to IPP request containing 'all,media-col-database' combination in one response, which is against RFC. This way we can find out about more devices which have those firmware issues.
zdohnal [Mon, 30 Oct 2023 10:29:52 +0000 (11:29 +0100)]
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.
The solution seems to be to unload the job before freeing the job history.
Zdenek Dohnal [Mon, 30 Oct 2023 09:21:47 +0000 (10:21 +0100)]
scheduler/colorman.c: Fix memory leak during creating color profile
Since the array `profiles` is set to use `strdup()` as a copy function, we
don't have to use `strdup()` on the element which is passed as parameter
of `cupsArrayAdd()` - using the `strdup()` as we used till now causes
memory leak.
Reproducer is the same as https://github.com/OpenPrinting/cups/pull/813
.
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.