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

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 9 09:30:05 PST 2008


Revision: 23477
          http://trac.macosforge.org/projects/launchd/changeset/23477
Author:   zarzycki at apple.com
Date:     2008-01-09 09:30:02 -0800 (Wed, 09 Jan 2008)

Log Message:
-----------
Misc branch hints.

Modified Paths:
--------------
    trunk/launchd/src/launchctl.c
    trunk/launchd/src/launchd_core_logic.c
    trunk/launchd/src/launchd_runtime.c

Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c	2007-12-21 21:53:37 UTC (rev 23476)
+++ trunk/launchd/src/launchctl.c	2008-01-09 17:30:02 UTC (rev 23477)
@@ -1475,6 +1475,7 @@
 
 	assumes(load_and_unload_cmd(4, load_launchd_items) == 0);
 
+#ifdef __ppc__
 	/*
 	 * 5066316
 	 *
@@ -1483,7 +1484,7 @@
 	 * I want a plist defined knob for jobs to give advisory hints that
 	 * will "hopefully" serialize bootstrap. Reasons for doing so include
 	 * pragmatic performance optimizations and attempts to workaround bugs
-	 * in jobs. My current thought is something like what follows.
+	 * in jobs. Something like what follows might work:
 	 *
 	 * The BootCache would switch to launchd and add this to the plist:
 	 *
@@ -1519,6 +1520,7 @@
 	 */
 	mach_timespec_t w = { 5, 0 };
 	IOKitWaitQuiet(kIOMasterPortDefault, &w);
+#endif
 
 	do_BootCache_magic(BOOTCACHE_TAG);
 

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-12-21 21:53:37 UTC (rev 23476)
+++ trunk/launchd/src/launchd_core_logic.c	2008-01-09 17:30:02 UTC (rev 23477)
@@ -275,7 +275,7 @@
 };
 
 #define jobmgr_assumes(jm, e)	\
-	(__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true)
+	(likely(e) ? true : jobmgr_log_bug(jm, __LINE__), false)
 
 static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name);
 static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload);
@@ -296,7 +296,7 @@
 static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0)));
 static void jobmgr_log(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
 /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */
-static void jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test);
+static void jobmgr_log_bug(jobmgr_t jm, unsigned int line);
 
 #define DO_RUSAGE_SUMMATION 0
 
@@ -373,7 +373,7 @@
 
 
 #define job_assumes(j, e)	\
-	(__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true)
+	(likely(e) ? true : job_log_bug(j, __LINE__), false)
 
 static void job_import_keys(launch_data_t obj, const char *key, void *context);
 static void job_import_bool(job_t j, const char *key, bool value);
@@ -415,7 +415,7 @@
 static void job_log_stdouterr(job_t j);
 static void job_logv(job_t j, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0)));
 static void job_log_error(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
-static void job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test);
+static void job_log_bug(job_t j, unsigned int line);
 static void job_log_stdouterr2(job_t j, const char *msg, ...);
 static void job_set_exeception_port(job_t j, mach_port_t port);
 static kern_return_t job_handle_mpm_wait(job_t j, mach_port_t srp, int *waitstatus);
@@ -1266,7 +1266,7 @@
 {
 	job_t j = jobmgr_import2(root_jobmgr, pload);
 
-	if (j == NULL) {
+	if (unlikely(j == NULL)) {
 		return NULL;
 	}
 
@@ -1283,17 +1283,16 @@
 	ja = alloca(c * sizeof(job_t ));
 
 	for (i = 0; i < c; i++) {
-		if ((ja[i] = jobmgr_import2(root_jobmgr, launch_data_array_get_index(pload, i)))) {
+		if (likely(ja[i] = jobmgr_import2(root_jobmgr, launch_data_array_get_index(pload, i)))) {
 			errno = 0;
 		}
 		launch_data_array_set_index(resp, launch_data_new_errno(errno), i);
 	}
 
 	for (i = 0; i < c; i++) {
-		if (ja[i] == NULL) {
-			continue;
+		if (likely(ja[i])) {
+			job_dispatch(ja[i], false);
 		}
-		job_dispatch(ja[i], false);
 	}
 
 	return resp;
@@ -1804,22 +1803,22 @@
 		return NULL;
 	}
 
-	if (launch_data_get_type(pload) != LAUNCH_DATA_DICTIONARY) {
+	if (unlikely(launch_data_get_type(pload) != LAUNCH_DATA_DICTIONARY)) {
 		errno = EINVAL;
 		return NULL;
 	}
 
-	if (!(tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL))) {
+	if (unlikely(!(tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL)))) {
 		errno = EINVAL;
 		return NULL;
 	}
 
-	if (launch_data_get_type(tmp) != LAUNCH_DATA_STRING) {
+	if (unlikely(launch_data_get_type(tmp) != LAUNCH_DATA_STRING)) {
 		errno = EINVAL;
 		return NULL;
 	}
 
-	if (!(label = launch_data_get_string(tmp))) {
+	if (unlikely(!(label = launch_data_get_string(tmp)))) {
 		errno = EINVAL;
 		return NULL;
 	}
@@ -1858,15 +1857,15 @@
 	if (unlikely((j = job_find(label)) != NULL)) {
 		errno = EEXIST;
 		return NULL;
-	} else if (label[0] == '\0' || (strncasecmp(label, "", strlen("com.apple.launchd")) == 0) ||
-			(strtol(label, NULL, 10) != 0)) {
+	} else if (unlikely(label[0] == '\0' || (strncasecmp(label, "", strlen("com.apple.launchd")) == 0) ||
+			(strtol(label, NULL, 10) != 0))) {
 		jobmgr_log(jm, LOG_ERR, "Somebody attempted to use a reserved prefix for a label: %s", label);
 		/* the empty string, com.apple.launchd and number prefixes for labels are reserved */
 		errno = EINVAL;
 		return NULL;
 	}
 
-	if ((j = job_new(jm, label, prog, argv))) {
+	if (likely(j = job_new(jm, label, prog, argv))) {
 		launch_data_dict_iterate(pload, job_import_keys, j);
 	}
 
@@ -1959,7 +1958,8 @@
 
 		mib[3] = ldc.pid;
 
-		if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && jobmgr_assumes(root_jobmgr, len == sizeof(kp))) {
+		if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)
+				&& jobmgr_assumes(root_jobmgr, len == sizeof(kp))) {
 			jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u UID %u EUID %u Mach Port 0x%x: %s", __func__, ldc.pid, ldc.uid, ldc.euid, p, kp.kp_proc.p_comm);
 		}
 	}
@@ -2074,7 +2074,7 @@
 
 	job_log(j, LOG_DEBUG, "Reaping");
 
-	if (j->weird_bootstrap) {
+	if (unlikely(j->weird_bootstrap)) {
 		mach_msg_size_t mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem);
 
 		if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) {
@@ -2295,7 +2295,7 @@
 
 	rsz = read(j->log_redirect_fd, buf, BIG_PIPE_SIZE);
 
-	if (rsz == 0) {
+	if (unlikely(rsz == 0)) {
 		job_log(j, LOG_DEBUG, "Standard out/error pipe closed");
 		close_log_redir = true;
 	} else if (!job_assumes(j, rsz != -1)) {
@@ -2312,7 +2312,7 @@
 
 	free(buf);
 
-	if (close_log_redir) {
+	if (unlikely(close_log_redir)) {
 		job_assumes(j, runtime_close(j->log_redirect_fd) != -1);
 		j->log_redirect_fd = 0;
 		job_dispatch(j, false);
@@ -2383,7 +2383,8 @@
 			struct kinfo_proc kp;
 			size_t len = sizeof(kp);
 
-			if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && job_assumes(j, len == sizeof(kp))) {
+			if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)
+					&& job_assumes(j, len == sizeof(kp))) {
 				char newlabel[1000];
 
 				snprintf(newlabel, sizeof(newlabel), "%p.%s", j, kp.kp_proc.p_comm);
@@ -3209,39 +3210,55 @@
 }
 
 void
-jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test)
+jobmgr_log_bug(jobmgr_t jm, unsigned int line)
 {
+	static const char *file;
 	int saved_errno = errno;
-	const char *file = strrchr(path, '/');
 	char buf[100];
 
-	extract_rcsid_substr(rcs_rev, buf, sizeof(buf));
+	extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf));
 
 	if (!file) {
-		file = path;
+		file = strrchr(__FILE__, '/');
+		if (!file) {
+			file = __FILE__;
+		} else {
+			file += 1;
+		}
+	}
+
+	/* the only time 'jm' should not be set is if setting up the first bootstrap fails for some reason */
+	if (likely(jm)) {
+		jobmgr_log(jm, LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
 	} else {
-		file += 1;
+		runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
 	}
-
-	jobmgr_log(jm, LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test);
 }
 
 void
-job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test)
+job_log_bug(job_t j, unsigned int line)
 {
+	static const char *file;
 	int saved_errno = errno;
-	const char *file = strrchr(path, '/');
 	char buf[100];
 
-	extract_rcsid_substr(rcs_rev, buf, sizeof(buf));
+	extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf));
 
 	if (!file) {
-		file = path;
+		file = strrchr(__FILE__, '/');
+		if (!file) {
+			file = __FILE__;
+		} else {
+			file += 1;
+		}
+	}
+
+	/* I cannot think of any reason why 'j' should ever be NULL, nor have I ever seen the case in the wild */
+	if (likely(j)) {
+		job_log(j, LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
 	} else {
-		file += 1;
+		runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
 	}
-
-	job_log(j, LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test);
 }
 
 void
@@ -3417,7 +3434,7 @@
 			job_assumes(j, runtime_close(si->fd) == 0);
 			si->fd = -1;
 		}
-	} while ((si->fd == -1) && (saved_errno == ENOENT));
+	} while (unlikely((si->fd == -1) && (saved_errno == ENOENT)));
 
 	if (saved_errno == ENOTSUP) {
 		/*
@@ -3501,7 +3518,7 @@
 	struct tm *tmptm = context;
 	int64_t val;
 
-	if (LAUNCH_DATA_INTEGER != launch_data_get_type(obj)) {
+	if (unlikely(LAUNCH_DATA_INTEGER != launch_data_get_type(obj))) {
 		/* hack to let caller know something went wrong */
 		tmptm->tm_sec = -1;
 		return;
@@ -3540,13 +3557,13 @@
 		return false;
 	}
 
-	if (LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj)) {
+	if (unlikely(LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj))) {
 		return false;
 	}
 
 	launch_data_dict_iterate(obj, calendarinterval_new_from_obj_dict_walk, &tmptm);
 
-	if (tmptm.tm_sec == -1) {
+	if (unlikely(tmptm.tm_sec == -1)) {
 		return false;
 	}
 
@@ -3591,7 +3608,7 @@
 	struct calendarinterval *ci = LIST_FIRST(&sorted_calendar_events);
 	time_t now = time(NULL);
 
-	if (ci && (ci->when_next < now)) {
+	if (unlikely(ci && (ci->when_next < now))) {
 		jobmgr_assumes(root_jobmgr, raise(SIGUSR1) != -1);
 	}
 }
@@ -3681,7 +3698,7 @@
 	char buf[10000];
 	unsigned int i, buf_off = 0;
 
-	if (sg->junkfds) {
+	if (unlikely(sg->junkfds)) {
 		return;
 	}
 
@@ -3892,6 +3909,7 @@
 	struct stat sb;
 	bool good_exit = (WIFEXITED(j->last_exit_status) && WEXITSTATUS(j->last_exit_status) == 0);
 
+#ifdef __ppc__
 	/*
 	 * 5066316
 	 *
@@ -3901,6 +3919,11 @@
 	if (j->mgr->global_on_demand_cnt > 0 && strcmp(j->label, "com.apple.kextd") != 0) {
 		return false;
 	}
+#else
+	if (j->mgr->global_on_demand_cnt > 0) {
+		return false;
+	}
+#endif
 
 	if (j->start_pending) {
 		job_log(j, LOG_DEBUG, "KeepAlive check: Pent-up non-IPC launch criteria.");
@@ -4071,9 +4094,9 @@
 struct machservice *
 machservice_new(job_t j, const char *name, mach_port_t *serviceport, bool pid_local)
 {
-	struct machservice *ms;
+	struct machservice *ms = calloc(1, sizeof(struct machservice) + strlen(name) + 1);
 
-	if ((ms = calloc(1, sizeof(struct machservice) + strlen(name) + 1)) == NULL) {
+	if (!job_assumes(j, ms != NULL)) {
 		return NULL;
 	}
 
@@ -4411,8 +4434,8 @@
 	}
 
 	jmr = calloc(1, sizeof(struct jobmgr_s) + (name ? (strlen(name) + 1) : 128));
-	
-	if (jmr == NULL) {
+
+	if (!jobmgr_assumes(jm, jmr != NULL)) {
 		return NULL;
 	}
 
@@ -6677,7 +6700,9 @@
 		}
 	}
 
-	if ((msp = calloc(1, sizeof(struct mspolicy) + strlen(name) + 1)) == NULL) {
+	msp = calloc(1, sizeof(struct mspolicy) + strlen(name) + 1);
+
+	if (!job_assumes(j, msp != NULL)) {
 		return false;
 	}
 

Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c	2007-12-21 21:53:37 UTC (rev 23476)
+++ trunk/launchd/src/launchd_runtime.c	2008-01-09 17:30:02 UTC (rev 23477)
@@ -186,7 +186,7 @@
 
 	for (;;) {
 		kr = mach_msg(&dummy.header, MACH_RCV_MSG|MACH_RCV_LARGE, 0, 0, demand_port_set, 0, MACH_PORT_NULL);
-		if (kr == MACH_RCV_PORT_CHANGED) {
+		if (unlikely(kr == MACH_RCV_PORT_CHANGED)) {
 			break;
 		} else if (!launchd_assumes(kr == MACH_RCV_TOO_LARGE)) {
 			continue;
@@ -357,7 +357,7 @@
 	unsigned short flags = kev->flags;
 	unsigned int fflags = kev->fflags;
 
-	if (!(LOG_MASK(level) & internal_mask_pri)) {
+	if (likely(!(LOG_MASK(level) & internal_mask_pri))) {
 		return;
 	}
 
@@ -592,9 +592,7 @@
 
 	bulk_kev = kev;
 
-	launchd_assumes((bulk_kev_cnt = kevent(fd, NULL, 0, kev, BULK_KEV_MAX, &ts)) != -1);
-
-	if (bulk_kev_cnt > 0) {
+	if (launchd_assumes((bulk_kev_cnt = kevent(fd, NULL, 0, kev, BULK_KEV_MAX, &ts)) != -1)) {
 #if 0
 		Dl_info dli;
 
@@ -631,11 +629,11 @@
 	int flags = VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE;
 
 	for (;;) {
-		if (req) {
+		if (likely(req)) {
 			launchd_assumes(vm_deallocate(mach_task_self(), (vm_address_t)req, mz) == KERN_SUCCESS);
 			req = NULL;
 		}
-		if (resp) {
+		if (likely(resp)) {
 			launchd_assumes(vm_deallocate(mach_task_self(), (vm_address_t)resp, mz) == KERN_SUCCESS);
 			resp = NULL;
 		}
@@ -676,7 +674,7 @@
 	if (which == MACH_NOTIFY_NO_SENDERS) {
 		/* Always make sure the send count is zero, in case a receive right is reused */
 		errno = mach_port_set_mscount(mach_task_self(), name, 0);
-		if (errno != KERN_SUCCESS) {
+		if (unlikely(errno != KERN_SUCCESS)) {
 			return errno;
 		}
 	}
@@ -684,7 +682,7 @@
 	errno = mach_port_request_notification(mach_task_self(), name, which, msgc, where,
 			MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous);
 
-	if (errno == 0 && previous != MACH_PORT_NULL) {
+	if (likely(errno == 0) && previous != MACH_PORT_NULL) {
 		launchd_assumes(launchd_mport_deallocate(previous) == KERN_SUCCESS);
 	}
 
@@ -749,7 +747,7 @@
 
 	msg_size = round_page(msg_size + MAX_TRAILER_SIZE);
 
-	if (needed_table_sz > mig_cb_table_sz) {
+	if (unlikely(needed_table_sz > mig_cb_table_sz)) {
 		needed_table_sz *= 2; /* Let's try and avoid realloc'ing for a while */
 		mig_callback *new_table = malloc(needed_table_sz);
 
@@ -757,7 +755,7 @@
 			return KERN_RESOURCE_SHORTAGE;
 		}
 
-		if (mig_cb_table) {
+		if (likely(mig_cb_table)) {
 			memcpy(new_table, mig_cb_table, mig_cb_table_sz);
 			free(mig_cb_table);
 		}
@@ -960,7 +958,7 @@
 
 	trailer_size = tp->msgh_trailer_size - (mach_msg_size_t)(sizeof(mach_msg_trailer_type_t) - sizeof(mach_msg_trailer_size_t));
 
-	if (trailer_size < (mach_msg_size_t)sizeof(audit_token_t)) {
+	if (unlikely(trailer_size < (mach_msg_size_t)sizeof(audit_token_t))) {
 		au_tok = NULL;
 		return;
 	}
@@ -971,7 +969,7 @@
 bool
 runtime_get_caller_creds(struct ldcred *ldc)
 {
-	if (!au_tok) {
+	if (unlikely(!au_tok)) {
 		return false;
 	}
 
@@ -999,7 +997,7 @@
 	for (;;) {
 		to = MACH_MSG_TIMEOUT_NONE;
 
-		if (msg_size != max_msg_size) {
+		if (unlikely(msg_size != max_msg_size)) {
 			/* The buffer isn't big enougth to receive messages anymore... */
 			tmp_options &= ~MACH_RCV_MSG;
 			options &= ~MACH_RCV_MSG;
@@ -1023,13 +1021,13 @@
 
 		tmp_options = options;
 
-		if (mr == MACH_SEND_INVALID_DEST || mr == MACH_SEND_TIMED_OUT) {
+		if (unlikely(mr == MACH_SEND_INVALID_DEST || mr == MACH_SEND_TIMED_OUT)) {
 			/* We need to clean up and start over. */
 			if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) {
 				mach_msg_destroy(&bufReply->Head);
 			}
 			continue;
-		} else if (mr == MACH_RCV_TIMED_OUT) {
+		} else if (unlikely(mr == MACH_RCV_TIMED_OUT)) {
 			if (to != MACH_MSG_TIMEOUT_NONE) {
 				if (runtime_busy_cnt == 0) {
 					launchd_shutdown();
@@ -1046,7 +1044,7 @@
 		bufRequest = bufReply;
 		bufReply = bufTemp;
 
-		if (!(tmp_options & MACH_RCV_MSG)) {
+		if (unlikely(!(tmp_options & MACH_RCV_MSG))) {
 			continue;
 		}
 
@@ -1069,7 +1067,7 @@
 		 * struct to declare our intent.
 		 */
 		static int no_hang_fd = -1;
-		if (no_hang_fd == -1) {
+		if (unlikely(no_hang_fd == -1)) {
 			no_hang_fd = _fd(open("/dev/autofs_nowait", 0));
 		}
 
@@ -1207,7 +1205,7 @@
 	/* we do this to make the unpacking for the log_drain cause unalignment faults */
 	lm_sz = ROUND_TO_64BIT_WORD_SIZE(lm_sz);
 
-	if (!(lm = calloc(1, lm_sz))) {
+	if (unlikely((lm = calloc(1, lm_sz)) == NULL)) {
 		return false;
 	}
 
@@ -1255,7 +1253,7 @@
 
 	mig_allocate(outval, *outvalCnt);
 
-	if (*outval == 0) {
+	if (unlikely(*outval == 0)) {
 		return 1;
 	}
 
@@ -1299,7 +1297,7 @@
 	tmp_port = drain_reply_port;
 	drain_reply_port = MACH_PORT_NULL;
 
-	if ((errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt))) {
+	if (unlikely(errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt))) {
 		launchd_assumes(errno == MACH_SEND_INVALID_DEST);
 		launchd_assumes(launchd_mport_deallocate(tmp_port) == KERN_SUCCESS);
 	}
@@ -1307,7 +1305,16 @@
 	mig_deallocate(outval, outvalCnt);
 }
 
+#if 0
 void
+runtime_kernel_trace(void *code, void *a, void *b, void *c, void *d)
+{
+	/* Request codes from Joe S. */
+	syscall(180 , code, a, b, c, d);
+}
+#endif
+
+void
 runtime_log_push(void)
 {
 	static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER;
@@ -1332,7 +1339,7 @@
 		return;
 	}
 
-	if (shutdown_start == 0) {
+	if (unlikely(shutdown_start == 0)) {
 		shutdown_start = runtime_get_wall_time();
 		launchd_log_vm_stats();
 	}
@@ -1340,14 +1347,14 @@
 
 	pthread_mutex_lock(&ourlock);
 
-	if (ourlogfile == NULL) {
+	if (unlikely(ourlogfile == NULL)) {
 		rename("/var/log/launchd-shutdown.log", "/var/log/launchd-shutdown.log.1");
 		ourlogfile = fopen("/var/log/launchd-shutdown.log", "a");
 	}
 
 	pthread_mutex_unlock(&ourlock);
 
-	if (!ourlogfile) {
+	if (unlikely(!ourlogfile)) {
 		return;
 	}
 
@@ -1541,7 +1548,7 @@
 	static int apple_internal_logging = 1;
 	struct stat sb;
 
-	if (apple_internal_logging == 1) {
+	if (unlikely(apple_internal_logging == 1)) {
 		apple_internal_logging = stat("/AppleInternal", &sb);
 	}
 
@@ -1599,4 +1606,3 @@
 	tbi_float_val = tbi.numer;
 	tbi_float_val /= tbi.denom;
 }
-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080109/79e086d8/attachment-0001.html


More information about the launchd-changes mailing list