From: msweet Date: Thu, 25 Apr 2013 19:15:59 +0000 (+0000) Subject: Make sure we fill the output buffer, otherwise we can stall in certain X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80bf7e5fb19e38fd26c845c78823e3758d3196ed;p=thirdparty%2Fcups.git Make sure we fill the output buffer, otherwise we can stall in certain situations. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10962 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/scheduler/client.c b/scheduler/client.c index 2dbb7ff41e..6001e5eff0 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -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)