[launchd-changes] [23180] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 23 13:32:09 PDT 2007
Revision: 23180
http://trac.macosforge.org/projects/launchd/changeset/23180
Author: zarzycki at apple.com
Date: 2007-03-23 13:32:08 -0700 (Fri, 23 Mar 2007)
Log Message:
-----------
Cache two unchanging values that CF calls a lot.
Modified Paths:
--------------
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/libvproc.c
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2007-03-23 01:42:15 UTC (rev 23179)
+++ trunk/launchd/src/launchd_core_logic.c 2007-03-23 20:32:08 UTC (rev 23180)
@@ -4270,12 +4270,27 @@
kern_return_t
job_mig_swap_integer(job_t j, vproc_gsk_t inkey, vproc_gsk_t outkey, int64_t inval, int64_t *outval)
{
+ const char *action;
kern_return_t kr = 0;
if (!launchd_assumes(j != NULL)) {
return BOOTSTRAP_NO_MEMORY;
}
+ if (inkey && outkey && !job_assumes(j, inkey == outkey)) {
+ return 1;
+ }
+
+ if (inkey && outkey) {
+ action = "Swapping";
+ } else if (inkey) {
+ action = "Setting";
+ } else {
+ action = "Getting";
+ }
+
+ job_log(j, LOG_DEBUG, "%s key: %u", action, inkey ? inkey : outkey);
+
switch (outkey) {
case VPROC_GSK_LAST_EXIT_STATUS:
*outval = j->last_exit_status;
@@ -4287,7 +4302,7 @@
*outval = getpid();
break;
case VPROC_GSK_IS_MANAGED:
- *outval = !j->anonymous;
+ *outval = j->anonymous ? 0 : 1;
break;
case VPROC_GSK_BASIC_KEEPALIVE:
*outval = !j->ondemand;
Modified: trunk/launchd/src/libvproc.c
===================================================================
--- trunk/launchd/src/libvproc.c 2007-03-23 01:42:15 UTC (rev 23179)
+++ trunk/launchd/src/libvproc.c 2007-03-23 20:32:08 UTC (rev 23180)
@@ -213,9 +213,38 @@
vproc_err_t
vproc_swap_integer(vproc_t vp __attribute__((unused)), vproc_gsk_t key, int64_t *inval, int64_t *outval)
{
+ static int64_t cached_pid = -1;
+ static int64_t cached_is_managed = -1;
int64_t dummyval = 0;
+ switch (key) {
+ case VPROC_GSK_MGR_PID:
+ if (cached_pid != -1 && outval) {
+ *outval = cached_pid;
+ return NULL;
+ }
+ break;
+ case VPROC_GSK_IS_MANAGED:
+ if (cached_is_managed != -1 && outval) {
+ *outval = cached_is_managed;
+ return NULL;
+ }
+ break;
+ default:
+ break;
+ }
+
if (vproc_mig_swap_integer(bootstrap_port, inval ? key : 0, outval ? key : 0, inval ? *inval : 0, outval ? outval : &dummyval) == 0) {
+ switch (key) {
+ case VPROC_GSK_MGR_PID:
+ cached_pid = outval ? *outval : dummyval;
+ break;
+ case VPROC_GSK_IS_MANAGED:
+ cached_is_managed = outval ? *outval : dummyval;
+ break;
+ default:
+ break;
+ }
return NULL;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070323/a9d22a00/attachment.html
More information about the launchd-changes
mailing list