Skip to content

Commit 7d4666d

Browse files
committed
cups-browsed: Removed IPP poll for job ID in on_job_state(), ID already available.
1 parent f90699e commit 7d4666d

File tree

1 file changed

+2
-43
lines changed

1 file changed

+2
-43
lines changed

utils/cups-browsed.c

+2-43
Original file line numberDiff line numberDiff line change
@@ -5714,7 +5714,6 @@ on_job_state (CupsNotifier *object,
57145714
int dest_index = 0;
57155715
int valid_dest_found = 0;
57165716
char uri[HTTP_MAX_URI];
5717-
/*int job_id = 0;*/
57185717
int num_options;
57195718
cups_option_t *options;
57205719
int num_of_printers;
@@ -5732,11 +5731,6 @@ on_job_state (CupsNotifier *object,
57325731
"printer-is-accepting-jobs"
57335732
};
57345733
http_t *conn = NULL;
5735-
static const char *jattrs[] =
5736-
{
5737-
"job-id",
5738-
"job-state"
5739-
};
57405734

57415735
debug_printf("on_job_state() in THREAD %ld\n", pthread_self());
57425736

@@ -5836,48 +5830,13 @@ on_job_state (CupsNotifier *object,
58365830
/* We have remote CUPS queue(s) and so are using the implicitclass
58375831
backend */
58385832
debug_printf("[CUPS Notification] %s is using the \"implicitclass\" CUPS backend, so let us search for a destination for this job.\n", printer);
5833+
58395834
/* We keep track of the printer which we used last time and start
58405835
checking with the next printer this time, to get a "round robin"
58415836
type of printer usage instead of having most jobs going to the first
58425837
printer in the list. Method taken from the cupsdFindAvailablePrinter()
58435838
function of the scheduler/classes.c file of CUPS. */
58445839

5845-
/* Find the ID of the current job */
5846-
request = ippNewRequest(IPP_GET_JOBS);
5847-
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
5848-
"localhost", ippPort(), "/printers/%s", printer);
5849-
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
5850-
"printer-uri", NULL, uri);
5851-
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
5852-
"requested-attributes",
5853-
sizeof(jattrs) / sizeof(jattrs[0]), NULL, jattrs);
5854-
job_id = 0;
5855-
if ((response = cupsDoRequest(conn, request, "/")) != NULL) {
5856-
/* Get the current active job on this queue... */
5857-
ipp_jstate_t jobstate = IPP_JOB_PENDING;
5858-
for (attr = ippFirstAttribute(response); attr != NULL;
5859-
attr = ippNextAttribute(response)) {
5860-
if (!ippGetName(attr)) {
5861-
if (jobstate == IPP_JOB_PROCESSING)
5862-
break;
5863-
else
5864-
continue;
5865-
}
5866-
if (!strcmp(ippGetName(attr), "job-id") &&
5867-
ippGetValueTag(attr) == IPP_TAG_INTEGER)
5868-
job_id = ippGetInteger(attr, 0);
5869-
else if (!strcmp(ippGetName(attr), "job-state") &&
5870-
ippGetValueTag(attr) == IPP_TAG_ENUM)
5871-
jobstate = (ipp_jstate_t)ippGetInteger(attr, 0);
5872-
}
5873-
if (jobstate != IPP_JOB_PROCESSING)
5874-
job_id = 0;
5875-
ippDelete(response);
5876-
}
5877-
if (job_id == 0)
5878-
debug_printf("ERROR: could not determine ID of current job on %s\n",
5879-
printer);
5880-
58815840
if (q->last_printer < 0 ||
58825841
q->last_printer >= cupsArrayCount(remote_printers))
58835842
q->last_printer = 0;
@@ -6169,7 +6128,7 @@ on_job_state (CupsNotifier *object,
61696128
"requesting-user-name", NULL, cupsUser());
61706129
if (dest_host) {
61716130
q->last_printer = dest_index;
6172-
snprintf(buf, sizeof(buf), "\"%d %s %s %s\"", job_id,destination_uri,
6131+
snprintf(buf, sizeof(buf), "\"%d %s %s %s\"", job_id, destination_uri,
61736132
document_format, resolution);
61746133
debug_printf("Destination for job %d to %s: %s:%d, queue %s\n",
61756134
job_id, printer, dest_host, dest_port, dest_name);

0 commit comments

Comments
 (0)