[launchd-changes] [22862] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 21 10:43:19 PDT 2006
Revision: 22862
http://trac.macosforge.org/projects/launchd/changeset/22862
Author: zarzycki at apple.com
Date: 2006-09-21 10:43:19 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
<rdar://problem/4743457> Let jobs override the default throttle interval
Modified Paths:
--------------
trunk/launchd/src/launch.h
trunk/launchd/src/launchd.plist.5
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/launchd_core_logic.h
Modified: trunk/launchd/src/launch.h
===================================================================
--- trunk/launchd/src/launch.h 2006-09-20 20:29:47 UTC (rev 22861)
+++ trunk/launchd/src/launch.h 2006-09-21 17:43:19 UTC (rev 22862)
@@ -92,6 +92,7 @@
#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus"
#define LAUNCH_JOBKEY_PID "PID"
#define LAUNCH_JOBKEY_SUBJOBS "SubJobs"
+#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInternval"
#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
Modified: trunk/launchd/src/launchd.plist.5
===================================================================
--- trunk/launchd/src/launchd.plist.5 2006-09-20 20:29:47 UTC (rev 22861)
+++ trunk/launchd/src/launchd.plist.5 2006-09-21 17:43:19 UTC (rev 22862)
@@ -169,9 +169,15 @@
.Xr umask 2
before running the job. Known bug: Property lists don't support octal, so please convert the value to decimal.
.It Sy TimeOut <integer>
-The recommended time out (in seconds) to pass to the job. If no value is specified, a default time out will be supplied by
+The recommended idle time out (in seconds) to pass to the job. If no value is specified, a default time out will be supplied by
.Nm launchd
for use by the job at check in time.
+.It Sy ThrottleInternval <integer>
+This key lets one override the default throttling policy imposed on jobs by
+.Nm launchd .
+The value is in seconds, and by default, jobs will not be spawned more than once every 10 seconds.
+The principle behind this is that jobs should linger around just in case their needed again in the near future. This not only
+reduces the latency of responses, but it encourages developers to amortize the cost of program invocation.
.It Sy InitGroups <boolean>
This optional key specifies whether the job should have
.Xr initgroups 3
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2006-09-20 20:29:47 UTC (rev 22861)
+++ trunk/launchd/src/launchd_core_logic.c 2006-09-21 17:43:19 UTC (rev 22862)
@@ -80,6 +80,8 @@
#include "bootstrapServer.h"
#include "mpm_reply.h"
+#define LAUNCHD_MIN_JOB_RUN_TIME 10
+
struct machservice {
SLIST_ENTRY(machservice) sle;
job_t job;
@@ -207,6 +209,7 @@
int nice;
int timeout;
time_t start_time;
+ time_t min_run_time;
unsigned int start_interval;
unsigned int checkedin:1, firstborn:1, debug:1, inetcompat:1, inetcompat_wait:1,
ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1,
@@ -719,6 +722,7 @@
strcpy(j->label, label);
j->kqjob_callback = job_callback;
j->parent = p ? job_get_bs(p) : NULL;
+ j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME;
j->ondemand = true;
j->checkedin = true;
j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0);
@@ -979,8 +983,15 @@
job_log(j, LOG_WARNING, "Timeout less than or equal to zero. Ignoring.");
else
j->timeout = value;
+ } else if (strcasecmp(key, LAUNCH_JOBKEY_THROTTLEINTERVAL) == 0) {
+ if (value < 0) {
+ job_log(j, LOG_WARNING, "%s less than zero. Ignoring.", LAUNCH_JOBKEY_THROTTLEINTERVAL);
+ } else {
+ j->min_run_time = value;
+ }
}
break;
+ break;
case 'u':
case 'U':
if (strcasecmp(key, LAUNCH_JOBKEY_UMASK) == 0) {
@@ -1469,8 +1480,8 @@
td = time(NULL) - j->start_time;
- if (td < LAUNCHD_MIN_JOB_RUN_TIME && !j->legacy_mach_job) {
- time_t respawn_delta = LAUNCHD_MIN_JOB_RUN_TIME - td;
+ if (td < j->min_run_time && !j->legacy_mach_job) {
+ time_t respawn_delta = j->min_run_time - td;
job_log(j, LOG_WARNING, "Throttling respawn: Will start in %ld seconds", respawn_delta);
job_assumes(j, kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, respawn_delta, j) != -1);
Modified: trunk/launchd/src/launchd_core_logic.h
===================================================================
--- trunk/launchd/src/launchd_core_logic.h 2006-09-20 20:29:47 UTC (rev 22861)
+++ trunk/launchd/src/launchd_core_logic.h 2006-09-21 17:43:19 UTC (rev 22862)
@@ -20,8 +20,6 @@
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
-#define LAUNCHD_MIN_JOB_RUN_TIME 10
-
#include "bootstrap_public.h"
#define job_assumes(j, e) \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20060921/92c0e228/attachment.html
More information about the launchd-changes
mailing list