1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Root only - Temporarily increase fs.inotify.max_user_watches to 128K (fixes #1208) (#1209)

Forum discussion: https://forum.syncthing.net/t/android-failed-to-set-up-inotify-handler-please-increase-inotify-limits/11924/15
This commit is contained in:
Catfriend1 2018-08-07 19:22:15 +02:00 committed by Audrius Butkevicius
parent 4b7024bf8a
commit 3bd1c753a6

View file

@ -130,6 +130,7 @@ public class SyncthingRunnable implements Runnable {
try {
if (wakeLock != null)
wakeLock.acquire();
increaseInotifyWatches();
HashMap<String, String> targetEnv = buildEnvironment();
process = setupAndLaunch(targetEnv);
@ -260,6 +261,20 @@ public class SyncthingRunnable implements Runnable {
return syncthingPIDs;
}
/**
* Root-only: Temporarily increase "fs.inotify.max_user_watches"
* as Android has a default limit of 8192 watches.
* Manually run "sysctl fs.inotify" in a root shell terminal to check current limit.
*/
private void increaseInotifyWatches() {
if (!mUseRoot || !Shell.SU.available()) {
Log.i(TAG, "increaseInotifyWatches: Root is not available. Cannot increase inotify limit.");
return;
}
int exitCode = Util.runShellCommand("sysctl -n -w fs.inotify.max_user_watches=131072\n", true);
Log.i(TAG, "increaseInotifyWatches: sysctl returned " + Integer.toString(exitCode));
}
/**
* Look for a running libsyncthing.so process and nice its IO.
*/