changeset 6254:1111f9acb96b

8001034: Memory management improvements Reviewed-by: prr, jgodinez
author bae
date Wed, 27 Feb 2013 11:53:10 +0400
parents 52c41d308415
children b1a2b9ac9714
files src/solaris/native/sun/awt/awt_GraphicsEnv.c src/solaris/native/sun/awt/awt_GraphicsEnv.h src/solaris/native/sun/java2d/x11/X11SurfaceData.c
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Tue Feb 26 12:45:21 2013 -0800
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Feb 27 11:53:10 2013 +0400
@@ -978,6 +978,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) {
@@ -1016,7 +1018,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/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Tue Feb 26 12:45:21 2013 -0800
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Wed Feb 27 11:53:10 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/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Tue Feb 26 12:45:21 2013 -0800
+++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Wed Feb 27 11:53:10 2013 +0400
@@ -92,6 +92,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;
@@ -122,6 +123,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) {
@@ -558,7 +566,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",