[launchd-changes] [23964] branches/PR-7431992/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 2 18:13:33 PST 2009


Revision: 23964
          http://trac.macosforge.org/projects/launchd/changeset/23964
Author:   dsorresso at apple.com
Date:     2009-12-02 18:13:30 -0800 (Wed, 02 Dec 2009)
Log Message:
-----------
Uh... yeah. Actually do something when the timer fires this time. Also, handle the case of anonymous jobs creating subsets. Those should have hard references now.

Modified Paths:
--------------
    branches/PR-7431992/launchd/src/launchd_core_logic.c
    branches/PR-7431992/launchd/src/launchd_runtime.c
    branches/PR-7431992/launchd/src/launchd_runtime.h

Modified: branches/PR-7431992/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-7431992/launchd/src/launchd_core_logic.c	2009-12-03 01:39:35 UTC (rev 23963)
+++ branches/PR-7431992/launchd/src/launchd_core_logic.c	2009-12-03 02:13:30 UTC (rev 23964)
@@ -547,7 +547,7 @@
 			clean_exit_timer_expired	:1, /* The job was clean, received SIGKILL and failed to exit after LAUNCHD_CLEAN_KILL_TIMER seconds. */
 			embedded_special_privileges	:1, /* The job runs as a non-root user on embedded but has select privileges of the root user. */
 			did_exec					:1, /* The job exec(2)ed successfully. */
-			migratory					:1, /* The (anonymous) job called vprocmgr_switch_to_session(). */
+			holds_ref					:1, /* The (anonymous) job called vprocmgr_switch_to_session(). */
 			jetsam_properties			:1; /* The job has Jetsam limits in place. */
 	mode_t mask;
 	pid_t tracing_pid;
@@ -668,6 +668,7 @@
 bool g_shutdown_debugging = false;
 bool g_verbose_boot = false;
 bool g_embedded_privileged_action = false;
+bool g_runtime_busy_time = false;
 
 void
 job_ignore(job_t j)
@@ -2777,7 +2778,7 @@
 	
 	if (j->anonymous) {
 		total_anon_children--;
-		if( j->migratory ) {
+		if( j->holds_ref ) {
 			runtime_del_ref();
 		}
 	} else {
@@ -3499,6 +3500,8 @@
 			jobmgr_still_alive_with_check(jm);
 		} else if( kev->ident == (uintptr_t)&jm->reboot_flags ) {
 			jobmgr_do_garbage_collection(jm);
+		} else if( kev->ident == (uintptr_t)&g_runtime_busy_time ) {
+			return launchd_shutdown();
 		}
 		break;
 	case EVFILT_VNODE:
@@ -5573,8 +5576,8 @@
 			if( phase == JOBMGR_PHASE_HOPEFULLY_EXITS_FIRST && !ji->hopefully_exits_first ) {
 				continue;
 			} else if( phase == JOBMGR_PHASE_NORMAL ) {
-				if( ji->migratory ) {
-					/* If we're shutting down, release the hold migratory jobs
+				if( ji->holds_ref ) {
+					/* If we're shutting down, release the hold holds_ref jobs
 					 * have on us.
 					 */
 					job_remove(ji);			
@@ -8318,7 +8321,7 @@
 	}
 	
 	j->mgr = target_jm;
-	j->migratory = true;
+	j->holds_ref = true;
 	*new_bsport = target_jm->jm_port;
 	
 	/* Anonymous jobs which move around are particularly interesting to us, so we want to
@@ -8507,6 +8510,11 @@
 	*subsetportp = jmr->jm_port;
 	jmr->properties |= BOOTSTRAP_PROPERTY_EXPLICITSUBSET;
 	
+	if( j->anonymous ) {
+		j->holds_ref = true;
+		runtime_add_ref();
+	}
+	
 	job_log(j, LOG_DEBUG, "Job created a subset named \"%s\"", jmr->name);
 	return BOOTSTRAP_SUCCESS;
 }

Modified: branches/PR-7431992/launchd/src/launchd_runtime.c
===================================================================
--- branches/PR-7431992/launchd/src/launchd_runtime.c	2009-12-03 01:39:35 UTC (rev 23963)
+++ branches/PR-7431992/launchd/src/launchd_runtime.c	2009-12-03 02:13:30 UTC (rev 23964)
@@ -102,7 +102,6 @@
 static struct ldcred ldc;
 static size_t runtime_busy_cnt;
 static size_t runtime_standby_cnt;
-static size_t runtime_busy_time;
 
 static STAILQ_HEAD(, logmsg_s) logmsg_queue = STAILQ_HEAD_INITIALIZER(logmsg_queue);
 static size_t logmsg_queue_sz;
@@ -1628,7 +1627,7 @@
 runtime_install_timer(void)
 {
 	if( !pid1_magic && runtime_busy_cnt == 0 ) {
-		launchd_assumes(kevent_mod((uintptr_t)&runtime_busy_time, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 30, NULL) != -1);
+		launchd_assumes(kevent_mod((uintptr_t)&g_runtime_busy_time, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 30, root_jobmgr) != -1);
 	}
 }
 
@@ -1636,7 +1635,7 @@
 runtime_remove_timer(void)
 {
 	if( !pid1_magic && runtime_busy_cnt > 0 ) {
-		launchd_assumes(kevent_mod((uintptr_t)&runtime_busy_time, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1);
+		launchd_assumes(kevent_mod((uintptr_t)&g_runtime_busy_time, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1);
 	}
 }
 

Modified: branches/PR-7431992/launchd/src/launchd_runtime.h
===================================================================
--- branches/PR-7431992/launchd/src/launchd_runtime.h	2009-12-03 01:39:35 UTC (rev 23963)
+++ branches/PR-7431992/launchd/src/launchd_runtime.h	2009-12-03 02:13:30 UTC (rev 23964)
@@ -108,6 +108,7 @@
 extern bool g_log_per_user_shutdown;
 extern bool g_log_strict_usage;
 extern bool g_embedded_shutdown_log;
+extern bool g_runtime_busy_time;
 extern int32_t g_sync_frequency;
 extern pid_t g_wsp;
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20091202/79fdd02d/attachment-0001.html>


More information about the launchd-changes mailing list