[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: [OpenJDK 2D-Dev] Patch: fix race condition in UnixPrintServiceLookup
From: Jennifer.Godinez () Sun ! COM (Jennifer Godinez)
Date: 2008-08-06 19:00:24
Message-ID: 4899F4C8.60102 () Sun ! COM
[Download RAW message or body]
Hi Andrew,
Bug is filed on this with ID 6731826. We are looking at your suggested fix and also \
looking at other ways to fix it. Stay tuned.
Jennifer
Andrew Haley wrote:
> The JCK revealed a race condition in UnixPrintServiceLookup when either
> sun.java2d.print.polling=false or getDefaultPrintService() returns
> before the polling PrintServices thread has started. This causes
> multiple copies of IPPPrintService to be instantiated. The test below
> fails on all platforms with -Dsun.java2d.print.polling=false and on
> some platforms with -Dsun.java2d.print.polling=true, depending on how
> long it takes the polling loop to start.
>
> The simple fix is to ensure that we call refreshServices() from the
> constructor, ensuring that everything is initialized before the first
> call to lookupDefaultPrintService().
>
> Is this patch a good approach to fixing the problem?
>
> Andrew.
>
>
> ----------------------------------------------------------------------------------
> import javax.print.PrintService;
> import javax.print.PrintServiceLookup;
>
>
> public class Test {
>
> public static void main(String argv[]) {
> trial();
> }
>
> static void trial() {
> PrintService pserv1 = PrintServiceLookup.lookupDefaultPrintService();
> PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
> PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
>
> if (pserv1.hashCode() != pserv2.hashCode()) {
> System.err.println("Different hashCodes for equal print "
> + "services: " + pserv1.hashCode() + " "
> + pserv2.hashCode());
> }
> }
> }
>
> ----------------------------------------------------------------------------------
>
> --- /notnfs/user/TCK_candidate/icedtea6-1.2/openjdk/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java \
> 2008-04-11 04:18:13.000000000 -0400
> +++ sun/print/UnixPrintServiceLookup.java 2008-07-30 12:45:40.000000000 -0400
> @@ -163,6 +163,12 @@
>
>
> public UnixPrintServiceLookup() {
> + try {
> + refreshServices();
> + } catch (Exception se) {
> + IPPPrintService.debug_println(debugPrefix+"Exception in \
> refreshServices()"); + }
> +
> // start the printer listener thread
> if (pollServices) {
> PrinterChangeListener thr = new PrinterChangeListener();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic