Revision
22894
Author
zarzycki@apple.com
Date
2006-10-13 08:00:25 -0700 (Fri, 13 Oct 2006)

Log Message

Only allocate the per-job Mach port as needed.

Modified Paths

Diff

Modified: trunk/launchd/src/launchd_core_logic.c (22893 => 22894)


--- trunk/launchd/src/launchd_core_logic.c	2006-10-13 14:52:18 UTC (rev 22893)
+++ trunk/launchd/src/launchd_core_logic.c	2006-10-13 15:00:25 UTC (rev 22894)
@@ -683,6 +683,10 @@
 	j->legacy_mach_job = true;
 	j->priv_port_has_senders = true; /* the IPC that called us will make-send on this port */
 
+	if (!job_setup_machport(j)) {
+		goto out_bad;
+	}
+
 	if (!job_assumes(j, launchd_mport_notify_req(j->bs_port, MACH_NOTIFY_NO_SENDERS) == KERN_SUCCESS)) {
 		job_assumes(j, launchd_mport_close_recv(j->bs_port) == KERN_SUCCESS);
 		goto out_bad;
@@ -816,10 +820,6 @@
 	j->checkedin = true;
 	j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0);
 
-	if (!job_setup_machport(j)) {
-		goto out_bad;
-	}
-
 	if (reqport != MACH_PORT_NULL) {
 		j->req_port = reqport;
 		if (!job_assumes(j, launchd_mport_notify_req(reqport, MACH_NOTIFY_DEAD_NAME) == KERN_SUCCESS)) {
@@ -1673,10 +1673,6 @@
 
 	time(&j->start_time);
 
-	if (j->bs_port) {
-		job_assumes(j, launchd_mport_notify_req(j->bs_port, MACH_NOTIFY_NO_SENDERS) == KERN_SUCCESS);
-	}
-
 	switch (c = job_fork(j->parent)) {
 	case -1:
 		job_log_error(j, LOG_ERR, "fork() failed, will try again in one second");