8001034: Memory management improvements
authorbae
Wed, 27 Feb 2013 12:10:59 +0400
changeset 18184 75811cab0180
parent 16929 c984ae5655cb
child 18185 607d2fb48f47
8001034: Memory management improvements Reviewed-by: mschoene, prr, jgodinez
jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h
jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Tue Apr 16 13:51:53 2013 -0400
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Feb 27 12:10:59 2013 +0400
@@ -906,6 +906,8 @@
 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) {
@@ -944,7 +946,8 @@
      * we need to test that we can actually do XShmAttach.
      */
     if (XShmQueryExtension(awt_display)) {
-        shminfo.shmid = shmget(IPC_PRIVATE, 0x10000, IPC_CREAT|0777);
+        shminfo.shmid = shmget(IPC_PRIVATE, 0x10000,
+                               IPC_CREAT|mitShmPermissionMask);
         if (shminfo.shmid < 0) {
             AWT_UNLOCK();
             J2dRlsTraceLn1(J2D_TRACE_ERROR,
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Tue Apr 16 13:51:53 2013 -0400
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Wed Feb 27 12:10:59 2013 +0400
@@ -47,6 +47,9 @@
 #include <X11/extensions/shmproto.h>
 #endif
 
+#define MITSHM_PERM_COMMON (0666)
+#define MITSHM_PERM_OWNER  (0600)
+
 extern int XShmQueryExtension();
 
 void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps);
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Tue Apr 16 13:51:53 2013 -0400
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Wed Feb 27 12:10:59 2013 +0400
@@ -89,6 +89,7 @@
 jint useMitShmExt = CANT_USE_MITSHM;
 jint useMitShmPixmaps = CANT_USE_MITSHM;
 jint forceSharedPixmaps = JNI_FALSE;
+int mitShmPermissionMask = MITSHM_PERM_OWNER;
 
 /* Cached shared image, one for all surface datas. */
 static XImage * cachedXImage;
@@ -119,6 +120,13 @@
     if (getenv("NO_AWT_MITSHM") == NULL &&
         getenv("NO_J2D_MITSHM") == NULL) {
         char * force;
+        char * permission = getenv("J2D_MITSHM_PERMISSION");
+        if (permission != NULL) {
+            if (strcmp(permission, "common") == 0) {
+                mitShmPermissionMask = MITSHM_PERM_COMMON;
+            }
+        }
+
         TryInitMITShm(env, &useMitShmExt, &useMitShmPixmaps);
 
         if(allowShmPixmaps) {
@@ -536,7 +544,8 @@
         return NULL;
     }
     shminfo->shmid =
-        shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777);
+        shmget(IPC_PRIVATE, height * img->bytes_per_line,
+               IPC_CREAT|mitShmPermissionMask);
     if (shminfo->shmid < 0) {
         J2dRlsTraceLn1(J2D_TRACE_ERROR,
                        "X11SD_SetupSharedSegment shmget has failed: %s",