]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Make sure we fill the output buffer, otherwise we can stall in certain
authormsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 25 Apr 2013 19:15:59 +0000 (19:15 +0000)
committermsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 25 Apr 2013 19:15:59 +0000 (19:15 +0000)
situations.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10962 7a7537e8-13f0-0310-91df-b6672ffda945

scheduler/client.c

index 2dbb7ff41e2d2bd554e31a2f541e719051e91f96..6001e5eff04ab37316196d0bf17885e16873e823 100644 (file)
@@ -2874,9 +2874,30 @@ cupsdWriteClient(cupsd_client_t *con)    /* I - Client connection */
 
   if (con->response && con->response->state != IPP_DATA)
   {
-    ipp_state = ippWrite(HTTP(con), con->response);
-    bytes     = ipp_state != IPP_ERROR &&
-                (con->file >= 0 || ipp_state != IPP_DATA);
+    int wused = con->http.wused;       /* Previous write buffer use */
+
+    do
+    {
+     /*
+      * Write a single attribute or the IPP message header...
+      */
+
+      ipp_state = ippWrite(HTTP(con), con->response);
+
+     /*
+      * If the write buffer has been flushed, stop buffering up attributes...
+      */
+
+      if (con->http.wused <= wused)
+        break;
+    }
+    while (ipp_state != IPP_STATE_DATA && ipp_state != IPP_STATE_ERROR);
+
+    if (con->http.wused > 0)
+      httpFlushWrite(HTTP(con));
+
+    bytes = ipp_state != IPP_STATE_ERROR &&
+           (con->file >= 0 || ipp_state != IPP_STATE_DATA);
   }
   else if ((bytes = read(con->file, con->header + con->header_used,
                         sizeof(con->header) - con->header_used)) > 0)