Bug 426653
Summary: | /usr/lib/cups/backend/usb busy-waits with 100% in select() call | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Daniel Berrangé <berrange> | ||||
Component: | cups | Assignee: | Tim Waugh <twaugh> | ||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
Severity: | low | Docs Contact: | |||||
Priority: | high | ||||||
Version: | 8 | ||||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | 1.3.5-2.fc8 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2008-01-27 07:18:45 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 235704 | ||||||
Attachments: |
|
Description
Daniel Berrangé
2007-12-23 21:45:52 UTC
Created attachment 290311 [details]
Fix busy-waiting
Based on the gdb stack trace the problem is in the 'backend/runloop.c' file and
the backendRunLoop method.
This code fragment sets the file descriptor for writability if 'print_bytes' is
non zero, or 'use_bc' is zero:
FD_ZERO(&output);
if (print_bytes || !use_bc)
FD_SET(device_fd, &output);
if (use_bc || side_cb)
{
if (select(nfds, &input, &output, NULL, NULL) < 0)
{
The stack trace shows that in the USB backend 'use_bc' is zero, and 'side_cb'
is non-zero, so we enter the select(), with the device monitored for
writability.
We only actually write data if 'print_bytes' is non zero though.
if (print_bytes && FD_ISSET(device_fd, &output))
{
if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
So, if use_bc is zero, and side_cb is non-NULL this code will busy-wait.
The solution is to change the initial code where the FD_SET is called
FD_ZERO(&output);
if (print_bytes || (!use_bc && !side_cb))
FD_SET(device_fd, &output);
Attaching a patch which does this
Thanks for the analysis and patch. Reported upstream: http://cups.org/str.php?L2664 Fixed in CVS. cups-1.3.5-2.fc8 has been pushed to the Fedora 8 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update cups' cups-1.3.5-2.fc8 has been pushed to the Fedora 8 stable repository. If problems still persist, please make note of it in this bug report. |