Intentionally cancelling job at printer causes repeated reprint attempts from client

未关闭
#75 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c
领域
backend

调研方向

从 backend/implicitclass.c 开始,然后跟踪取消状态经过 libcupsfilters/filter.c 的流程,以及 CUPS scheduler/job.c 中的处理方式。使用通过 browsing 发现的远程 IPP/IPPS 队列和打印机端取消来重现问题,并比较 direct IPPS 和 implicitclass 的日志。完成的标准是:有意进行的取消操作应以取消而不是可重试失败的形式传播,从而防止反复重新打印。

由索引模型根据 Issue 内容生成。

描述

I've noticed a behavior that may have been going on for awhile, but only recently was brought to my attention. When a user prints from a client with a "browsed" remote cups queue, and that user then intentionally cancels the print job at the printer, the client computer will begin retrying that print job repeatedly. Also, for reasons I have yet to determine, each retry also appends the job to the existing job (doubling the number of copies on every retry attempt).

I've observed that this only occurs on clients with printers browsed from a remote cups server, where that server is then connected to the printer via ipp/ipps. If the same client is connected directly with the printer ( ipps:// ), this does not occur. My guess is that this occurs where implicitclass is used.

I've tested this with a few combination of debian-based linux systems I have on hand, and a few models of HP enterprise network printers, and one model of small-office Canon network printer. I set up a debian Trixie system as the "server" (offering to the shared queues to be browsed by clients) and an ubuntu 26.04 system as the "server". As clients, I tried a few different versions of debian-based client (ubuntu 24/26, Mint, debian). All seemed to exhibit this behavior.

To see this behavior:

  1. Set up a Linux cups "server". Set settings in cupsd.conf that allow clients to browse the shared printers
    Listen 0.0.0.0:631 and Allow all in the <Location /> directive block
  2. Create a printer in this cups instance, connected with ipp/ipps, using the IPP everywhere driver. Share the printer
  3. Set up a client with cups-browsed, configured to browse the cups queue from the server. For example, in cups-browsed.conf, a BrowsePoll directive pointing to the IP address of the server
  4. Print a document from the client to this shared printer, such that you have to time manually cancel it while it is in progress.

End of client job log for a job printing from the client directly to the printer (ipps):

D [25/Aug/2026:19:02:24 -0500] [Job 314] job-password-encryption-supported 1setOf keyword none,sha2-256
D [25/Aug/2026:19:02:24 -0500] [Job 314] printer-state-message textWithoutLanguage 
D [25/Aug/2026:19:02:24 -0500] [Job 314] ---- end-of-attributes-tag ----
D [25/Aug/2026:19:02:24 -0500] [Job 314] ATTR: auth-info-required=none
E [25/Aug/2026:19:02:24 -0500] [Job 314] Print job canceled at printer.
D [25/Aug/2026:19:02:24 -0500] [Job 314] Set job-printer-state-message to "Print job canceled at printer.", current level=ERROR
D [25/Aug/2026:19:02:24 -0500] [Job 314] PID 1067977 (/usr/lib/cups/backend/ipps) stopped with status 5.
W [25/Aug/2026:19:02:24 -0500] [Job 314] Backend ipps returned status 5 (cancel job)
D [25/Aug/2026:19:02:24 -0500] [Job 314] time-at-completed=1787702544
I [25/Aug/2026:19:02:24 -0500] [Job 314] Job canceled at printer.
D [25/Aug/2026:19:02:25 -0500] [Job 314] Unloading...

End of a client job log for a job printing to a browsed remote queue:

D [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): multiple-document-handling-supported 1setOf keyword separate-documents-uncollated-copies,separate-documents-collated-copies
D [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): operations-supported 1setOf enum Print-Job,Validate-Job,Create-Job,Send-Document,Cancel-Job,Get-Job-Attributes,Get-Jobs,Get-Printer-Attributes,Hold-Job,Release-Job,Pause-Printer,Resume-Printer,Purge-Jobs,Set-Printer-Attributes,Set-Job-Attributes,Get-Printer-Supported-Values,Create-Printer-Subscriptions,Create-Job-Subscriptions,Get-Subscription-Attributes,Get-Subscriptions,Renew-Subscription,Cancel-Subscription,Get-Notifications,Enable-Printer,Disable-Printer,Hold-New-Jobs,Release-Held-New-Jobs,Cancel-Jobs,Cancel-My-Jobs,Close-Job,CUPS-Get-Default,CUPS-Get-Printers,CUPS-Add-Modify-Printer,CUPS-Delete-Printer,CUPS-Get-Classes,CUPS-Add-Modify-Class,CUPS-Delete-Class,CUPS-Accept-Jobs,CUPS-Reject-Jobs,CUPS-Set-Default,CUPS-Get-Devices,CUPS-Get-PPDs,CUPS-Move-Job,CUPS-Authenticate-Job,CUPS-Get-PPD,CUPS-Get-Document,Restart-Job
D [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): ---- end-of-attributes-tag ----
D [25/Aug/2026:18:57:25 -0500] [Job 313] ATTR: auth-info-required=none
E [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): Print job canceled at printer.
E [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): Backend (PID 1067687) stopped with status 5
D [25/Aug/2026:18:57:25 -0500] [Job 313] Set job-printer-state-message to "cfFilterExternal (ipp): Backend (PID 1067687) stopped with status 5", current level=ERROR
D [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterExternal (ipp): Logging (PID 1067688) exited with no errors.
D [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterChain: Backend completed with status 1.
E [25/Aug/2026:18:57:25 -0500] [Job 313] cfFilterChain: Backend (PID 1067686) stopped with status 1
D [25/Aug/2026:18:57:25 -0500] [Job 313] Closed the pipes for back and side channels
E [25/Aug/2026:18:57:25 -0500] [Job 313] Job processing failed.
D [25/Aug/2026:18:57:25 -0500] [Job 313] PID 1067683 (/usr/lib/cups/backend/implicitclass) stopped with status 1.
W [25/Aug/2026:18:57:25 -0500] [Job 313] Backend implicitclass returned status 1 (failed)
I [25/Aug/2026:18:57:25 -0500] [Job 313] Job held for 300 seconds since it could not be sent.

Some brief glancing at the code seems to point to the different error codes returned from the ipp backend and the implicitclass backend. In main cups source (https://github.com/OpenPrinting/cups/blob/e119e5c84d88679fae61b63f789b584af89d8ba8/scheduler/job.c#L3247), the ipp backend returns error values which are handled there. Note that error 5 as seen in the logs is "CUPS_BACKEND_CANCEL", which leads the the job being actually cancelled.

However, when implicit class returns from a job canceled at the printer at this point, it will return "1" instead of "5" which leads to it being retried (presuming that the error policy is retry-job or retry-current-job). At (https://github.com/OpenPrinting/cups-browsed/blob/04b26c8b34407b6ba4631d755d56643d71d057ab/backend/implicitclass.c#L386) implicitclass calls cfFilterChain which eventually calls the ipp backend as a filter, which, when it receives the "error" of being canceled at the printer, is then handled by filter.c in the libcupsfilters repository at (https://github.com/OpenPrinting/libcupsfilters/blob/b95e5a4703d5ccf5129ffe49b6646bd7fbce91cf/cupsfilters/filter.c#L1544 ) which turns this ipp backend return into "status = 1" at ( https://github.com/OpenPrinting/libcupsfilters/blob/b95e5a4703d5ccf5129ffe49b6646bd7fbce91cf/cupsfilters/filter.c#L1568 ), which then implicit class turns into a return of "1" back to the cups job scheduler ( https://github.com/OpenPrinting/cups-browsed/blob/04b26c8b34407b6ba4631d755d56643d71d057ab/backend/implicitclass.c#L403 ).

IN general, a workaround to this is to set the error policy to "Abort job" instead of retrying. However, should this be fixed? Without enough knowledge of the connected pieces of cups, I'm not sure where the best place to fix this would be.

主要语言
C
星标
51
派生
21
平均合并
22 小时 49 分钟
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenPrinting/cups-browsed 的其他 Issue

查看 OpenPrinting/cups-browsed 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。