cups-lpd can lose print data

Sebastian James sjames at wmltd.co.uk
Fri May 15 03:08:51 PDT 2009


> > > Sebastian James wrote:
> > > > ..
> > > > 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?
> > >  > ...
> > >
> > > No, since a) you can add more disk space and/or increase the MaxJobs
> > > parameter to suite your site and b) if cups-lpd or cupsd are unable
> > > to queue the job, cups-lpd returns an error to the client doing the
> > > printing.
> > > If b) is not working, then we need to address it, however we aren't
> > > going to add code to cups-lpd to do cupsd's job.
> > >
> > > --
> > > ______________________________________________________________________
> > > Michael Sweet, Easy Software Products           mike at easysw dot com
> >
> > I will test b) and come back to you. I suspect it doesn't work in the older 1.1.23 code.
> >
> > Seb
>
> I realised that the problem in the 1.1.23 cups-lpd.c code is that it creates a print request using IPP_PRINT_JOB and makes essentially a single request to the cupsd to "print this file please" - requiring that the file is completely received before cups-lpd can find out if cupsd will accept the print job or not.
>
> I had a look at the alternative IPP requests and noticed that you can first IPP_CREATE_JOB then IPP_SEND_DOCUMENT. This means you can first try to create the job, which will be allowed only if maxjobs has not been reached in the cupsd (amoung other things of course). After you have "reserved" your job, cups-lpd could then receive the file from the sending process and request for it to be printed. If the job were refused, cups-lpd could close the connection before the print data was sent, ensuring that the sending process will know to try again later.
>
> So, I went back to the 1.4b2 cups code, and notice that this is nearly the way it is now done. In 1.1.23, print_file() make an IPP_PRINT_JOB request. In 1.4b2, create_job() is called first to get a job id, then print_file makes an IPP_SEND_DOCUMENT request.
>
> However, the create_job() call occurs AFTER the print data has been received from the sending process - an "acknowledgement is sent" back to the sending process that the print data has been received.
>
> So, I think it's still possible for cups-lpd.c to lose print data in the case that maxjobs has been reached. This could be solved by moving the create_job() call earlier in recv_print_job().
>
> I will come back when I have done some more work on this.
>
> best,
> Seb James.

I've finally got around to making a patch with my fix. See STR #3199. Thanks.




More information about the cups mailing list