[launchd-changes] [23935] branches/PR-7178164/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Sat Sep 26 14:45:48 PDT 2009
Revision: 23935
http://trac.macosforge.org/projects/launchd/changeset/23935
Author: dsorresso at apple.com
Date: 2009-09-26 14:45:45 -0700 (Sat, 26 Sep 2009)
Log Message:
-----------
Initial set of changes for the memory limit stuff. Code compiles, but no testing done yet.
Modified Paths:
--------------
branches/PR-7178164/launchd/src/launch_priv.h
branches/PR-7178164/launchd/src/launchd_core_logic.c
Modified: branches/PR-7178164/launchd/src/launch_priv.h
===================================================================
--- branches/PR-7178164/launchd/src/launch_priv.h 2009-09-26 15:13:43 UTC (rev 23934)
+++ branches/PR-7178164/launchd/src/launch_priv.h 2009-09-26 21:45:45 UTC (rev 23935)
@@ -59,6 +59,7 @@
#define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags"
#define LAUNCH_JOBKEY_SANDBOX_NAMED "Named"
#define LAUNCH_JOBKEY_JETSAMPRIORITY "JetsamPriority"
+#define LAUNCH_JOBKEY_JETSAMMEMORYLIMIT "JetsamMemoryLimit"
#define LAUNCH_JOBKEY_SECURITYSESSIONUUID "SecuritySessionUUID"
#define LAUNCH_JOBKEY_EMBEDDEDPRIVILEGEDISPENSATION "EmbeddedPrivilegeDispensation"
Modified: branches/PR-7178164/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-7178164/launchd/src/launchd_core_logic.c 2009-09-26 15:13:43 UTC (rev 23934)
+++ branches/PR-7178164/launchd/src/launchd_core_logic.c 2009-09-26 21:45:45 UTC (rev 23935)
@@ -93,6 +93,7 @@
typedef struct jetsam_priority_entry {
pid_t pid;
uint32_t flags;
+ uint32_t memlimit;
} jetsam_priority_entry_t;
enum {
@@ -133,7 +134,7 @@
#define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20
#define LAUNCHD_SIGKILL_TIMER 5
#define LAUNCHD_CLEAN_KILL_TIMER 1
-#define LAUNCHD_JETSAM_PRIORITY_UNSET 0xdead1eebabell
+#define LAUNCHD_JETSAM_PRIORITY_UNSET 0xdead1ee
#define SHUTDOWN_LOG_DIR "/var/log/shutdown"
@@ -465,8 +466,9 @@
int log_redirect_fd;
int nice;
int stdout_err_fd;
- long long jetsam_priority;
- long long main_thread_priority;
+ uint32_t jetsam_priority;
+ uint32_t jetsam_memlimit;
+ uint32_t main_thread_priority;
uint32_t timeout;
uint32_t exit_timeout;
uint64_t sent_signal_time;
@@ -638,7 +640,6 @@
void eliminate_double_reboot(void);
/* For Jetsam. */
-static void jetsam_priority_from_job(job_t j, bool front, jetsam_priority_entry_t *jp);
static int job_cmp(const job_t *lhs, const job_t *rhs);
int launchd_set_jetsam_priorities(launch_data_t priorities);
@@ -1901,6 +1902,12 @@
j->jetsam_priority = (typeof(j->jetsam_priority))value;
LIST_INSERT_HEAD(&j->mgr->jetsam_jobs, j, jetsam_sle);
j->mgr->jetsam_jobs_cnt++;
+ } else if( strcasecmp(key, LAUNCH_JOBKEY_JETSAMMEMORYLIMIT) == 0 ) {
+ /* The Jetsam stuff really needs to be in its own dictionary. For now,
+ * we'll require that anyone who wants to do anything with Jetsam must
+ * set a priority, even if they only want the memory limit stuff.
+ */
+ j->jetsam_memlimit = (typeof(j->jetsam_memlimit))value;
}
break;
case 'n':
@@ -8913,13 +8920,6 @@
}
}
-static void
-jetsam_priority_from_job(job_t j, bool front, jetsam_priority_entry_t *jp)
-{
- jp->pid = j->p;
- jp->flags |= front ? kJetsamFlagsFrontmost : 0;
-}
-
static int
job_cmp(const job_t *lhs, const job_t *rhs)
{
@@ -8980,11 +8980,11 @@
}
launch_data_t pri;
- long long _pri = 0;
- if( !launchd_assumes(pri = launch_data_dict_lookup(ldi, LAUNCH_KEY_JETSAMPRIORITY)) ) {
+ typeof(ji->jetsam_priority) _pri = 0;
+ if( !launchd_assumes(pri = launch_data_dict_lookup(ldi, LAUNCH_KEY_JETSAMPRIORITY)) || launch_data_get_type(pri) != LAUNCH_DATA_INTEGER ) {
continue;
}
- _pri = launch_data_get_integer(pri);
+ _pri = (typeof(_pri))launch_data_get_integer(pri);
if( ji->jetsam_priority == LAUNCHD_JETSAM_PRIORITY_UNSET ) {
LIST_INSERT_HEAD(&ji->mgr->jetsam_jobs, ji, jetsam_sle);
@@ -8993,11 +8993,18 @@
ji->jetsam_priority = _pri;
launch_data_t frontmost = NULL;
- if( !(frontmost = launch_data_dict_lookup(ldi, LAUNCH_KEY_JETSAMFRONTMOST)) ) {
+ if( !(frontmost = launch_data_dict_lookup(ldi, LAUNCH_KEY_JETSAMFRONTMOST)) || launch_data_get_type(frontmost) != LAUNCH_DATA_BOOL ) {
ji->jetsam_frontmost = false;
continue;
}
ji->jetsam_frontmost = launch_data_get_bool(frontmost);
+
+ launch_data_t memlimit = 0;
+ if( !(memlimit = launch_data_dict_lookup(ldi, LAUNCH_JOBKEY_JETSAMMEMORYLIMIT)) || launch_data_get_type(frontmost) != LAUNCH_DATA_INTEGER ) {
+ ji->jetsam_memlimit = 0;
+ continue;
+ }
+ ji->jetsam_memlimit = (uint32_t)launch_data_get_integer(memlimit);
}
i = 0;
@@ -9019,7 +9026,9 @@
result = ENOMEM;
} else {
for( i = 0; i < totalpris; i++ ) {
- jetsam_priority_from_job(jobs[i], jobs[i]->jetsam_frontmost, &jpris[i]);
+ jpris[i].pid = jobs[i]->p;
+ jpris[i].flags |= jobs[i]->jetsam_frontmost ? kJetsamFlagsFrontmost : 0;
+ jpris[i].memlimit = jobs[i]->jetsam_memlimit;
}
int _result = 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090926/287bee07/attachment.html>
More information about the launchd-changes
mailing list