Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipptool hangs in http_read despite timeout (-T 10) #4515

Closed
michaelrsweet opened this issue Nov 4, 2014 · 5 comments
Closed

ipptool hangs in http_read despite timeout (-T 10) #4515

michaelrsweet opened this issue Nov 4, 2014 · 5 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 2.0.0
CUPS.org User: tometzky

I'm using ipptool (really ipptool-static) on Linux (CentOS6 x86_64, manually compiled ipptool) to check printer queue (Canon iR3225) like this:

DEVICE_URI="ipp:https://printerhostname/ipp"
IPPTOOL="ipptool"
IPPTOOL_GET_QUEUED_JOB_COUNT='
{
NAME "Get queued job count using Get-Printer-Attributes"
OPERATION Get-Printer-Attributes

GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language attributes-natural-language en
ATTR uri printer-uri $uri

STATUS successful-ok

DISPLAY queued-job-count

}
'
$IPPTOOL -c -T 10 "$DEVICE_URI" /dev/stdin <<< "$IPPTOOL_GET_QUEUED_JOB_COUNT"
queued-job-count
0

But despite using "-T 10" ipptool process hanged for 18 hours in http_read function. Even restarting a printer did not help as ipptool does not use TCP SO_KEEPALIVE.

Please enable SO_KEEPALIVE for ipptool connections by default or at least add an option to enable it.

Here's a backtrace from hanging process:
#0 0x00007f0236302b12 in __libc_recv (fd=, buf=0x7f02387601e1, n=8, flags=)

at ../sysdeps/unix/sysv/linux/x86_64/recv.c:30

#1 0x00007f023674ea6f in recv (http=0x7f023875bab0, buffer=0x7f02387601e1 "\003", length=8)

at /usr/include/bits/socket2.h:45

#2 http_read (http=0x7f023875bab0, buffer=0x7f02387601e1 "\003", length=8) at http.c:4079
#3 0x00007f023674f571 in httpRead2 (http=0x7f023875bab0, buffer=0x7f02387601e1 "\003", length=)

at http.c:2129

#4 0x00007f023675891f in ipp_read_http (http=0x7f023875bab0, buffer=, length=8) at ipp.c:6834
#5 0x00007f02367592bd in ippReadIO (src=0x7f023875bab0, cb=0x7f02367588b0 <ipp_read_http>, blocking=1,

parent=<value optimized out>, ipp=0x7f023875ef60) at ipp.c:2999

#6 0x00007f023675f73b in cupsGetResponse (http=0x7f023875bab0, resource=) at request.c:402
#7 0x00007f0236744753 in do_tests (outfile=, vars=0x7fff05dbf320,

testfile=0x7fff05dc2d1d "/dev/stdin") at ipptool.c:2577

#8 0x00007f02367494f4 in main (argc=6, argv=0x7fff05dc0ab8) at ipptool.c:670

I'm attaching a compressed core file (from CentOS 6.6 x86_64 with all updates until today) - it may help with debugging this.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: tometzky

I couldn't attach a core file directly to this report. Please download from http:https://prhn.ato.waw.pl/~tometzky/tmp/core.10765.xz

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: tometzky

This process did not even react to TERM signal. I had to use 'kill -9' to kill it.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

ipptool catches SIGTERM when timeouts are in use - a second SIGTERM will kill it.

It should not be possible for libcups to hang like this - when timeouts are set the read should only occur if input is available.

Investigating.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str4515.patch":

Index: cups/ipp.c

--- cups/ipp.c (revision 12463)
+++ cups/ipp.c (working copy)
@@ -6830,7 +6830,23 @@
break;
}
}

  • else if (http->used == 0 && http->timeout_value > 0)
  • {
  • /*
    
  •  \* Wait up to timeout seconds for more data on blocking sockets...
    
  •  */
    
  •  if (!httpWait(http, (int)(1000 * http->timeout_value)))
    
  •  {
    
  •   /*
    
  • * Signal no data...
  • */
  • bytes = -1;
  • break;
  •  }
    
  • }

if ((bytes = httpRead2(http, (char *)buffer, length - (size_t)tbytes)) < 0)
{
#ifdef WIN32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant