[libbluray-devel] MountManager: handle mount requests in privileged thread

hpi1 git at videolan.org
Mon Mar 23 09:28:18 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Mar 23 10:27:29 2015 +0200| [074c21806ca9e0687a8ab951edc49e04f1c4d471] | committer: hpi1

MountManager: handle mount requests in privileged thread

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=074c21806ca9e0687a8ab951edc49e04f1c4d471
---

 .../bdj/java/org/videolan/MountManager.java        |   47 ++++++++++++++------
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/MountManager.java b/src/libbluray/bdj/java/org/videolan/MountManager.java
index a49b39d..368f3a0 100644
--- a/src/libbluray/bdj/java/org/videolan/MountManager.java
+++ b/src/libbluray/bdj/java/org/videolan/MountManager.java
@@ -45,19 +45,8 @@ public class MountManager {
 
     /* called from org/dvb/dsmcc/ServiceDomain */
     public static String mount(int jarId) throws MountException {
-        final int id = jarId;
-        Object obj = null;
-        try {
-            obj = AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws MountException {
-                        return mount(id, true);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-             throw (MountException) e.getException();
-        }
-        return (String)obj;
+        /* dispatch mount request to privileged thread */
+        return new MountAction(jarId).execute();
     }
 
     /* package private, called from BDJXletContext */
@@ -289,4 +278,36 @@ public class MountManager {
         private int refCount;
         private boolean classFiles;
     };
+
+    private static class MountAction extends BDJAction {
+        public MountAction(int jarId) {
+            this.jarId = jarId;
+        }
+
+        protected void doAction() {
+            try {
+                this.mountPoint = (String)AccessController.doPrivileged(
+                    new PrivilegedExceptionAction() {
+                        public Object run() throws MountException {
+                            return mount(jarId, true);
+                        }
+                    });
+            } catch (PrivilegedActionException e) {
+                this.exception = (MountException) e.getException();
+            }
+        }
+
+        public String execute() throws MountException {
+            BDJActionManager.getInstance().putCommand(this);
+            waitEnd();
+            if (exception != null) {
+                throw exception;
+            }
+            return mountPoint;
+        }
+
+        private final int jarId;
+        private String mountPoint = null;
+        private MountException exception = null;
+    }
 }



More information about the libbluray-devel mailing list