[launchd-changes] [23762] trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Dec 12 14:46:45 PST 2008


Revision: 23762
          http://trac.macosforge.org/projects/launchd/changeset/23762
Author:   dsorresso at apple.com
Date:     2008-12-12 14:46:45 -0800 (Fri, 12 Dec 2008)
Log Message:
-----------
<rdar://problem/6428552> Screen Sharing not started
<rdar://problem/6434297> Remove more debug messages

Embedded build fixes.

Modified Paths:
--------------
    trunk/launchd/src/launchctl.c
    trunk/launchd/src/launchd_core_logic.c
    trunk/launchd/src/liblaunch.c
    trunk/launchd.xcodeproj/project.pbxproj

Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c	2008-12-11 21:49:26 UTC (rev 23761)
+++ trunk/launchd/src/launchctl.c	2008-12-12 22:46:45 UTC (rev 23762)
@@ -1706,7 +1706,9 @@
 	}
 
 	assumes(touch_file(_PATH_UTMPX, DEFFILEMODE) != -1);
+#if !TARGET_OS_EMBEDDED
 	assumes(touch_file(_PATH_VARRUN "/.systemStarterRunning", DEFFILEMODE) != -1);
+#endif
 
 	if (path_check("/etc/security/rc.audit")) {
 		const char *audit_tool[] = { _PATH_BSHELL, "/etc/security/rc.audit", NULL };
@@ -1719,17 +1721,20 @@
 
 	_vproc_set_global_on_demand(true);
 
-	char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d",
-#if TARGET_OS_EMBEDDED
-		"/var/mobile/Library/LaunchAgents",
+	
+#if !TARGET_OS_EMBEDDED
+	char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d", NULL };
+	int load_launchd_items_cnt = 4;
+#else
+	char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d",	"/var/mobile/Library/LaunchAgents", NULL };
+	int load_launchd_items_cnt = 5;
 #endif
-		NULL };
 
 	if (is_safeboot()) {
 		load_launchd_items[2] = "system";
 	}
 
-	assumes(load_and_unload_cmd(4, load_launchd_items) == 0);
+	assumes(load_and_unload_cmd(load_launchd_items_cnt, load_launchd_items) == 0);
 
 	/*
 	 * 5066316

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2008-12-11 21:49:26 UTC (rev 23761)
+++ trunk/launchd/src/launchd_core_logic.c	2008-12-12 22:46:45 UTC (rev 23762)
@@ -4228,7 +4228,6 @@
 semaphoreitem_watch(job_t j, struct semaphoreitem *si)
 {
 	char *parentdir, tmp_path[PATH_MAX];
-	const char *which_path = si->what;
 	int saved_errno = 0;
 	int fflags = NOTE_DELETE|NOTE_RENAME;
 
@@ -4256,20 +4255,18 @@
 	/* See 5321044 for why we do the do-while loop and 5415523 for why ENOENT is checked */
 	do {
 		if (si->fd == -1) {
-			if ((si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY))) == -1) {
-				which_path = parentdir;
-				si->watching_parent = true;
-				si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY));
+			if ((si->fd = _fd(open(si->what, O_EVTONLY|O_NOCTTY))) == -1) {
+				si->watching_parent = job_assumes(j, (si->fd = _fd(open(parentdir, O_EVTONLY|O_NOCTTY))) != -1);
 			} else {
 				si->watching_parent = false;
 			}
 		}
 
 		if (si->fd == -1) {
-			return job_log_error(j, LOG_ERR, "Path monitoring failed on \"%s\"%s", si->what, si->watching_parent ? " (Could not monitor parent directory)" : "");
+			return job_log_error(j, LOG_ERR, "Path monitoring failed on \"%s\"", si->what);
 		}
 
-		job_log(j, LOG_DEBUG, "Watching %svnode: %d", si->watching_parent ? "parent ": "", si->fd);
+		job_log(j, LOG_DEBUG, "Watching %svnode (%s): %d", si->watching_parent ? "parent ": "", si->what, si->fd);
 
 		if (kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) == -1) {
 			saved_errno = errno;
@@ -4311,6 +4308,7 @@
 		case PATH_EXISTS:
 		case PATH_MISSING:
 		case DIR_NOT_EMPTY:
+			job_log(j, LOG_DEBUG, "P%s changed (%u): %s", si->watching_parent ? "arent path" : "ath", si->why, si->what);
 			break;
 		default:
 			continue;
@@ -4352,8 +4350,6 @@
 	}
 
 	if( !si->watching_parent ) {
-		job_log(j, LOG_DEBUG, "Watch path modified: %s", si->what);
-
 		if (si->why == PATH_CHANGES) {
 			j->start_pending = true;
 		}
@@ -4363,10 +4359,6 @@
 			si->fd = -1; /* this will get fixed in semaphoreitem_watch() */
 			semaphoreitem_watch(j, si);
 		}
-		
-		if( !si->watching_parent ) {
-			j->start_pending = true;
-		}
 	}
 	
 	job_dispatch(j, false);
@@ -4904,12 +4896,20 @@
 			wanted_state = true;
 		case PATH_MISSING:
 			if ((bool)(stat(si->what, &sb) == 0) == wanted_state) {
-				if (si->fd != -1) {
-					job_assumes(j, runtime_close(si->fd) == 0);
-					si->fd = -1;
+				job_log(j, LOG_NOTICE, "KeepAlive: The following path %s: %s", wanted_state ? "exists" : "is missing", si->what);
+				return true;
+			} else {
+				if( wanted_state ) { /* File is not there but we wish it was. */
+					if( si->fd != -1 && !si->watching_parent ) { /* Need to be watching the parent now. */
+						job_assumes(j, runtime_close(si->fd) == 0);
+						si->fd = -1;
+					}
+				} else { /* File is there but we wish it wasn't. */
+					if( si->fd != -1 && si->watching_parent ) { /* Need to watch the file now. */
+						job_assumes(j, runtime_close(si->fd) == 0);
+						si->fd = -1;
+					}
 				}
-				job_log(j, LOG_DEBUG, "KeepAlive: The following path %s: %s", wanted_state ? "exists" : "is missing", si->what);
-				return true;
 			}
 			break;
 		case PATH_CHANGES:
@@ -5551,6 +5551,9 @@
 		if( jobmgr_assumes(jm, pid1_magic) ) {
 			/* Have our system bootstrapper print out to the console. */
 			bootstrapper->stdoutpath = _PATH_CONSOLE;
+		#if TARGET_OS_EMBEDDED
+			bootstrapper->stderrpath = _PATH_CONSOLE;
+		#endif
 		}
 	}
 	

Modified: trunk/launchd/src/liblaunch.c
===================================================================
--- trunk/launchd/src/liblaunch.c	2008-12-11 21:49:26 UTC (rev 23761)
+++ trunk/launchd/src/liblaunch.c	2008-12-12 22:46:45 UTC (rev 23762)
@@ -217,31 +217,35 @@
 		if (where && where[0] != '\0') {
 			strncpy(sun.sun_path, where, sizeof(sun.sun_path));
 		} else {
-			if( (getenv("SUDO_COMMAND") || getenv("__USE_SYSTEM_LAUNCHD")) && geteuid() == 0 ) {
-				/* Talk to the system launchd. */
-				strncpy(sun.sun_path, LAUNCHD_SOCK_PREFIX "/sock", sizeof(sun.sun_path));
-			} else if( _vprocmgr_getsocket(spath) == 0 ) {
-				/* Talk to our per-user launchd. */
-				size_t min_len;
-				
-				min_len = sizeof(sun.sun_path) < sizeof(spath) ? sizeof(sun.sun_path) : sizeof(spath);
-				
-				strncpy(sun.sun_path, spath, min_len);
+			if( _vprocmgr_getsocket(spath) == 0 ) {
+				if( (getenv("SUDO_COMMAND") || getenv("__USE_SYSTEM_LAUNCHD")) && geteuid() == 0 ) {
+					/* Talk to the system launchd. */
+					strncpy(sun.sun_path, LAUNCHD_SOCK_PREFIX "/sock", sizeof(sun.sun_path));
+				} else {
+					/* Talk to our per-user launchd. */
+					size_t min_len;
+					
+					min_len = sizeof(sun.sun_path) < sizeof(spath) ? sizeof(sun.sun_path) : sizeof(spath);
+					
+					strncpy(sun.sun_path, spath, min_len);
+				}
 			}
 		}
-
+		
 		if ((lfd = _fd(socket(AF_UNIX, SOCK_STREAM, 0))) == -1) {
 			goto out_bad;
 		}
-			
 		if (-1 == connect(lfd, (struct sockaddr *)&sun, sizeof(sun))) {
 			goto out_bad;
 		}
 	}
-	if (!(_lc->l = launchd_fdopen(lfd)))
+	
+	if (!(_lc->l = launchd_fdopen(lfd))) {
 		goto out_bad;
-	if (!(_lc->async_resp = launch_data_alloc(LAUNCH_DATA_ARRAY)))
+	}
+	if (!(_lc->async_resp = launch_data_alloc(LAUNCH_DATA_ARRAY))) {
 		goto out_bad;
+	}
 
 	return;
 out_bad:

Modified: trunk/launchd.xcodeproj/project.pbxproj
===================================================================
--- trunk/launchd.xcodeproj/project.pbxproj	2008-12-11 21:49:26 UTC (rev 23761)
+++ trunk/launchd.xcodeproj/project.pbxproj	2008-12-12 22:46:45 UTC (rev 23762)
@@ -999,6 +999,7 @@
 				PREBINDING = NO;
 				PRODUCT_NAME = launchd;
 				STRIP_STYLE = debugging;
+				VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64";
 				ZERO_LINK = NO;
 			};
 			name = Release;
@@ -1025,6 +1026,7 @@
 				);
 				PRODUCT_NAME = launch;
 				PUBLIC_HEADERS_FOLDER_PATH = /usr/include;
+				VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64";
 				VERSIONING_SYSTEM = "apple-generic";
 				VERSION_INFO_PREFIX = __;
 			};
@@ -1042,6 +1044,7 @@
 				PREBINDING = NO;
 				PRODUCT_NAME = launchctl;
 				STRIP_STYLE = debugging;
+				VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64";
 				ZERO_LINK = NO;
 			};
 			name = Release;
@@ -1095,6 +1098,7 @@
 				PREBINDING = NO;
 				PRODUCT_NAME = launchproxy;
 				STRIP_STYLE = debugging;
+				VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64";
 				ZERO_LINK = NO;
 			};
 			name = Release;
@@ -1110,6 +1114,7 @@
 				PREBINDING = NO;
 				PRODUCT_NAME = wait4path;
 				STRIP_STYLE = debugging;
+				VALID_ARCHS = "armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64";
 				ZERO_LINK = NO;
 			};
 			name = Release;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20081212/bef2bd98/attachment.html>


More information about the launchd-changes mailing list