[launchd-changes] [23443] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Tue Oct 23 08:40:55 PDT 2007
Revision: 23443
http://trac.macosforge.org/projects/launchd/changeset/23443
Author: zarzycki at apple.com
Date: 2007-10-23 08:40:55 -0700 (Tue, 23 Oct 2007)
Log Message:
-----------
Short circuit MIG replies when forwarding queries.
Modified Paths:
--------------
trunk/launchd/src/Makefile.am
trunk/launchd/src/Makefile.in
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/protocol_job.defs
Added Paths:
-----------
trunk/launchd/src/protocol_job_forward.defs
Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am 2007-10-23 15:29:03 UTC (rev 23442)
+++ trunk/launchd/src/Makefile.am 2007-10-23 15:40:55 UTC (rev 23443)
@@ -48,13 +48,16 @@
launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
launchd_LDFLAGS = -lbsm
-launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
+launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c
launchd_runtime.c:: notifyServer.h launchd_internal.h
-launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
+launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h
launchproxy_LDFLAGS = -weak_framework Security
+job_forwardUser.c job_forward.h: $(srcdir)/protocol_job_forward.defs
+ mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_forward.defs
+
notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in 2007-10-23 15:29:03 UTC (rev 23442)
+++ trunk/launchd/src/Makefile.in 2007-10-23 15:40:55 UTC (rev 23443)
@@ -96,7 +96,8 @@
am__launchd_SOURCES_DIST = launchd.c launchd_core_logic.c \
launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c \
launchd_internalUser.c launchd_internalServer.c \
- job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
+ job_replyUser.c launchd_runtime.c launchd_runtime_kill.c \
+ job_forwardUser.c
@LIBS_ONLY_FALSE at am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \
@LIBS_ONLY_FALSE@ launchd-launchd_core_logic.$(OBJEXT) \
@LIBS_ONLY_FALSE@ launchd-launchd_unix_ipc.$(OBJEXT) \
@@ -106,7 +107,8 @@
@LIBS_ONLY_FALSE@ launchd-launchd_internalServer.$(OBJEXT) \
@LIBS_ONLY_FALSE@ launchd-job_replyUser.$(OBJEXT) \
@LIBS_ONLY_FALSE@ launchd-launchd_runtime.$(OBJEXT) \
- at LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT)
+ at LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT) \
+ at LIBS_ONLY_FALSE@ launchd-job_forwardUser.$(OBJEXT)
launchd_OBJECTS = $(am_launchd_OBJECTS)
launchd_LDADD = $(LDADD)
launchd_LINK = $(CCLD) $(launchd_CFLAGS) $(CFLAGS) $(launchd_LDFLAGS) \
@@ -253,7 +255,7 @@
@LIBS_ONLY_FALSE at SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
@LIBS_ONLY_FALSE at launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
@LIBS_ONLY_FALSE at launchd_LDFLAGS = -lbsm
- at LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
+ at LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c
@LIBS_ONLY_FALSE at launchproxy_LDFLAGS = -weak_framework Security
@LIBS_ONLY_FALSE at man1_MANS = wait4path.1 launchctl.1
@LIBS_ONLY_FALSE at man5_MANS = launchd.plist.5 launchd.conf.5
@@ -415,6 +417,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SystemStarter-StartupItems.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SystemStarter-SystemStarter.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/launchctl-launchctl.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/launchd-job_forwardUser.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/launchd-job_replyUser.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/launchd-launchd.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/launchd-launchd_core_logic.Po at am__quote@
@@ -787,6 +790,20 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='launchd_runtime_kill.c' object='launchd-launchd_runtime_kill.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime_kill.obj `if test -f 'launchd_runtime_kill.c'; then $(CYGPATH_W) 'launchd_runtime_kill.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime_kill.c'; fi`
+
+launchd-job_forwardUser.o: job_forwardUser.c
+ at am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-job_forwardUser.o -MD -MP -MF $(DEPDIR)/launchd-job_forwardUser.Tpo -c -o launchd-job_forwardUser.o `test -f 'job_forwardUser.c' || echo '$(srcdir)/'`job_forwardUser.c
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-job_forwardUser.Tpo $(DEPDIR)/launchd-job_forwardUser.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='job_forwardUser.c' object='launchd-job_forwardUser.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-job_forwardUser.o `test -f 'job_forwardUser.c' || echo '$(srcdir)/'`job_forwardUser.c
+
+launchd-job_forwardUser.obj: job_forwardUser.c
+ at am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-job_forwardUser.obj -MD -MP -MF $(DEPDIR)/launchd-job_forwardUser.Tpo -c -o launchd-job_forwardUser.obj `if test -f 'job_forwardUser.c'; then $(CYGPATH_W) 'job_forwardUser.c'; else $(CYGPATH_W) '$(srcdir)/job_forwardUser.c'; fi`
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-job_forwardUser.Tpo $(DEPDIR)/launchd-job_forwardUser.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='job_forwardUser.c' object='launchd-job_forwardUser.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-job_forwardUser.obj `if test -f 'job_forwardUser.c'; then $(CYGPATH_W) 'job_forwardUser.c'; else $(CYGPATH_W) '$(srcdir)/job_forwardUser.c'; fi`
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
@@ -1149,8 +1166,11 @@
@LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a
@LIBS_ONLY_FALSE at launchd_runtime.c:: notifyServer.h launchd_internal.h
- at LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
+ at LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h
+ at LIBS_ONLY_FALSE@job_forwardUser.c job_forward.h: $(srcdir)/protocol_job_forward.defs
+ at LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_forward.defs
+
@LIBS_ONLY_FALSE at notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
@LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2007-10-23 15:29:03 UTC (rev 23442)
+++ trunk/launchd/src/launchd_core_logic.c 2007-10-23 15:40:55 UTC (rev 23443)
@@ -91,6 +91,7 @@
#include "protocol_vproc.h"
#include "protocol_vprocServer.h"
#include "job_reply.h"
+#include "job_forward.h"
#define LAUNCHD_MIN_JOB_RUN_TIME 10
#define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20
@@ -5741,7 +5742,7 @@
}
kern_return_t
-job_mig_look_up2(job_t j, name_t servicename, mach_port_t *serviceportp, mach_msg_type_name_t *ptype, pid_t target_pid, uint64_t flags)
+job_mig_look_up2(job_t j, mach_port_t srp, name_t servicename, mach_port_t *serviceportp, pid_t target_pid, uint64_t flags)
{
struct machservice *ms;
struct ldcred ldc;
@@ -5788,12 +5789,12 @@
j->lastlookup_gennum = ms->gen_num;
#endif
*serviceportp = machservice_port(ms);
- *ptype = MACH_MSG_TYPE_COPY_SEND;
kr = BOOTSTRAP_SUCCESS;
} else if (!(flags & BOOTSTRAP_PER_PID_SERVICE) && (inherited_bootstrap_port != MACH_PORT_NULL)) {
job_log(j, LOG_DEBUG, "Mach service lookup forwarded: %s", servicename);
- *ptype = MACH_MSG_TYPE_MOVE_SEND;
- kr = bootstrap_look_up(inherited_bootstrap_port, servicename, serviceportp);
+ job_assumes(j, vproc_mig_look_up2_forward(inherited_bootstrap_port, srp, servicename, 0, 0) == 0);
+ /* The previous routine moved the reply port, we're forced to return MIG_NO_REPLY now */
+ return MIG_NO_REPLY;
} else if (getpid() == 1 && j->anonymous && ldc.euid >= 500 && strcasecmp(job_get_bs(j)->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) {
/*
* 5240036 Should start background session when a lookup of CCacheServer occurs
@@ -5811,7 +5812,7 @@
}
kern_return_t
-job_mig_parent(job_t j, mach_port_t *parentport, mach_msg_type_name_t *pptype)
+job_mig_parent(job_t j, mach_port_t srp, mach_port_t *parentport)
{
if (!launchd_assumes(j != NULL)) {
return BOOTSTRAP_NO_MEMORY;
@@ -5820,15 +5821,14 @@
job_log(j, LOG_DEBUG, "Requested parent bootstrap port");
jobmgr_t jm = j->mgr;
- *pptype = MACH_MSG_TYPE_MAKE_SEND;
-
if (jobmgr_parent(jm)) {
*parentport = jobmgr_parent(jm)->jm_port;
} else if (MACH_PORT_NULL == inherited_bootstrap_port) {
*parentport = jm->jm_port;
} else {
- *pptype = MACH_MSG_TYPE_COPY_SEND;
- *parentport = inherited_bootstrap_port;
+ job_assumes(j, vproc_mig_parent_forward(inherited_bootstrap_port, srp) == 0);
+ /* The previous routine moved the reply port, we're forced to return MIG_NO_REPLY now */
+ return MIG_NO_REPLY;
}
return BOOTSTRAP_SUCCESS;
}
Modified: trunk/launchd/src/protocol_job.defs
===================================================================
--- trunk/launchd/src/protocol_job.defs 2007-10-23 15:29:03 UTC (rev 23442)
+++ trunk/launchd/src/protocol_job.defs 2007-10-23 15:40:55 UTC (rev 23443)
@@ -63,8 +63,9 @@
routine look_up2(
__bs_port : job_t;
+ sreplyport __rport : mach_port_make_send_once_t;
__service_name : name_t;
- out __service_port : mach_port_send_t;
+ out __service_port : mach_port_t;
__target_pid : pid_t;
__flags : uint64_t);
@@ -76,7 +77,8 @@
routine parent(
__bs_port : job_t;
- out __parent_port : mach_port_send_t);
+ sreplyport __rport : mach_port_make_send_once_t;
+ out __parent_port : mach_port_make_send_t);
routine post_fork_ping(
__bs_port : job_t;
Added: trunk/launchd/src/protocol_job_forward.defs
===================================================================
--- trunk/launchd/src/protocol_job_forward.defs (rev 0)
+++ trunk/launchd/src/protocol_job_forward.defs 2007-10-23 15:40:55 UTC (rev 23443)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+subsystem job_forward 400;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include "launchd_mig_types.defs"
+import "libvproc_public.h";
+import "libvproc_private.h";
+import "libvproc_internal.h";
+
+userprefix vproc_mig_;
+serverprefix job_mig_;
+
+skip; /* create_server */
+
+skip; /* reboot2 */
+
+skip; /* check_in */
+
+skip; /* register2 */
+
+simpleroutine look_up2_forward(
+ __bs_port : job_t;
+ replyport __rport : mach_port_move_send_once_t;
+ __service_name : name_t;
+ __target_pid : pid_t;
+ __flags : uint64_t);
+
+skip; /* send_signal */
+
+simpleroutine parent_forward(
+ __bs_port : job_t;
+ replyport __rport : mach_port_move_send_once_t);
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20071023/4c2c5881/attachment-0001.html
More information about the launchd-changes
mailing list