]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Eliminate indefinite wait for response.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 15 Apr 2011 06:08:35 +0000 (06:08 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 15 Apr 2011 06:08:35 +0000 (06:08 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9688 7a7537e8-13f0-0310-91df-b6672ffda945

cups/http.c
cups/request.c

index 3d752d9d934a27b6ef39f91f37ebac076fdb5e39..3d8eaa26ac8c3e49dfaf24be0d62a38a0bbdf6ac 100644 (file)
@@ -868,7 +868,7 @@ httpFlushWrite(http_t *http)                /* I - Connection to server */
 
   http->wused = 0;
 
-  DEBUG_printf(("1httpFlushWrite: Returning %d.", bytes));
+  DEBUG_printf(("1httpFlushWrite: Returning %d, errno=%d.", bytes, errno));
 
   return (bytes);
 }
@@ -1327,7 +1327,7 @@ httpGets(char   *line,                    /* I - Line to read into */
       * No newline; see if there is more data to be read...
       */
 
-      if (!http->blocking && !_httpWait(http, 10000, 1))
+      if (!_httpWait(http, http->blocking ? 30000 : 10000, 1))
       {
         DEBUG_puts("3httpGets: Timed out!");
 #ifdef WIN32
@@ -2951,11 +2951,16 @@ httpWait(http_t *http,                  /* I - Connection to server */
   * First see if there is data in the buffer...
   */
 
+  DEBUG_printf(("2httpWait(http=%p, msec=%d)", http, msec));
+
   if (http == NULL)
     return (0);
 
   if (http->used)
+  {
+    DEBUG_puts("3httpWait: Returning 1 since there is buffered data ready.");
     return (1);
+  }
 
  /*
   * Flush pending data, if any...
@@ -2963,6 +2968,8 @@ httpWait(http_t *http,                    /* I - Connection to server */
 
   if (http->wused)
   {
+    DEBUG_puts("3httpWait: Flushing write buffer.");
+
     if (httpFlushWrite(http) < 0)
       return (0);
   }
index d92810a5c1dd021fcb5cc7290fe3e6c91141d07e..3c2e076666d085717cd99438bf5ba98b8fcd20ef 100644 (file)
@@ -396,7 +396,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   {
     status = httpUpdate(http);
   }
-  while (http->state == HTTP_POST_RECV);
+  while (status != HTTP_ERROR && http->state == HTTP_POST_RECV);
 
   DEBUG_printf(("2cupsGetResponse: status=%d", status));
 
@@ -738,6 +738,14 @@ cupsSendRequest(http_t     *http,  /* I - Connection to server or @code CUPS_HTTP
          break;
       }
 
+    if (state == IPP_ERROR)
+    {
+      http->status = HTTP_ERROR;
+      http->state  = HTTP_WAITING;
+
+      return (HTTP_ERROR);
+    }
+
    /*
     * Wait up to 1 second to get the 100-continue response as needed...
     */