summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>2013-04-25 19:15:59 +0000
committermsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>2013-04-25 19:15:59 +0000
commit80bf7e5fb19e38fd26c845c78823e3758d3196ed (patch)
tree3551c2b1390d6d03204b63e8e75ca94ff4cd5503
parent54b0b445515ed3a00cac065a6231e463f7cc6765 (diff)
downloadcups-80bf7e5fb19e38fd26c845c78823e3758d3196ed.tar.gz
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
-rw-r--r--scheduler/client.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/scheduler/client.c b/scheduler/client.c
index 2dbb7ff41..6001e5eff 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)