[launchd-changes] [22899] trunk/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 16 14:57:28 PDT 2006


Revision: 22899
          http://trac.macosforge.org/projects/launchd/changeset/22899
Author:   zarzycki at apple.com
Date:     2006-10-16 14:57:27 -0700 (Mon, 16 Oct 2006)

Log Message:
-----------
<rdar://problem/4768702> Launchd needs "launch once and only once" capability

Modified Paths:
--------------
    trunk/launchd/src/launch.h
    trunk/launchd/src/launchd.plist.5
    trunk/launchd/src/launchd_core_logic.c

Modified: trunk/launchd/src/launch.h
===================================================================
--- trunk/launchd/src/launch.h	2006-10-16 21:18:21 UTC (rev 22898)
+++ trunk/launchd/src/launch.h	2006-10-16 21:57:27 UTC (rev 22899)
@@ -93,6 +93,7 @@
 #define LAUNCH_JOBKEY_PID			"PID"
 #define LAUNCH_JOBKEY_SUBJOBS			"SubJobs"
 #define LAUNCH_JOBKEY_THROTTLEINTERVAL		"ThrottleInterval"
+#define LAUNCH_JOBKEY_LAUNCHONLYONCE		"LaunchOnlyOnce"
 
 #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT	"Wait"
 

Modified: trunk/launchd/src/launchd.plist.5
===================================================================
--- trunk/launchd/src/launchd.plist.5	2006-10-16 21:18:21 UTC (rev 22898)
+++ trunk/launchd/src/launchd.plist.5	2006-10-16 21:57:27 UTC (rev 22899)
@@ -172,7 +172,7 @@
 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>
+.It Sy ThrottleInterval <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.
@@ -265,20 +265,31 @@
 value should be applied to the daemon.
 .It Sy LowPriorityIO <boolean>
 This optional key specifies whether the kernel should consider this daemon to be low priority when doing file system I/O.
-.It Sy MachServices <dictionary of booleans>
+.It Sy LaunchOnlyOnce <boolean>
+This optional key specifies whether the job can only be run once and only once.
+In other words, if the job cannot be safely respawned without a full machine
+reboot, then set this key to be true.
+.It Sy MachServices <dictionary of booleans or a dictionary of dictionaries>
 This optional key is used to specify Mach services to be registered with the
 Mach bootstrap sub-system.  Each key in this dictionary should be the name of
-service to be advertised.  The value of the key must be a boolean. If the
-boolean is true, the port is recycled, thus leaving clients to remain oblivious
-to the demand nature of job. If the value is set to false, clients receive port
+service to be advertised. The value of the key must be a boolean and set to true.
+Alternatively, a dictionary can be used instead of a simple true value.
+.Bl -ohang -offset indent
+.It Sy ResetAtClose <boolean>
+If this boolean is false, the port is recycled, thus leaving clients to remain oblivious
+to the demand nature of job. If the value is set to true, clients receive port
 death notifications when the job lets go of the receive right. The port will be
 recreated atomically with respect to bootstrap_look_up() calls, so that clients
 can trust that after receiving a port death notification, the new port will
-have already been recreated. Setting the value to false should be done with
-care. Not all clients may be able to handle this behavior. Finally, for the job
-itself, the values will be replaced with Mach ports at the time of check-in
-with
+have already been recreated. Setting the value to true should be done with
+care. Not all clients may be able to handle this behavior. The default value is false.
+.It Sy HideUntilCheckIn <boolean>
+Reserve the name in the namespace, but cause bootstrap_look_up() to fail until the job has checked in with
 .Nm launchd .
+.El
+.Pp
+Finally, for the job itself, the values will be replaced with Mach ports at the time of check-in with
+.Nm launchd .
 .It Sy Sockets <dictionary of dictionaries... OR dictionary of array of dictionaries...>
 This optional key is used to specify launch on demand sockets that can be used to let
 .Nm launchd

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2006-10-16 21:18:21 UTC (rev 22898)
+++ trunk/launchd/src/launchd_core_logic.c	2006-10-16 21:57:27 UTC (rev 22899)
@@ -229,10 +229,12 @@
 	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,
-		importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1, anonymous:1;
+		     ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1,
+		     importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1,
+		     anonymous:1;
 	mode_t mask;
-	unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1, stall_before_exec:1, __pad:26;
+	unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1,
+		     stall_before_exec:1, only_once:1;
 	char label[0];
 };
 
@@ -967,6 +969,8 @@
 	case 'L':
 		if (strcasecmp(key, LAUNCH_JOBKEY_LOWPRIORITYIO) == 0) {
 			j->low_pri_io = value;
+		} else if (strcasecmp(key, LAUNCH_JOBKEY_LAUNCHONLYONCE) == 0) {
+			j->only_once = value;
 		}
 		break;
 	case 'i':
@@ -2489,7 +2493,9 @@
 bool
 job_useless(job_t j)
 {
-	if (j->unload_at_exit && j->start_time != 0) {
+	/* Yes, j->unload_at_exit and j->j->only_once seem the same, but they'll differ someday... */
+
+	if ((j->unload_at_exit || j->only_once) && j->start_time != 0) {
 		job_log(j, LOG_INFO, "Exited. Was only configured to run once.");
 		return true;
 	} else if (shutdown_in_progress) {
@@ -2608,14 +2614,6 @@
 	}
 
 	if (j->priv_port_has_senders) {
-		if (j->start_time && !j->checkedin) {
-			if (j->legacy_mach_job) {
-				job_log(j, LOG_NOTICE, "Daemonized. Extremely expensive no-op.");
-			} else if (!j->unload_at_exit) {
-				job_log(j, LOG_ERR, "Daemonization is not supported under launchd.");
-				return false;
-			}
-		}
 		return true;
 	}
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/10891a42/attachment.html


More information about the launchd-changes mailing list