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

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 16 12:56:13 PST 2008


Revision: 23484
          http://trac.macosforge.org/projects/launchd/changeset/23484
Author:   zarzycki at apple.com
Date:     2008-01-16 12:56:12 -0800 (Wed, 16 Jan 2008)

Log Message:
-----------
A simple change.

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

Modified: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c	2008-01-15 00:51:21 UTC (rev 23483)
+++ trunk/launchd/src/launchd.c	2008-01-16 20:56:12 UTC (rev 23484)
@@ -77,7 +77,6 @@
 
 #define LAUNCHD_CONF ".launchd.conf"
 #define SECURITY_LIB "/System/Library/Frameworks/Security.framework/Versions/A/Security"
-#define SHUTDOWN_LOG_DIR "/var/log/shutdown"
 
 
 extern char **environ;
@@ -93,7 +92,6 @@
 static void monitor_networking_state(void);
 static void fatal_signal_handler(int sig, siginfo_t *si, void *uap);
 static void handle_pid1_crashes_separately(void);
-static void prep_shutdown_log_dir(void);
 
 static bool re_exec_in_single_user_mode;
 static void *crash_addr;
@@ -236,12 +234,6 @@
 	return fd;
 }
 
-void
-prep_shutdown_log_dir(void)
-{
-	launchd_assumes(mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST);
-}
-
 INTERNAL_ABI void
 launchd_shutdown(void)
 {
@@ -259,7 +251,6 @@
 		 * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown
 		 */
 		runtime_setlogmask(LOG_UPTO(LOG_DEBUG));
-		prep_shutdown_log_dir();
 	}
 
 	runtime_log_push();

Modified: trunk/launchd/src/launchd.h
===================================================================
--- trunk/launchd/src/launchd.h	2008-01-15 00:51:21 UTC (rev 23483)
+++ trunk/launchd/src/launchd.h	2008-01-16 20:56:12 UTC (rev 23484)
@@ -26,8 +26,6 @@
 #include "libbootstrap_public.h"
 #include "launchd_runtime.h"
 
-#define SHUTDOWN_LOG_DIR "/var/log/shutdown"
-
 struct kevent;
 struct conncb;
 

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2008-01-15 00:51:21 UTC (rev 23483)
+++ trunk/launchd/src/launchd_core_logic.c	2008-01-16 20:56:12 UTC (rev 23484)
@@ -96,6 +96,7 @@
 #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20
 #define LAUNCHD_SIGKILL_TIMER 5
 
+#define SHUTDOWN_LOG_DIR "/var/log/shutdown"
 
 #define TAKE_SUBSET_NAME	"TakeSubsetName"
 #define TAKE_SUBSET_PID		"TakeSubsetPID"
@@ -714,7 +715,7 @@
 		}
 	}
 
-	if (do_apple_internal_logging() && jm->parentmgr == NULL && pid1_magic) {
+	if (do_apple_internal_logging && jm->parentmgr == NULL && pid1_magic) {
 		runtime_set_timeout(still_alive_with_check, 5);
 	}
 
@@ -4862,10 +4863,14 @@
 	int wstatus;
 	pid_t sp;
 
-	if (!do_apple_internal_logging()) {
+	if (!do_apple_internal_logging) {
 		return;
 	}
 	
+	if (!job_assumes(j, mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST)) {
+		return;
+	}
+
 	snprintf(pidstr, sizeof(pidstr), "%u", j->p);
 	snprintf(logfile, sizeof(logfile), SHUTDOWN_LOG_DIR "/%s-%u.sample.txt", j->label, j->p);
 

Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c	2008-01-15 00:51:21 UTC (rev 23483)
+++ trunk/launchd/src/launchd_runtime.c	2008-01-16 20:56:12 UTC (rev 23484)
@@ -121,7 +121,9 @@
 static sigset_t sigign_set;
 static FILE *ourlogfile;
 bool pid1_magic;
+bool do_apple_internal_logging;
 
+
 INTERNAL_ABI mach_port_t
 runtime_get_kernel_port(void)
 {
@@ -1145,7 +1147,7 @@
 runtime_fsync(int fd)
 {
 #if 0
-	if (do_apple_internal_logging()) {
+	if (do_apple_internal_logging) {
 		return fcntl(fd, F_FULLFSYNC, NULL);
 	} else {
 		return fsync(fd);
@@ -1187,7 +1189,7 @@
 	char newmsg[10000];
 
 	if (attr->priority == LOG_APPLEONLY) {
-		if (do_apple_internal_logging()) {
+		if (do_apple_internal_logging) {
 			attr->priority = LOG_NOTICE;
 		} else {
 			return;
@@ -1552,19 +1554,6 @@
 	launchd_mport_deallocate(mhs);
 }
 
-INTERNAL_ABI bool
-do_apple_internal_logging(void)
-{
-	static int apple_internal_logging = 1;
-	struct stat sb;
-
-	if (unlikely(apple_internal_logging == 1)) {
-		apple_internal_logging = stat("/AppleInternal", &sb);
-	}
-
-	return (apple_internal_logging == 0);
-}
-
 INTERNAL_ABI int64_t
 runtime_get_wall_time(void)
 {
@@ -1612,6 +1601,8 @@
 void
 do_file_init(void)
 {
+	struct stat sb;
+
 	launchd_assert(mach_timebase_info(&tbi) == 0);
 	tbi_float_val = tbi.numer;
 	tbi_float_val /= tbi.denom;
@@ -1619,4 +1610,8 @@
 	if (getpid() == 1) {
 		pid1_magic = true;
 	}
+
+	if (stat("/AppleInternal", &sb) != -1) {
+		do_apple_internal_logging = true;
+	}
 }

Modified: trunk/launchd/src/launchd_runtime.h
===================================================================
--- trunk/launchd/src/launchd_runtime.h	2008-01-15 00:51:21 UTC (rev 23483)
+++ trunk/launchd/src/launchd_runtime.h	2008-01-16 20:56:12 UTC (rev 23484)
@@ -104,6 +104,7 @@
 typedef INTERNAL_ABI void (*timeout_callback)(void);
 
 extern bool pid1_magic;
+extern bool do_apple_internal_logging;
 
 INTERNAL_ABI mach_port_t runtime_get_kernel_port(void);
 
@@ -130,8 +131,6 @@
 INTERNAL_ABI const char *reboot_flags_to_C_names(unsigned int flags);
 INTERNAL_ABI const char *proc_flags_to_C_names(unsigned int flags);
 
-INTERNAL_ABI bool do_apple_internal_logging(void);
-
 INTERNAL_ABI int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt);
 INTERNAL_ABI int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata);
 

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


More information about the launchd-changes mailing list