From 47653f4e4acd4ca4b679fa5e863f77800604a395 Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Tue, 8 Mar 2011 13:52:56 +0200 Subject: [PATCH] Changes: Disable out of memory adjustments command line parameter added to invoker, code refactoring RevBy: Antti Kervinen --- debian/changelog | 3 ++- src/common/protocol.h | 21 ++++++++++++--------- src/invoker/invoker.c | 31 +++++++++++++++++++------------ src/launcherlib/appdata.cpp | 13 +++++++++---- src/launcherlib/appdata.h | 11 +++++++---- src/launcherlib/booster.cpp | 3 ++- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/debian/changelog b/debian/changelog index 333e942..fa060a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ applauncherd (0.21.0) unstable; urgency=low - * + * Changes: Disable out of memory adjustments command line parameter added to invoker + * Changes: AppData code refactoring -- Jussi Lind Fri, 04 Mar 2011 14:08:07 +0200 diff --git a/src/common/protocol.h b/src/common/protocol.h index 7ce274c..fa4e2ff 100644 --- a/src/common/protocol.h +++ b/src/common/protocol.h @@ -22,16 +22,19 @@ #include +const uint32_t INVOKER_MSG_MAGIC = 0xb0070000; +const uint32_t INVOKER_MSG_MAGIC_VERSION_MASK = 0x0000ff00; +const uint32_t INVOKER_MSG_MAGIC_VERSION = 0x00000300; +const uint32_t INVOKER_MSG_MAGIC_OPTION_MASK = 0x000000ff; +const uint32_t INVOKER_MSG_MAGIC_OPTION_WAIT = 0x00000001; +const uint32_t INVOKER_MSG_MAGIC_OPTION_DLOPEN_GLOBAL = 0x00000002; +const uint32_t INVOKER_MSG_MAGIC_OPTION_DLOPEN_DEEP = 0x00000004; +const uint32_t INVOKER_MSG_MAGIC_OPTION_SINGLE_INSTANCE = 0x00000008; +const uint32_t INVOKER_MSG_MAGIC_OPTION_SPLASH_SCREEN = 0x00000010; +const uint32_t INVOKER_MSG_MAGIC_OPTION_OOM_ADJ_DISABLE = 0x00000020; + + const uint32_t INVOKER_MSG_MASK = 0xffff0000; -const uint32_t INVOKER_MSG_MAGIC = 0xb0070000; -const uint32_t INVOKER_MSG_MAGIC_VERSION_MASK = 0x0000ff00; -const uint32_t INVOKER_MSG_MAGIC_VERSION = 0x00000300; -const uint32_t INVOKER_MSG_MAGIC_OPTION_MASK = 0x000000ff; -const uint32_t INVOKER_MSG_MAGIC_OPTION_WAIT = 0x00000001; -const uint32_t INVOKER_MSG_MAGIC_OPTION_DLOPEN_GLOBAL = 0x00000002; -const uint32_t INVOKER_MSG_MAGIC_OPTION_DLOPEN_DEEP = 0x00000004; -const uint32_t INVOKER_MSG_MAGIC_OPTION_SINGLE_INSTANCE = 0x00000008; -const uint32_t INVOKER_MSG_MAGIC_OPTION_SPLASH_SCREEN = 0x00000010; const uint32_t INVOKER_MSG_NAME = 0x5a5e0000; const uint32_t INVOKER_MSG_EXEC = 0xe8ec0000; const uint32_t INVOKER_MSG_ARGS = 0xa4650000; diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index 15571f3..7c03302 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -430,6 +430,8 @@ static void usage(int status) " Show splash screen from the LANDSCAPE-FILE\n" " in case the device is in landscape orientation.\n" " (To be implemented)\n" + " -o, --oom-adj-disable Disable default out of memory killing adjustments \n" + " for launched process. \n" " -h, --help Print this help.\n\n" "Example: %s --type=m /usr/bin/helloworld\n\n", PROG_NAME_INVOKER, PROG_NAME_LAUNCHER, DEFAULT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER); @@ -603,17 +605,18 @@ int main(int argc, char *argv[]) // Options recognized struct option longopts[] = { - {"help", no_argument, NULL, 'h'}, - {"creds", no_argument, NULL, 'c'}, - {"wait-term", no_argument, NULL, 'w'}, - {"no-wait", no_argument, NULL, 'n'}, - {"global-syms", no_argument, NULL, 'G'}, - {"deep-syms", no_argument, NULL, 'D'}, - {"single-instance", no_argument, NULL, 's'}, - {"type", required_argument, NULL, 't'}, - {"delay", required_argument, NULL, 'd'}, - {"respawn", required_argument, NULL, 'r'}, - {"splash", required_argument, NULL, 'S'}, + {"help", no_argument, NULL, 'h'}, + {"creds", no_argument, NULL, 'c'}, + {"wait-term", no_argument, NULL, 'w'}, + {"no-wait", no_argument, NULL, 'n'}, + {"global-syms", no_argument, NULL, 'G'}, + {"deep-syms", no_argument, NULL, 'D'}, + {"single-instance", no_argument, NULL, 's'}, + {"oom-adj-disable", no_argument, NULL, 'o'}, + {"type", required_argument, NULL, 't'}, + {"delay", required_argument, NULL, 'd'}, + {"respawn", required_argument, NULL, 'r'}, + {"splash", required_argument, NULL, 'S'}, {"splash-landscape", required_argument, NULL, 'L'}, {0, 0, 0, 0} }; @@ -621,7 +624,7 @@ int main(int argc, char *argv[]) // Parse options // TODO: Move to a function int opt; - while ((opt = getopt_long(argc, argv, "hcwnGDsd:t:r:S:L:", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "hcwnGDsod:t:r:S:L:", longopts, NULL)) != -1) { switch(opt) { @@ -637,6 +640,10 @@ int main(int argc, char *argv[]) // nothing to do, it's by default now break; + case 'o': + magic_options |= INVOKER_MSG_MAGIC_OPTION_OOM_ADJ_DISABLE; + break; + case 'n': wait_term = false; magic_options &= (~INVOKER_MSG_MAGIC_OPTION_WAIT); diff --git a/src/launcherlib/appdata.cpp b/src/launcherlib/appdata.cpp index 94514fe..659b293 100644 --- a/src/launcherlib/appdata.cpp +++ b/src/launcherlib/appdata.cpp @@ -53,21 +53,26 @@ int AppData::options() const return m_options; } -bool AppData::dlopenGlobal() +bool AppData::dlopenGlobal() const { return (m_options & INVOKER_MSG_MAGIC_OPTION_DLOPEN_GLOBAL) != 0; } -bool AppData::dlopenDeep() +bool AppData::dlopenDeep() const { return (m_options & INVOKER_MSG_MAGIC_OPTION_DLOPEN_DEEP) != 0; } -bool AppData::singleInstance() +bool AppData::singleInstance() const { return (m_options & INVOKER_MSG_MAGIC_OPTION_SINGLE_INSTANCE) != 0; } +bool AppData::disableOutOfMemAdj() const +{ + return (m_options & INVOKER_MSG_MAGIC_OPTION_OOM_ADJ_DISABLE) != 0; +} + void AppData::setArgc(int newArgc) { m_argc = newArgc; @@ -133,7 +138,7 @@ void AppData::setDelay(int newDelay) m_delay = newDelay; } -int AppData::delay() +int AppData::delay() const { return m_delay; } diff --git a/src/launcherlib/appdata.h b/src/launcherlib/appdata.h index 8f1d192..d24534c 100644 --- a/src/launcherlib/appdata.h +++ b/src/launcherlib/appdata.h @@ -54,13 +54,16 @@ public: int options() const; //! Return whether or not RTLD_GLOBAL should be used in dlopen - bool dlopenGlobal(); + bool dlopenGlobal() const; //! Return whether or not RTLD_DEEPBIND should be used in dlopen - bool dlopenDeep(); + bool dlopenDeep() const; //! Return whether or not application should be launched as a single instance application - bool singleInstance(); + bool singleInstance() const; + + //! Return whether or not disable default out of memory killing adjustments for application process + bool disableOutOfMemAdj() const; //! Set argument count void setArgc(int argc); @@ -102,7 +105,7 @@ public: void setDelay(int delay); //!Return respawn delay - int delay(); + int delay() const; //! Set entry point for the application void setEntry(entry_t entry); diff --git a/src/launcherlib/booster.cpp b/src/launcherlib/booster.cpp index 4050d53..1fcc33b 100644 --- a/src/launcherlib/booster.cpp +++ b/src/launcherlib/booster.cpp @@ -323,7 +323,8 @@ void Booster::setEnvironmentBeforeLaunch() setegid(orig); // Reset out-of-memory killer adjustment - resetOomAdj(); + if (!m_appData->disableOutOfMemAdj()) + resetOomAdj(); #ifdef HAVE_CREDS // filter out invoker-specific credentials