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

Backends returned status is never set before job is removed #448

Closed
michaelrsweet opened this issue Nov 30, 2003 · 10 comments
Closed

Backends returned status is never set before job is removed #448

michaelrsweet opened this issue Nov 30, 2003 · 10 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.1.20
CUPS.org User: ehmsen.imada.sdu

Hi...

I have this problem with the lpd backend of cups.
My printer is connected to a printserver (netgear FM114P). When the printer is "online" printing goes very well, but when the printer is turned off and I try to print my job just gets lost and never queued (until the printer is eventually turned on).

I have locted the problem so far:
When the printer is on and I try to print, the lpd backend returns a status of 0 (everything went fine)
When the printer is off and I try to print, the lpd backend returns a status of 1 (something went wrong).
So far it looks correct.
But the returned status is never set and thus the job->status field is never updated before the job is removed. So the UpdateJob function just sees the job as finished and removes it, not depending on what the backend returned.

Her is a output from the error_log (with loglevel DEBUG2):

When the printer is on:

D [27/Nov/2003:22:01:40 +0100] [Job 544] Printing job: /var/spool/cups/tmp/3fc66633c6e89
I [27/Nov/2003:22:01:40 +0100] [Job 544] Attempting to connect to host 192.168.0.1 for printer
I [27/Nov/2003:22:01:40 +0100] [Job 544] Connected to 192.168.0.1...
D [27/Nov/2003:22:01:40 +0100] [Job 544] Connected on ports 515 (local 0)...
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command 02
D [27/Nov/2003:22:01:40 +0100] [Job 544] Sending command string (2 bytes)...
D [27/Nov/2003:22:01:40 +0100] [Job 544] Reading command status...
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command returning 0
D [27/Nov/2003:22:01:40 +0100] [Job 544] Control file is:
D [27/Nov/2003:22:01:40 +0100] [Job 544] Hmatrix
D [27/Nov/2003:22:01:40 +0100] [Job 544] Pehmsen
D [27/Nov/2003:22:01:40 +0100] [Job 544] Jtemp_txt
D [27/Nov/2003:22:01:40 +0100] [Job 544] ldfA457matrix
D [27/Nov/2003:22:01:40 +0100] [Job 544] UdfA457matrix
D [27/Nov/2003:22:01:40 +0100] [Job 544] Ntemp_txt
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command 02 64 cfA457matrix
D [27/Nov/2003:22:01:40 +0100] [Job 544] Sending command string (17 bytes)...
D [27/Nov/2003:22:01:40 +0100] [Job 544] Reading command status...
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command returning 0
I [27/Nov/2003:22:01:40 +0100] [Job 544] Sending control file (64 bytes)
I [27/Nov/2003:22:01:40 +0100] [Job 544] Control file sent successfully
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command 03 390971 dfA457matrix
D [27/Nov/2003:22:01:40 +0100] [Job 544] Sending command string (21 bytes)...
D [27/Nov/2003:22:01:40 +0100] [Job 544] Reading command status...
D [27/Nov/2003:22:01:40 +0100] [Job 544] lpd_command returning 0
I [27/Nov/2003:22:01:40 +0100] [Job 544] Sending data file (390971 bytes)
I [27/Nov/2003:22:01:40 +0100] [Job 544] Spooling LPR job, 0% complete...
I [27/Nov/2003:22:01:40 +0100] [Job 544] Spooling LPR job, 2% complete...
..
I [27/Nov/2003:22:02:06 +0100] [Job 544] Spooling LPR job, 98% complete...
I [27/Nov/2003:22:02:07 +0100] [Job 544] Data file sent successfully
D [27/Nov/2003:22:02:07 +0100] UpdateJob: job 544, file 0 is complete.
d [27/Nov/2003:22:02:07 +0100] UpdateJob: Removing fd 10 from InputSet...
D [27/Nov/2003:22:02:07 +0100] CancelJob: id = 544
D [27/Nov/2003:22:02:07 +0100] StopJob: id = 544, force = 0
D [27/Nov/2003:22:02:07 +0100] StopJob: printer state is 3
d [27/Nov/2003:22:02:07 +0100] StopJob: Freeing status buffer...
d [27/Nov/2003:22:02:07 +0100] SaveJob: Closing file 9...
d [27/Nov/2003:22:02:07 +0100] SaveJob: Closing file 9...
d [27/Nov/2003:22:02:07 +0100] PID 7457 exited with no errors.

When the printer is off:

I [30/Nov/2003:17:49:49 +0100] [Job 556] Attempting to connect to host 192.168.0.1 for printer
I [30/Nov/2003:17:49:49 +0100] [Job 556] Connected to 192.168.0.1...
D [30/Nov/2003:17:49:49 +0100] [Job 556] Connected on ports 515 (local 0)...
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command 02
D [30/Nov/2003:17:49:49 +0100] [Job 556] Sending command string (2 bytes)...
D [30/Nov/2003:17:49:49 +0100] [Job 556] Reading command status...
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command returning 0
D [30/Nov/2003:17:49:49 +0100] [Job 556] Control file is:
D [30/Nov/2003:17:49:49 +0100] [Job 556] Hmatrix
D [30/Nov/2003:17:49:49 +0100] [Job 556] Pehmsen
D [30/Nov/2003:17:49:49 +0100] [Job 556] Jtemp_txt
D [30/Nov/2003:17:49:49 +0100] [Job 556] ldfA916matrix
D [30/Nov/2003:17:49:49 +0100] [Job 556] UdfA916matrix
D [30/Nov/2003:17:49:49 +0100] [Job 556] Ntemp_txt
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command 02 64 cfA916matrix
D [30/Nov/2003:17:49:49 +0100] [Job 556] Sending command string (17 bytes)...
D [30/Nov/2003:17:49:49 +0100] [Job 556] Reading command status...
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command returning 0
I [30/Nov/2003:17:49:49 +0100] [Job 556] Sending control file (64 bytes)
I [30/Nov/2003:17:49:49 +0100] [Job 556] Control file sent successfully
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command 03 390971 dfA916matrix
D [30/Nov/2003:17:49:49 +0100] [Job 556] Sending command string (21 bytes)...
D [30/Nov/2003:17:49:49 +0100] [Job 556] Reading command status...
D [30/Nov/2003:17:49:49 +0100] [Job 556] lpd_command returning -1
D [30/Nov/2003:17:49:49 +0100] UpdateJob: job 556, file 0 is complete.
d [30/Nov/2003:17:49:49 +0100] UpdateJob: Removing fd 9 from InputSet...
D [30/Nov/2003:17:49:49 +0100] CancelJob: id = 556
D [30/Nov/2003:17:49:49 +0100] StopJob: id = 556, force = 0
D [30/Nov/2003:17:49:49 +0100] StopJob: printer state is 3
d [30/Nov/2003:17:49:49 +0100] StopJob: Freeing status buffer...
d [30/Nov/2003:17:49:49 +0100] SaveJob: Closing file 9...
d [30/Nov/2003:17:49:49 +0100] SaveJob: Closing file 9...
E [30/Nov/2003:17:49:49 +0100] PID 6916 stopped with status 1!

As seen above, the return status from the backend dosen't change the action taken by job.c
The job is removed before the exit status of lpd is discovered!

I haven't been able to fix it by my self (at least not so far), but this is clearly a problem that should be fixed.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Reassigned to 1.2.

What OS are you using?

What compiler are you using?

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: ehmsen.imada.sdu

I'm using linux (2.4.23) and gcc version 3.3.2

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

What version of CUPS are you currently using?

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: thames.get2net

I'm using 1.1.20 (and thats the same version I used when reporting the bug)

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

OK, I think I know what is going wrong - the job status is getting checked before the signals...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: thames.get2net

Thats also what I would conclude based on the log above.
Please let me know if there is anything I can do to help fix the problem.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Please try the attached patch to see if it fixes the problem...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: thames.get2net

The patch seems to work fine. Now the job dosen't get removed if I printed it while the printer was turned off.

This is probably not related but, now if I have a job waiting to be printed and I turn on my printer, it dosen't get printed right away. I have to enable the printer either via the web-interface or via the command "enable".
This is probably just a misconfiguration from my side, but I can't seem to find anything related in the documentation.
Can you point me in the right direction, and then you will never hear another peep from me :-)

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

If you have a locally connected printer (parallel, serial, or USB) then if the device is not connected or powered on, or if the port does not exist, the backend will exit with a non-zero exit status which stops the queue.

Currently the only policy for queue errors is to stop the queue; CUPS 1.2 will add retry-job and cancel-job policies, as well as optionally notifying people that something has happened...

@michaelrsweet
Copy link
Collaborator Author

"str448.patch":

Index: job.c

RCS file: /development/cvs/cups/scheduler/job.c,v
retrieving revision 1.222
diff -u -r1.222 job.c
--- job.c 5 Nov 2003 19:11:42 -0000 1.222
+++ job.c 3 Feb 2004 12:49:11 -0000
@@ -2104,6 +2104,7 @@
void
UpdateJob(job_t job) / I - Job to check */
{

  • int i; /* Looping var /
    int bytes; /
    Number of bytes read /
    int copies; /
    Number of copies printed /
    char *lineptr, /
    Pointer to end of line in buffer */
    @@ -2283,6 +2284,19 @@

if (bytes <= 0)
{

  • /*
  • * See if all of the filters and the backend have returned their
  • * exit statuses.
  • */
  • for (i = 0; job->procs[i]; i ++)
  •  if (job->procs[i] > 0)
    
  • return;
  • /*
  • * Handle the end of job stuff...
  • */

LogMessage(L_DEBUG, "UpdateJob: job %d, file %d is complete.",
job->id, job->current_file - 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