]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
<rdar://problem/14016099> ipptool: Use SO_NWRITE socket option to extend timeouts
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 30 May 2013 01:33:55 +0000 (01:33 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 30 May 2013 01:33:55 +0000 (01:33 +0000)
Make the ipptool timeout callback check whether the output buffer is empty.  If
not, automatically extend the timeout until it is - useful for when the printer
is blocking due to a printer error like "out of paper"...

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11000 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-IPPTOOL.txt
CHANGES.txt
test/ipptool.c

index 0fc20784845bfa6b8f87b8aea14efef0934db9e3..9c0a36fe09a59a3cbf30b8b66e10efe6c176ecdc 100644 (file)
@@ -1,11 +1,14 @@
-CHANGES-IPPTOOL.txt - 2013-05-02
+CHANGES-IPPTOOL.txt - 2013-05-29
 --------------------------------
 
 This file provides a list of changes to the ipptool binary distribution posted
 on cups.org.
 
-2013-05-02
+2013-05-29
 
+       - Added support for automatically extending the timeout when all of the
+         request data has not yet been written (all platforms but Windows
+         which does not support it...)
        - Fixed several ipptool test files that used old STATUS names.
 
 
index bf59c88f30d54bfd5eff47ff89c4d7faccbf04f4..a6e87ebf0a0333c1274d904d3370fa55b96a7013 100644 (file)
@@ -3,6 +3,8 @@ CHANGES.txt - 1.7b1 - 2013-05-13
 
 CHANGES IN CUPS V1.7b2
 
+       - The ipptool program now automatically extends timeouts when the
+         output buffer is filled (<rdar://problem/14016099>)
        - The ipptool program now supports the --help and --version options.
        - The ipptool program did not continue past include file errors by
          default (<rdar://problem/13875803>)
index 9d6044604e8d721e973fff942333bf4d5f46a367..bb101ae3f1fedd3f0455388943a8fda8e2d951b4 100644 (file)
@@ -4744,14 +4744,34 @@ sigterm_handler(int sig)                /* I - Signal number (unused) */
  */
 
 static int                             /* O - 1 to continue, 0 to cancel */
-timeout_cb(http_t *http,               /* I - Connection to server (unused) */
+timeout_cb(http_t *http,               /* I - Connection to server */
            void   *user_data)          /* I - User data (unused) */
 {
+  int          buffered = 0;           /* Bytes buffered but not yet sent */
+
+
+ /*
+  * If the socket still have data waiting to be sent to the printer (as can
+  * happen if the printer runs out of paper), continue to wait until the output
+  * buffer is empty...
+  */
+
+#ifdef SO_NWRITE                       /* OS X and some versions of Linux */
+  socklen_t len = sizeof(buffered);    /* Size of return value */
+
+  if (getsockopt(httpGetFd(http), SOL_SOCKET, SO_NWRITE, &buffered, &len))
+    buffered = 0;
+
+#elif defined(SIOCOUTQ)                        /* Others except Windows */
+  if (ioctl(httpGetFd(http), SIOCOUTQ, &buffered))
+    buffered = 0;
+
+#else                                  /* Windows (not possible) */
   (void)http;
   (void)user_data;
+#endif /* SO_NWRITE */
 
- /* Always cancel on timeout */
-  return (0);
+  return (buffered > 0);
 }