Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipp backend doesn't wait as it should #761

Closed
michaelrsweet opened this issue Jun 10, 2004 · 4 comments
Closed

ipp backend doesn't wait as it should #761

michaelrsweet opened this issue Jun 10, 2004 · 4 comments

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.1.21rc1
CUPS.org User: mclasen.redhat

I found that the ipp backend only waits for the job completion if waitjob is 1 and argc > 6. This may be intentional, but it has the consequence that printer status is not reported back to the daemon, because the code
block after
/*
* Now check on the printer state...
*/
is never reached. After changing that I discovered that the
"Waiting for job to complete" printer status_message never gets cleared, so I had to make the ipp backend emit an empty INFO message to clear it.

My patch does three things:

  • Make sure that the "Wait for the job to complete..."
    loop is always reached if waitjob is 1
  • Make sure that we always query the printer state at least once
    in the loop.
  • Clear the printer status_message before exiting
@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

We can't accept the patch as-is, since it does not conform to the CUPS CMP coding style requirements, and I'm not keen on using goto in any of our code if it can be avoided.

Will look into this some more and see if I can come up with a simpler fix.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

I implemented a simpler fix which queries the printer at the end of all job processing.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.

@michaelrsweet
Copy link
Collaborator Author

"debug.patch":

--- cups-1.1.21rc1/backend/ipp.c.debug 2004-06-08 13:06:39.000000000 -0400
+++ cups-1.1.21rc1/backend/ipp.c 2004-06-08 13:06:39.000000000 -0400
@@ -884,9 +884,12 @@
if (response)
ippDelete(response);

  • if (ipp_status <= IPP_OK_CONFLICT && argc > 6)
  • if (ipp_status <= IPP_OK_CONFLICT)
    {
  •  fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1);
    
  •  if (argc > 6)
    
  • {
  • fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1);
    
  • }
    copies --;
    }
    else if (ipp_status != IPP_SERVICE_UNAVAILABLE &&
    @@ -901,9 +904,10 @@
    continue;

fputs("INFO: Waiting for job to complete...\n", stderr);

  • for (;;)
    {

  •  int stop_waiting = 0;
    

    /*

    • Build an IPP_GET_JOB_ATTRIBUTES request...
      */
      @@ -955,7 +959,8 @@
      ippDelete(response);

    ipp_status = IPP_OK;

  •    break;
    
  • stop_waiting = 1;

  • goto printerstatus;
    }

    if (ipp_status > IPP_OK_CONFLICT)
    @@ -968,7 +973,8 @@

   fprintf(stderr, "ERROR: Unable to get job %d attributes (%s)!\n",
      job_id, ippErrorString(ipp_status));
  • break;
    
  • stop_waiting = 1;
    
  • goto printerstatus;
    
    }
    }

@@ -985,11 +991,14 @@
* Stop polling if the job is finished or pending-held...
*/

  • fprintf(stderr, "DEBUG: job status %d\n", job_state->values[0].integer);
    
    •  if (job_state->values[0].integer > IPP_JOB_PROCESSING ||
      job_state->values[0].integer == IPP_JOB_HELD)
      
      {
      ippDelete(response);
  •   break;
    
  •   stop_waiting = 1;
    
  •   goto printerstatus;
    

    }
    }
    }
    @@ -1000,7 +1009,7 @@
    /*

    • Now check on the printer state...
      */

  • printerstatus:
    request = ippNew();
    request->request.op.version[1] = version;
    request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
    @@ -1030,12 +1039,16 @@
    if (!copies_sup)
    httpReconnect(http);

  •  reasons = 0;
    

    if ((response = cupsDoRequest(http, request, resource)) != NULL)
    {
    reasons = report_printer_state(response);
    ippDelete(response);
    }

  •  if (stop_waiting) 
    
  • break;

  • /*
  • Wait 10 seconds before polling again...
    */
    @@ -1043,6 +1056,14 @@
    sleep(10);
    }
    }
  • if (reasons == 0)
  • {
  • /*
  • \* Clear printer->state_message
    
  • */
    
  • fprintf(stderr, "INFO: \n");
  • }

/*

  • Free memory...
    @@ -1065,6 +1086,11 @@
    unlink(pstmpname);
    #endif /* APPLE */
  • /*
  • * Give the daemon some time to read stderr
  • */
  • sleep (10);

/*

  • Return the queue status...
    /
    @@ -1388,6 +1414,11 @@
    unlink(pstmpname);
    #endif /
    APPLE */
  • /*
  • * Give the daemon some time to read stderr
  • */
  • sleep (10);

exit(1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant