summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorMichael R Sweet <michaelrsweet@gmail.com>2017-01-16 12:00:25 -0500
committerMichael R Sweet <michaelrsweet@gmail.com>2017-01-16 12:00:25 -0500
commita401c2733abb7bd5c2d3141c9419fdc64a641fe5 (patch)
tree042ea869dae3f8852cbbf474cbe259a51f40c5b7 /backend
parent2e69b2483efc32e83ba6549dfeeaed1239bcf973 (diff)
downloadcups-a401c2733abb7bd5c2d3141c9419fdc64a641fe5.tar.gz
Optimize connection usage in the IPP backend.
Diffstat (limited to 'backend')
-rw-r--r--backend/ipp.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/backend/ipp.c b/backend/ipp.c
index a338577f9..6eefd144e 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -2430,10 +2430,13 @@ monitor_printer(
while (monitor->job_state < IPP_JOB_CANCELED && !job_canceled)
{
/*
- * Reconnect to the printer...
+ * Reconnect to the printer as needed...
*/
- if (!httpReconnect(http))
+ if (httpGetFd(http) < 0)
+ httpReconnect(http);
+
+ if (httpGetFd(http) >= 0)
{
/*
* Connected, so check on the printer state...
@@ -2452,7 +2455,7 @@ monitor_printer(
* No job-id yet, so continue...
*/
- goto monitor_disconnect;
+ goto monitor_sleep;
}
/*
@@ -2613,20 +2616,14 @@ monitor_printer(
(monitor->job_state == IPP_JOB_CANCELED ||
monitor->job_state == IPP_JOB_ABORTED))
job_canceled = -1;
-
- /*
- * Disconnect from the printer - we'll reconnect on the next poll...
- */
-
- monitor_disconnect:
-
- _httpDisconnect(http);
}
/*
* Sleep for N seconds...
*/
+ monitor_sleep:
+
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
@@ -2638,7 +2635,10 @@ monitor_printer(
if (job_canceled > 0 && monitor->job_id > 0)
{
- if (!httpReconnect(http))
+ if (httpGetFd(http) < 0)
+ httpReconnect(http);
+
+ if (httpGetFd(http) >= 0)
{
cancel_job(http, monitor->uri, monitor->job_id, monitor->resource,
monitor->user, monitor->version);