src/solaris/native/sun/awt/awt_GraphicsEnv.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 828,837 **** --- 828,839 ---- JNU_ThrowInternalError(env, errmsg); return NULL; } XSetIOErrorHandler(xioerror_handler); + JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "init", "(J)V", + ptr_to_jlong(awt_display)); /* set awt_numScreens, and whether or not we're using Xinerama */ xineramaInit(); if (!usingXinerama) {
*** 974,1007 **** #ifdef MITSHM static jint canUseShmExt = UNSET_MITSHM; static jint canUseShmExtPixmaps = UNSET_MITSHM; - static jboolean xshmAttachFailed = JNI_FALSE; extern int mitShmPermissionMask; - int J2DXErrHandler(Display *display, XErrorEvent *xerr) { - int ret = 0; - if (xerr->minor_code == X_ShmAttach) { - xshmAttachFailed = JNI_TRUE; - } else { - ret = (*xerror_saved_handler)(display, xerr); - } - return ret; - } - jboolean isXShmAttachFailed() { - return xshmAttachFailed; - } - void resetXShmAttachFailed() { - xshmAttachFailed = JNI_FALSE; - } - void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) { XShmSegmentInfo shminfo; int XShmMajor, XShmMinor; int a, b, c; AWT_LOCK(); if (canUseShmExt != UNSET_MITSHM) { *shmExt = canUseShmExt; *shmPixmaps = canUseShmExtPixmaps; --- 976,993 ---- #ifdef MITSHM static jint canUseShmExt = UNSET_MITSHM; static jint canUseShmExtPixmaps = UNSET_MITSHM; extern int mitShmPermissionMask; void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) { XShmSegmentInfo shminfo; int XShmMajor, XShmMinor; int a, b, c; + jboolean xShmAttachResult; AWT_LOCK(); if (canUseShmExt != UNSET_MITSHM) { *shmExt = canUseShmExt; *shmPixmaps = canUseShmExtPixmaps;
*** 1036,1060 **** strerror(errno)); return; } shminfo.readOnly = True; ! resetXShmAttachFailed(); ! /** ! * The J2DXErrHandler handler will set xshmAttachFailed ! * to JNI_TRUE if any Shm error has occured. ! */ ! EXEC_WITH_XERROR_HANDLER(J2DXErrHandler, ! XShmAttach(awt_display, &shminfo)); ! /** * Get rid of the id now to reduce chances of leaking * system resources. */ shmctl(shminfo.shmid, IPC_RMID, 0); ! if (isXShmAttachFailed() == JNI_FALSE) { canUseShmExt = CAN_USE_MITSHM; /* check if we can use shared pixmaps */ XShmQueryVersion(awt_display, &XShmMajor, &XShmMinor, (Bool*)&canUseShmExtPixmaps); canUseShmExtPixmaps = canUseShmExtPixmaps && --- 1022,1039 ---- strerror(errno)); return; } shminfo.readOnly = True; ! xShmAttachResult = TryXShmAttach(env, awt_display, &shminfo); /** * Get rid of the id now to reduce chances of leaking * system resources. */ shmctl(shminfo.shmid, IPC_RMID, 0); ! if (xShmAttachResult == JNI_TRUE) { canUseShmExt = CAN_USE_MITSHM; /* check if we can use shared pixmaps */ XShmQueryVersion(awt_display, &XShmMajor, &XShmMinor, (Bool*)&canUseShmExtPixmaps); canUseShmExtPixmaps = canUseShmExtPixmaps &&
*** 1065,1074 **** --- 1044,1070 ---- *shmExt = canUseShmExt; *shmPixmaps = canUseShmExtPixmaps; } AWT_UNLOCK(); } + + /* + * Must be called with the acquired AWT lock. + */ + jboolean TryXShmAttach(JNIEnv *env, Display *display, XShmSegmentInfo *shminfo) { + jboolean errorOccurredFlag = JNI_FALSE; + jobject errorHandlerRef; + + /* + * XShmAttachHandler will set its internal flag to JNI_TRUE, if any Shm error occurs. + */ + EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$XShmAttachHandler", + "()Lsun/awt/X11/XErrorHandler$XShmAttachHandler;", JNI_TRUE, + errorHandlerRef, errorOccurredFlag, + XShmAttach(display, shminfo)); + return errorOccurredFlag == JNI_FALSE ? JNI_TRUE : JNI_FALSE; + } #endif /* MITSHM */ /* * Class: sun_awt_X11GraphicsEnvironment * Method: checkShmExt