From ca761ec7b8ed9cb105375069c5e0ae256bdde6d8 Mon Sep 17 00:00:00 2001 From: fanpengcheng_cm Date: Sat, 14 Mar 2020 21:26:29 +0800 Subject: [PATCH] feat:Lock the application's physical memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dock锁定到物理内存,不要到swap分区 --- debian/postinst | 20 ++++++++++++++++++++ frame/main.cpp | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 debian/postinst diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 000000000..363b76b36 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +if [ "$1" = configure ]; then + if command -v setcap > /dev/null; then + if setcap cap_ipc_lock+eip /usr/bin/dde-dock;then + chmod u-s /usr/bin/dde-dock + else + echo "Setcap failed, falling back to setuid" >&2 + chmod u+s /usr/bin/dde-dock + fi + else + echo "Setcap is not installed, falling back to setuid" >&2 + chmod u+s /usr/bin/dde-dock + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/frame/main.cpp b/frame/main.cpp index 558432789..478c1f58b 100644 --- a/frame/main.cpp +++ b/frame/main.cpp @@ -35,6 +35,8 @@ #include #include "dbus/dbusdockadaptors.h" +#include + DWIDGET_USE_NAMESPACE #ifdef DCORE_NAMESPACE DCORE_USE_NAMESPACE @@ -111,6 +113,9 @@ int main(int argc, char *argv[]) DApplication::loadDXcbPlugin(); DApplication app(argc, argv); + // 锁定物理内存,用于国测测试 + qDebug() << "lock memory result:" << mlockall(MCL_CURRENT | MCL_FUTURE); + app.setOrganizationName("deepin"); app.setApplicationName("dde-dock"); app.setApplicationDisplayName("DDE Dock");