wait for module to be loaded before trying to set parameters
authorMichael Gernoth <michael@gernoth.net>
Mon, 29 Oct 2012 11:42:49 +0000 (12:42 +0100)
committerMichael Gernoth <michael@gernoth.net>
Mon, 29 Oct 2012 11:42:49 +0000 (12:42 +0100)
MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java

index fbcc837..b01b2b5 100644 (file)
@@ -93,6 +93,16 @@ public class DebounceModuleHelper
 
                runAsRoot(insmod + " " + debounce_ko);
 
+               int cnt = 10;
+               while ((!isLoaded()) && (cnt > 0)) {
+                       try {
+                               Thread.sleep(100);
+                       } catch (Exception e) {
+                               return false;
+                       }
+                       cnt--;
+               }
+
                if (!isLoaded()) {
                        return false;
                }
@@ -123,6 +133,7 @@ public class DebounceModuleHelper
 
        public synchronized boolean isLoaded() {
                boolean loaded = false;
+
                try {
                        String read;
 
@@ -131,10 +142,13 @@ public class DebounceModuleHelper
 
                        while((read = modules_buf.readLine()) != null) {
                                if (read.regionMatches(0, "debounce", 0, 8)) {
-                                       loaded = true;
+                                       File sysdir = new File("/sys/devices/debounce");
+                                       if (sysdir.exists() && sysdir.isDirectory()) {
+                                               loaded = true;
+                                               break;
+                                       }
                                }
                        }
-
                } catch (Exception e) {
                        loaded = false;
                }
Impressum, Datenschutz