* limitations under the License.
*/
-#include "db_handle_provider.hh"
-
+#include <fcntl.h>
#include <sys/types.h>
#include <tzplatform_config.h>
#include <algorithm>
+#include <string>
#include <vector>
+#include "db_handle_provider.hh"
#include "pkgmgrinfo_debug.h"
#include "pkgmgr-info.h"
return *prov;
}
+bool DBHandleProvider::IsCrashedWriteRequest() {
+ std::unique_lock<std::recursive_mutex> u(lock_);
+ if (pid_list_.empty())
+ return false;
+ bool ret = true;
+ LOGD("Check process count : %d", pid_list_.size());
+ std::vector<pid_t> remove_pids;
+ for (pid_t pid : pid_list_) {
+ std::string status_path = "/proc/" + std::to_string(pid) + "/status";
+
+ int fd = open(status_path.c_str(), O_RDONLY);
+ if (fd < 0) {
+ LOGE("Process is crashed (%d)", pid);
+ remove_pids.push_back(pid);
+ } else {
+ ret = false;
+ close(fd);
+ }
+ }
+
+ for (pid_t pid : remove_pids)
+ pid_list_.erase(pid);
+
+ return ret;
+}
+
std::vector<std::pair<std::string, uid_t>> DBHandleProvider::GetParserDBPath(
pid_t pid, bool write) {
std::unique_lock<std::recursive_mutex> u(lock_);
public:
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
+ static bool IsCrashedWriteRequest();
std::vector<std::pair<std::string, uid_t>> GetParserDBPath(int pid, bool write);
std::string GetCertDBPath(int pid, bool write);
void SetMemoryMode(int pid, bool flag);
* limitations under the License.
*/
-#include "worker_thread.hh"
#include <sqlite3.h>
#include <malloc.h>
+#include "worker_thread.hh"
+#include "db_handle_provider.hh"
+
#include "pkgmgrinfo_debug.h"
#include "get_appinfo_request_handler.hh"
#include "get_cert_request_handler.hh"
malloc_trim(0);
*timer = 0;
+ if (pkgmgr_common::DBHandleProvider::IsCrashedWriteRequest())
+ pkgmgr_common::DBHandleProvider::
+ GetInst(getuid()).SetMemoryMode(getpid(), false);
+
return false;
}