From 2b26b706ee901d201d424c5e6386649f5fb16636 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Mon, 29 Oct 2012 12:42:49 +0100 Subject: [PATCH] wait for module to be loaded before trying to set parameters --- .../ms2debounce/DebounceModuleHelper.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index fbcc837..b01b2b5 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -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; } -- 2.39.5