Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Aug 2005 16:34:46 GMT
From:      soc-tyler <soc-tyler@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 82499 for review
Message-ID:  <200508241634.j7OGYkWH051355@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82499

Change 82499 by soc-tyler@soc-tyler_launchd on 2005/08/24 16:34:27

	Set a definite, development-only LAUNCHD_PATH and LAUNCHCTL_PATH so that
	I can start launchd as a child of launchctl to ensure that they can 
	"talk" to each other via launch_msg()
	
	Add suggested fix for ADC Bug #4229882 which references launchd 
	idly dying despite launchctl still maintaining an open socket connection 
	to it (i.e. when the daemon is not running jobs)
	
	Oh, and add a few more fprintf()'s to make sure I know what I'm doing ;)

Affected files ...

.. //depot/projects/soc2005/launchd/includes/launch.h#10 edit
.. //depot/projects/soc2005/launchd/launchd.c#13 edit
.. //depot/projects/soc2005/launchd/liblaunch.c#11 edit

Differences ...

==== //depot/projects/soc2005/launchd/includes/launch.h#10 (text+ko) ====

@@ -53,14 +53,15 @@
 #include <stddef.h>
 #include <stdbool.h>
 
-/* XXX: if _LAUNCHD_ is defined, then I'm working with the source code, so the 
- *	the relevant launchctl(1) executable is in our current working dir. 
- */
 #ifdef _LAUNCHD_
-#define LAUNCHCTL_PATH "./launchctl/launchctl"
-#define LAUNCHD_PATH "./launchd"
-#else
+#define LAUNCHD_PATH "/home/tyler/perforce/launchd/launchd"
+#define LAUNCHCTL_PATH "/home/tyler/perforce/launchd/launchctl/launchctl"
+#endif
+
+#ifndef LAUNCHCTL_PATH
 #define LAUNCHCTL_PATH "/sbin/launchctl"
+#endif
+#ifndef LAUNCHD_PATH
 #define LAUNCHD_PATH "/sbin/launchd"
 #endif
 

==== //depot/projects/soc2005/launchd/launchd.c#13 (text+ko) ====

@@ -368,7 +368,7 @@
 			if (readcfg_pid == 0)
 				init_pre_kevent();
 		} else {
-			if (TAILQ_EMPTY(&jobs)) {
+			if (TAILQ_EMPTY(&jobs) && TAILQ_EMPTY(&connections)) {
 				/* launched on demand */
 				timeoutp = &timeout;
 			} else if (shutdown_in_progress && total_children == 0) {
@@ -525,6 +525,10 @@
 		snprintf(ourdir, sizeof(ourdir), "%s/%u.%u", LAUNCHD_SOCK_PREFIX, getuid(), getpid());
 		snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%u.%u/sock", LAUNCHD_SOCK_PREFIX, getuid(), getpid());
 		setenv(LAUNCHD_SOCKET_ENV, sun.sun_path, 1);
+#ifdef _LAUNCHD_
+		fprintf(stderr, "Setting the socket path to \"%s\"\n", sun.sun_path);
+#endif
+
 	} else {
 		snprintf(ourdir, sizeof(ourdir), "%s/%u", LAUNCHD_SOCK_PREFIX, getuid());
 		snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%u/sock", LAUNCHD_SOCK_PREFIX, getuid());

==== //depot/projects/soc2005/launchd/liblaunch.c#11 (text+ko) ====

@@ -125,6 +125,8 @@
 
 #ifdef _LAUNCHD_
 	fprintf(stderr,"starting launch_client_init() in liblaunch.c:%d\n", __LINE__);
+	fprintf(stderr,"where = \"%s\"\n", where);
+	fprintf(stderr,"_launchd_fd = \"%s\"\n", _launchd_fd);
 #endif
 	
 	_lc = calloc(1, sizeof(struct _launch_client));
@@ -178,7 +180,7 @@
 		for (tries = 0; tries < 10; tries++) {
 			r = connect(lfd, (struct sockaddr *)&sun, sizeof(sun));
 			if (r == -1) {
-				if (getuid() != 0 && fork() == 0)
+				if (fork() == 0)
 					execl(LAUNCHD_PATH, LAUNCHD_PATH, NULL);
 				sleep(1);
 			} else {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508241634.j7OGYkWH051355>