cups-lpd can lose print data

Sebastian James seb at esfnet.co.uk
Fri Jan 30 03:45:20 PST 2009


Hi,

We've (www.wmltd.co.uk) supplied cups to our customers and used cups-lpd.c in many different production environments to receive print data into a cups server from other systems.

We've found a couple of problems in cups-lpd.c

These comments all relate to cups-lpd.c from cups-1.1.23, which I know is rather old. However, I think they still hold true, from a scan through cups-lpd.c from 1.4b2.

This is really all about resources on the cups server.

1) Disk Space

We've run cups on a resource constrained device, which had limited disk storage.

The problem, when using cups-lpd.c, is that cups-lpd.c completely receives the print job from the sender, which now thinks that the job will have printed. cups-lpd.c then attempts to send the job to the cupsd, but fails, because cupsd can't get the disk space to store a copy of it. cups-lpd.c then exits, and the print data has been lost.

We've hacked a work around for this, which is a hard-coded limit on the available disk space. When cups-lpd.c sees that there is only X MB of space left, it pauses, until more disk space is available, thus preventing loss of data.

This "minimum free disk space" could be a parameter set in cupsd.conf. cupsd could then be queried by cups-lpd.c for the value of this parameter. If it detected less space than the minimum, it would then pause, to wait for the disk space to become available.

2) MaxJobs

Cupsd has a "MaxJobs" parameter. If the cupsd reaches this limit, it stops accepting connections.

The problem, when using cups-lpd.c, is that cups-lpd.c completely receives the print job from the sender, which now thinks that the job will have printed. cups-lpd.c then attempts to send the job to the cupsd, but fails, because cupsd refuses it, as MaxJobs has been reached. cups-lpd.c then exits, and the print data has been lost.

We have coded a work around to this, which is to add a new query to cupsd - for maxjobs and numjobs. cups-lpd.c can now ask cupsd if numjobs is < maxjobs. If it is, the job is printed. If NOT then cups-lpd.c waits until it is able to send the job to cupsd and no print data is lost.

Our work around is not yet suitable for submission as a patch because we have had to use a shared memory resource to ensure that only a single cups-lpd.c queries for numjobs at a time, to prevent a race condition. This "one at a time" behaviour needs to be brought within cupsd itself.

Would a patch to add a new query CUPS_GET_MAXJOBS to cups be likely to be accepted subject to the code being of acceptable quality?

We'd love to get these features rolled into CUPS, so that we could use an un-patched CUPS in the systems we sell.

Comments?

Seb James





More information about the cups mailing list