<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[23526] trunk/launchd/src/launchd_core_logic.c</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/launchd/changeset/23526">23526</a></dd>
<dt>Author</dt> <dd>zarzycki@apple.com</dd>
<dt>Date</dt> <dd>2008-03-03 16:46:00 -0800 (Mon, 03 Mar 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>Misc.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunklaunchdsrclaunchd_core_logicc">trunk/launchd/src/launchd_core_logic.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunklaunchdsrclaunchd_core_logicc"></a>
<div class="modfile"><h4>Modified: trunk/launchd/src/launchd_core_logic.c (23525 => 23526)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/launchd/src/launchd_core_logic.c        2008-02-26 21:39:33 UTC (rev 23525)
+++ trunk/launchd/src/launchd_core_logic.c        2008-03-04 00:46:00 UTC (rev 23526)
</span><span class="lines">@@ -6011,6 +6011,7 @@
</span><span class="cx">         struct machservice *ms;
</span><span class="cx">         struct ldcred *ldc = runtime_get_caller_creds();
</span><span class="cx">         kern_return_t kr;
</span><ins>+        bool per_pid_lookup = flags &amp; BOOTSTRAP_PER_PID_SERVICE;
</ins><span class="cx"> 
</span><span class="cx">         if (!launchd_assumes(j != NULL)) {
</span><span class="cx">                 return BOOTSTRAP_NO_MEMORY;
</span><span class="lines">@@ -6023,12 +6024,12 @@
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        if (unlikely(!mspolicy_check(j, servicename, flags &amp; BOOTSTRAP_PER_PID_SERVICE))) {
</del><ins>+        if (unlikely(!mspolicy_check(j, servicename, per_pid_lookup))) {
</ins><span class="cx">                 job_log(j, LOG_NOTICE, &quot;Policy denied Mach service lookup: %s&quot;, servicename);
</span><span class="cx">                 return BOOTSTRAP_NOT_PRIVILEGED;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (flags &amp; BOOTSTRAP_PER_PID_SERVICE) {
</del><ins>+        if (per_pid_lookup) {
</ins><span class="cx">                 ms = jobmgr_lookup_service(j-&gt;mgr, servicename, false, target_pid);
</span><span class="cx">         } else {
</span><span class="cx">                 ms = jobmgr_lookup_service(j-&gt;mgr, servicename, true, 0);
</span><span class="lines">@@ -6044,9 +6045,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (likely(ms)) {
</span><span class="cx">                 job_assumes(j, machservice_port(ms) != MACH_PORT_NULL);
</span><del>-                job_log(j, LOG_DEBUG, &quot;%sMach service lookup: %s&quot;, flags &amp; BOOTSTRAP_PER_PID_SERVICE ? &quot;Per PID &quot; : &quot;&quot;, servicename);
</del><ins>+                job_log(j, LOG_DEBUG, &quot;%sMach service lookup: %s&quot;, per_pid_lookup ? &quot;Per PID &quot; : &quot;&quot;, servicename);
</ins><span class="cx"> 
</span><del>-                if (unlikely(j-&gt;lastlookup == ms &amp;&amp; j-&gt;lastlookup_gennum == ms-&gt;gen_num &amp;&amp; !j-&gt;per_user)) {
</del><ins>+                if (unlikely(!per_pid_lookup &amp;&amp; j-&gt;lastlookup == ms &amp;&amp; j-&gt;lastlookup_gennum == ms-&gt;gen_num &amp;&amp; !j-&gt;per_user)) {
+                        /* we need to think more about the per_pid_lookup logic before logging about repeated lookups */
</ins><span class="cx">                         job_log(j, LOG_APPLEONLY, &quot;Performance: Please fix the framework that talks to \&quot;%s\&quot; to cache the Mach port for service: %s&quot;, ms-&gt;job-&gt;label, servicename);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -6056,7 +6058,7 @@
</span><span class="cx">                 *serviceportp = machservice_port(ms);
</span><span class="cx"> 
</span><span class="cx">                 kr = BOOTSTRAP_SUCCESS;
</span><del>-        } else if (!(flags &amp; BOOTSTRAP_PER_PID_SERVICE) &amp;&amp; (inherited_bootstrap_port != MACH_PORT_NULL)) {
</del><ins>+        } else if (!per_pid_lookup &amp;&amp; (inherited_bootstrap_port != MACH_PORT_NULL)) {
</ins><span class="cx">                 job_log(j, LOG_DEBUG, &quot;Mach service lookup forwarded: %s&quot;, servicename);
</span><span class="cx">                 job_assumes(j, vproc_mig_look_up2_forward(inherited_bootstrap_port, srp, servicename, 0, 0) == 0);
</span><span class="cx">                 /* The previous routine moved the reply port, we're forced to return MIG_NO_REPLY now */
</span><span class="lines">@@ -6070,7 +6072,7 @@
</span><span class="cx">                  */
</span><span class="cx">                 return VPROC_ERR_TRY_PER_USER;
</span><span class="cx">         } else {
</span><del>-                job_log(j, LOG_DEBUG, &quot;%sMach service lookup failed: %s&quot;, flags &amp; BOOTSTRAP_PER_PID_SERVICE ? &quot;Per PID &quot; : &quot;&quot;, servicename);
</del><ins>+                job_log(j, LOG_DEBUG, &quot;%sMach service lookup failed: %s&quot;, per_pid_lookup ? &quot;Per PID &quot; : &quot;&quot;, servicename);
</ins><span class="cx">                 kr = BOOTSTRAP_UNKNOWN_SERVICE;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>