https://bugs.winehq.org/show_bug.cgi?id=41799
Bug ID: 41799 Summary: winspool.drv: race can cause WINSPOOL_LoadSystemPrinters to fail Product: Wine Version: 1.9.23 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: awilfox@adelielinux.org Distribution: ---
Created attachment 56232 --> https://bugs.winehq.org/attachment.cgi?id=56232 winspool.drv: Clear last error when creating mutex
WINSPOOL_LoadSystemPrinters creates a unique mutex and then checks if GetLastError is ERROR_ALREADY_EXISTS. Running 1.9.23 with staging or unpatched, and current -HEAD, I'm seeing a race where sometimes a stale error is left and it returns ERROR_ALREADY_EXISTS due to another component. This causes printing to always fail on my machine, since CUPS_LoadPrinters is never called and therefore no printers exist.
This one-line patch has allowed printing to work on my system and still guards against multiple initialisations.