From: Michael R Sweet Date: Mon, 16 Jan 2017 17:00:25 +0000 (-0500) Subject: Optimize connection usage in the IPP backend. X-Git-Tag: v2.2.2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a401c2733abb7bd5c2d3141c9419fdc64a641fe5;p=thirdparty%2Fcups.git Optimize connection usage in the IPP backend. --- diff --git a/CHANGES.txt b/CHANGES.txt index dc25152fd0..707adc565a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,8 @@ CHANGES IN CUPS V2.2.2 - Fixed some issues with IPP Everywhere printer support (Issue #4893, Issue #4909, Issue #4916, Issue #4921, Issue #4923, Issue #4932, Issue #4933, Issue #4938) + - Optimized connection usage in the IPP backend + () - The scheduler did not detect when an encrypted connection was closed by the client on Linux (Issue #4901) - The cups-lpd program did not catch all legacy usage of ISO-8859-1 diff --git a/backend/ipp.c b/backend/ipp.c index a338577f9d..6eefd144e7 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);