Posted on 2004年9月6日 20:03
(From my mail posted to winsock2 newsgroup)
1.If you are a guru in Winsock SPI, especially in LSP, please help me!
If not, sorry to bother you...
2.Summary: I have developed an app based on Layered sample(I know, i
know, it's too old - but it's not my choice :( ), and found a bug when
using LPR printing after installed the pure layered sample.
3.Detail: After install the lsp, we try to print a doc through the
Standard TCP/IP port(LPR). But we always got a message box which tell
us there are some write error, then the message box disappeared, then
pop up several times again(the number of pop up times are random), but
the doc printed successfully.
* Notice that it happened only after we install the release version of
layered - but rarely after we install the debug version. *
4.I just try to debug it with WinDbg, but the strange thing is that
when i attach the debugger to the spoolsv then this bug does NOT
appear again :(
5.After 1 week fighting against the bug. I just have some ideas about
how the spoolsv work:
a. We try to print a doc.
b. the spoolsv call WSASend 4 times with overlapped enabled to send
some command - i don't understand why it pass the same overlapped struc into the lower layer, shouldn't we use saperate struct for each io?
c. then it call WSAGetOverlappedResult to do some judge
d. then it call WSASend several times(the number depend on the size of
the printting doc) to send the print data.
e. then it call WSAGetOverlappedResult to do some judge.
{today i did trace into spoolsv more, and learn that it called KERNEL32!WaitForSingleObject with 5s timeout, and WS2_32!WSAResetEvent the waiting event handle after it has been signaled and so on}
I notice that when a messagebox popuped then Step b-c will execute
again, so i did think that there must be some wrong when the lsp
process the leading 4 overlapped send.
I also have installed the latest LSP sample in PSDK, it have NO the SAME
problems when printing through LPR. I did compare it with the layered
sample but still have no idea about the bug.
Forgive my poor English, i hope you could understand my words and
could give me some advice.
I'm almost crazy now...
Best regards