Spooler does not inform the Port Monitor about errors
I have compiled the XPSDrv demo targeting Windows Vista and run it on
Windows XP. It fails printing some documents causing the applicaitons to
hang when some standard print ports are used. I'm writing a custom print
monitor grounding on the DDK example. Both the redmon and my monitor receive
a premature EndDoc -- after a single 22-byte write is made. The following
error is recorded in the System Event Log:
" The document Microsoft Word - XPSDrv_Config-1.doc owned by valentin failed
to print on printer XPSDrv Sample Driver. Data type: RAW. Size of the spool
file in bytes: 405633. Number of bytes printed: 65577. Total number of pages
in the document: 11. Number of pages printed: 0. Client machine: \\MERCURY.
Win32 error code returned by the print processor: 2147549183 (0x8000ffff). "
The same problem is observed when using RedMon -- it starts your application
and delivers only 22 first bytes to it. There is no way to inform the
application about failure since the monitor is not aware of it itself. I was
trying getting error flag from job status retreived via GetJob in the EndDoc
of my monitor -- The status is PRINTING for normally finished jobs and is
additionally SPOOLING for the troublesome jobs. But but no error observed.
Furthermore, I have also noticed that XPSDrv does not notify the printqueue.
I have a monitor application, which logs all the activity in a printer's
queue but it is silent on the XPS sample driver regardless of whether the
job is printed sucessfully or fails. But that is another story.
I'm sure that 1) XPSDrv must be repaired; and 2) threads must fail fast. The
latter means that you should stop a task once one of it steps (which likely
is a preconditioin for the subsequent stages) fails. I see no reason to
invoke further processing from the monitor when printing fails and the
output is incomplete, therefore.