On Thu, 11 Mar 2021 11:30:52 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>>> I guess having "FALSE" as fAsynchronous value mean the function does not 
>>> return until a change has occurred so do we still need this do-while 
>>> monitoring loop?
>> 
>> You're right, `FALSE` for `fAsynchronous` means the function doesn't return 
>> until a change occurred.
>> 
>> If a change occurs, we refresh the list of print services and then start to 
>> wait again. If we exit the loop, we'll not catch other changes that may 
>> occur.
>> 
>>> And if the function fails once, should we stop monitoring?
>> I followed Sergey's approach in `notifyLocalPrinterChange`, namely if 
>> `FindNextPrinterChangeNotification` returns an error, we quit the loop.
>> 
>> I can't see how we can fix the error if it occurs. Will it succeed the next 
>> time? Probably not. Thus I decided to quit the loop in case of an error.
>
> I also am not sure on this. But I think since this is for remote printer, 
> sometimes network availability issue might be there so it may fail more 
> compared to local printer so I guess we should give this method a fair 
> chance, more than that of local printer change, and not bail out on one 
> failure.....maybe try out after some duration...or 5 times spaced out...as 
> you did for the other EnumPrinter fix..

No, network connectivity cannot affect this. The function watches for registry 
changes, specifically keys created or removed under 
`HKCU\Printers\Connections`. If network is down, you won't be able to add a new 
printer. Yet you can still remove an existing printer.

The case with `EnumPrinters` is very different. A printer may be renamed or a 
new printer may be added therefore the allocated buffer becomes to small to fit 
the updated data. Thus retrying with larger buffer makes perfect sense.

In this case, `RegNotifyChangeKeyValue` could fail only because of invalid 
parameters. If it does, it will fail on the retry because the parameters 
haven't changed.

In that sense, it's the same as with local printers. If the wait/notification 
function fails the first time, it will likely fail the second time and so on…

-------------

PR: https://git.openjdk.java.net/jdk/pull/2915

Reply via email to