From 1303e5f3c9c90a9a78a4f37734d3ffe7e9a026e3 Mon Sep 17 00:00:00 2001 From: iaom Date: Tue, 16 Nov 2021 09:21:26 +0800 Subject: [PATCH] Optimized the strategy of modifying inotify/max_user_watches. --- ukuisearch-systemdbus/sysdbusregister.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ukuisearch-systemdbus/sysdbusregister.cpp b/ukuisearch-systemdbus/sysdbusregister.cpp index 9303d25..c11c4b5 100644 --- a/ukuisearch-systemdbus/sysdbusregister.cpp +++ b/ukuisearch-systemdbus/sysdbusregister.cpp @@ -63,6 +63,16 @@ QString SysdbusRegister::setInotifyMaxUserWatchesStep1() { } QString SysdbusRegister::setInotifyMaxUserWatchesStep2() { + QFile file("/proc/sys/fs/inotify/max_user_watches"); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + QTextStream ts(&file); + QString s = ts.read(512); + file.close(); + if(s.toInt() >= 9999999 ) { + return s; + } + QByteArray ba; FILE * fp = NULL; char cmd[128]; @@ -109,6 +119,7 @@ int SysdbusRegister::AddInotifyMaxUserInstance(int addNum) return -1; QTextStream ts(&file); QString s = ts.read(512); + file.close(); int instances = s.toInt() + addNum; QByteArray ba;