[launchd-changes] [23810] branches/PR-6589133/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 16 23:53:06 PST 2009


Revision: 23810
          http://trac.macosforge.org/projects/launchd/changeset/23810
Author:   dsorresso at apple.com
Date:     2009-02-16 23:53:04 -0800 (Mon, 16 Feb 2009)
Log Message:
-----------
<rdar://problem/6589133> 10A274: hundreds of failing (ENOENT) opens of /dev/autofs_nowait in launchd at boot

Modified Paths:
--------------
    branches/PR-6589133/launchd/src/launchd_core_logic.c
    branches/PR-6589133/launchd/src/launchd_runtime.c

Modified: branches/PR-6589133/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6589133/launchd/src/launchd_core_logic.c	2009-02-17 05:33:11 UTC (rev 23809)
+++ branches/PR-6589133/launchd/src/launchd_core_logic.c	2009-02-17 07:53:04 UTC (rev 23810)
@@ -635,6 +635,7 @@
 #define JOB_BOOTCACHE_HACK_CHECK(j)	(unlikely(j->per_user && !did_first_per_user_launchd_BootCache_hack && (j->mach_uid >= 500) && (j->mach_uid != (uid_t)-2)))
 static job_t workaround_5477111;
 static pid_t s_update_pid = 0;
+static int s_no_hang_fd = -1;
 
 /* process wide globals */
 mach_port_t inherited_bootstrap_port;
@@ -3362,6 +3363,17 @@
 			jobmgr_still_alive_with_check(jm);
 		}
 		break;
+	case EVFILT_VNODE:
+		if( kev->ident == (uintptr_t)s_no_hang_fd ) {
+			int _no_hang_fd = open("/dev/autofs_nowait", O_EVTONLY | O_NONBLOCK);
+			if( unlikely(_no_hang_fd != -1) ) {
+				jobmgr_log(root_jobmgr, LOG_DEBUG, "/dev/autofs_nowait has appeared!");
+				jobmgr_assumes(root_jobmgr, kevent_mod((uintptr_t)s_no_hang_fd, EVFILT_VNODE, EV_DELETE, 0, 0, NULL) != -1);
+				jobmgr_assumes(root_jobmgr, runtime_close(s_no_hang_fd) != -1);
+				s_no_hang_fd = _fd(_no_hang_fd);
+			}
+		}
+		break;
 	default:
 		return (void)jobmgr_assumes(jm, false);
 	}
@@ -8466,6 +8478,15 @@
 	SLIST_INIT(&s_curious_jobs);
 	
 	launchd_assert((root_jobmgr = jobmgr_new(NULL, MACH_PORT_NULL, MACH_PORT_NULL, sflag, root_session_type)) != NULL);
+	
+	uint32_t fflags = NOTE_ATTRIB | NOTE_LINK | NOTE_REVOKE | NOTE_EXTEND | NOTE_WRITE;
+	s_no_hang_fd = open("/dev/autofs_nowait", O_EVTONLY | O_NONBLOCK);
+	if( likely(s_no_hang_fd == -1) ) {
+		if( jobmgr_assumes(root_jobmgr, (s_no_hang_fd = open("/dev", O_EVTONLY | O_NONBLOCK)) != -1) ) {
+			jobmgr_assumes(root_jobmgr, kevent_mod((uintptr_t)s_no_hang_fd, EVFILT_VNODE, EV_ADD, fflags, 0, root_jobmgr) != -1);
+		}
+	}
+	s_no_hang_fd = _fd(s_no_hang_fd);
 }
 
 size_t

Modified: branches/PR-6589133/launchd/src/launchd_runtime.c
===================================================================
--- branches/PR-6589133/launchd/src/launchd_runtime.c	2009-02-17 05:33:11 UTC (rev 23809)
+++ branches/PR-6589133/launchd/src/launchd_runtime.c	2009-02-17 07:53:04 UTC (rev 23810)
@@ -1142,16 +1142,6 @@
 #endif
 
 		record_caller_creds(&bufRequest->Head);
-
-		/*
-		 * This is a total hack. We really need a bit in the kernel's proc
-		 * struct to declare our intent.
-		 */
-		static int no_hang_fd = -1;
-		if (unlikely(no_hang_fd == -1)) {
-			no_hang_fd = _fd(open("/dev/autofs_nowait", 0));
-		}
-
 		runtime_ktrace(RTKT_LAUNCHD_MACH_IPC|DBG_FUNC_START, bufRequest->Head.msgh_local_port, bufRequest->Head.msgh_id, (long)the_demux);
 
 		if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090216/d0076b4c/attachment.html>


More information about the launchd-changes mailing list