[launchd-changes] [23463] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 12 12:32:55 PST 2007
Revision: 23463
http://trac.macosforge.org/projects/launchd/changeset/23463
Author: zarzycki at apple.com
Date: 2007-12-12 12:32:53 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
Misc updates.
Modified Paths:
--------------
trunk/launchd/src/Makefile.am
trunk/launchd/src/Makefile.in
trunk/launchd/src/launchd.c
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/launchd_runtime.c
trunk/launchd/src/launchd_runtime.h
Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/Makefile.am 2007-12-12 20:32:53 UTC (rev 23463)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wpadded -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
+AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
@@ -46,7 +46,7 @@
SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit
SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
-launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
+launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
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 job_forwardUser.c mach_excServer.c
Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/Makefile.in 2007-12-12 20:32:53 UTC (rev 23463)
@@ -238,7 +238,7 @@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wpadded -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
+AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h
@@ -254,7 +254,7 @@
@LIBS_ONLY_FALSE at SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS)
@LIBS_ONLY_FALSE at SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit
@LIBS_ONLY_FALSE at SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
- at LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
+ at LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
@LIBS_ONLY_FALSE at launchd_LDFLAGS = -lbsm
@LIBS_ONLY_FALSE at 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 mach_excServer.c
@LIBS_ONLY_FALSE at launchproxy_LDFLAGS = -weak_framework Security
Modified: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/launchd.c 2007-12-12 20:32:53 UTC (rev 23463)
@@ -176,7 +176,7 @@
static __attribute__((unused)) typeof(reboot) *__junk_dyld_trick3 = reboot;
void
-fatal_signal_handler(int sig, siginfo_t *si, void *uap)
+fatal_signal_handler(int sig, siginfo_t *si, void *uap __attribute__((unused)))
{
const char *doom_why = "at instruction";
char *sample_args[] = { "/usr/bin/sample", "1", "1", "-file", PID1_CRASH_LOGFILE, NULL };
@@ -245,6 +245,7 @@
void
launchd_shutdown(void)
{
+ struct timeval tvnow;
struct stat sb;
if (shutdown_in_progress) {
@@ -263,6 +264,12 @@
debug_shutdown_hangs = true;
}
+ if (launchd_assumes(gettimeofday(&tvnow, NULL) != -1)) {
+ runtime_syslog(LOG_NOTICE, "Shutdown began at: %lu.%06u", tvnow.tv_sec, tvnow.tv_usec);
+ }
+
+ launchd_log_vm_stats();
+
launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL);
}
@@ -372,7 +379,7 @@
}
void
-pfsystem_callback(void *obj, struct kevent *kev)
+pfsystem_callback(void *obj __attribute__((unused)), struct kevent *kev)
{
bool new_networking_state;
char buf[1024];
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/launchd_core_logic.c 2007-12-12 20:32:53 UTC (rev 23463)
@@ -401,7 +401,7 @@
static void job_setup_exception_port(job_t j, task_t target_task);
static void job_reparent_hack(job_t j, const char *where);
static void job_callback(void *obj, struct kevent *kev);
-static void job_callback_proc(job_t j, int flags, int fflags);
+static void job_callback_proc(job_t j, int fflags);
static void job_callback_timer(job_t j, void *ident);
static void job_callback_read(job_t j, int ident);
static void job_log_stray_pg(job_t j);
@@ -752,6 +752,9 @@
runtime_del_ref();
SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle);
} else if (getpid() == 1) {
+ jobmgr_log(jm, LOG_DEBUG, "About to call: sync()");
+ sync(); /* We're are going to rely on log timestamps to benchmark this call */
+ launchd_log_vm_stats();
jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags));
runtime_closelog();
jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1);
@@ -1109,7 +1112,7 @@
}
if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) {
- u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT /* |NOTE_REAP */;
+ u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT|NOTE_REAP;
total_anon_children++;
jr->anonymous = true;
@@ -2348,7 +2351,7 @@
}
void
-job_callback_proc(job_t j, int flags, int fflags)
+job_callback_proc(job_t j, int fflags)
{
bool program_changed = false;
@@ -2394,15 +2397,9 @@
}
}
- /* NOTE_REAP sanity checking is disabled for now while we try and diagnose 5289559 */
-#if 0
if (j && (fflags & NOTE_REAP)) {
- job_assumes(j, flags & EV_ONESHOT);
- job_assumes(j, flags & EV_EOF);
-
job_assumes(j, j->p == 0);
}
-#endif
}
void
@@ -2510,7 +2507,7 @@
switch (kev->filter) {
case EVFILT_PROC:
- return job_callback_proc(j, kev->flags, kev->fflags);
+ return job_callback_proc(j, kev->fflags);
case EVFILT_TIMER:
return job_callback_timer(j, (void *)kev->ident);
case EVFILT_VNODE:
@@ -2534,7 +2531,7 @@
char nbuf[64];
pid_t c;
bool sipc = false;
- u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC /* NOTE_REAP */;
+ u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC|NOTE_REAP;
if (!job_assumes(j, j->mgr != NULL)) {
return;
@@ -2687,11 +2684,11 @@
void
job_start_child(job_t j)
{
+ typeof(posix_spawn) *psf;
const char *file2exec = "/usr/libexec/launchproxy";
const char **argv;
posix_spawnattr_t spattr;
int gflags = GLOB_NOSORT|GLOB_NOCHECK|GLOB_TILDE|GLOB_DOOFFS;
- pid_t junk_pid;
glob_t g;
short spflags = POSIX_SPAWN_SETEXEC;
size_t binpref_out_cnt = 0;
@@ -2769,14 +2766,15 @@
}
}
- if (j->prog) {
- errno = posix_spawn(&junk_pid, j->inetcompat ? file2exec : j->prog, NULL, &spattr, (char *const*)argv, environ);
- job_log_error(j, LOG_ERR, "posix_spawn(\"%s\", ...)", j->prog);
- } else {
- errno = posix_spawnp(&junk_pid, j->inetcompat ? file2exec : argv[0], NULL, &spattr, (char *const*)argv, environ);
- job_log_error(j, LOG_ERR, "posix_spawnp(\"%s\", ...)", argv[0]);
+ psf = j->prog ? posix_spawn : posix_spawnp;
+
+ if (!j->inetcompat) {
+ file2exec = j->prog ? j->prog : argv[0];
}
+ errno = psf(NULL, file2exec, NULL, &spattr, (char *const*)argv, environ);
+ job_log_error(j, LOG_ERR, "posix_spawn(\"%s\", ...)", j->prog);
+
out_bad:
_exit(EXIT_FAILURE);
}
@@ -4234,20 +4232,6 @@
jobmgr_log(jm, LOG_DEBUG, "Garbage collecting.");
- /*
- * Normally, we wait for all resources of a job (Unix PIDs/FDs and Mach ports)
- * to reset before we conider the job truly dead and ready to be spawned again.
- *
- * In order to work around 5487724 and 3456090, we're going to call reboot()
- * when the last PID dies and not wait for the associated resources to reset.
- */
- if (getpid() == 1 && jm->parentmgr == NULL && total_children == 0) {
- jobmgr_log_stray_children(jm);
- jobmgr_log(jm, LOG_DEBUG, "About to force a call to: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags));
- runtime_closelog();
- jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1);
- }
-
if (jm->hopefully_first_cnt) {
return jm;
}
Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/launchd_runtime.c 2007-12-12 20:32:53 UTC (rev 23463)
@@ -869,7 +869,7 @@
}
kern_return_t
-do_mach_notify_port_destroyed(mach_port_t notify, mach_port_t rights)
+do_mach_notify_port_destroyed(mach_port_t notify __attribute__((unused)), mach_port_t rights)
{
/* This message is sent to us when a receive right is returned to us. */
@@ -881,7 +881,7 @@
}
kern_return_t
-do_mach_notify_port_deleted(mach_port_t notify, mach_port_name_t name)
+do_mach_notify_port_deleted(mach_port_t notify __attribute__((unused)), mach_port_name_t name __attribute__((unused)))
{
/* If we deallocate/destroy/mod_ref away a port with a pending
* notification, the original notification message is replaced with
@@ -892,7 +892,7 @@
}
kern_return_t
-do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount)
+do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount __attribute__((unused)))
{
job_t j = job_mig_intran(notify);
@@ -910,7 +910,7 @@
}
kern_return_t
-do_mach_notify_send_once(mach_port_t notify)
+do_mach_notify_send_once(mach_port_t notify __attribute__((unused)))
{
/* This message is sent to us every time we close a port that we have
* outstanding Mach notification requests on. We can safely ignore this
@@ -921,7 +921,7 @@
}
kern_return_t
-do_mach_notify_dead_name(mach_port_t notify, mach_port_name_t name)
+do_mach_notify_dead_name(mach_port_t notify __attribute__((unused)), mach_port_name_t name)
{
/* This message is sent to us when one of our send rights no longer has
* a receiver somewhere else on the system.
@@ -1467,7 +1467,7 @@
}
kern_return_t
-catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task,
+catch_mach_exception_raise(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task,
exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt)
{
pid_t p4t = -1;
@@ -1484,7 +1484,7 @@
}
kern_return_t
-catch_mach_exception_raise_state(mach_port_t exception_port,
+catch_mach_exception_raise_state(mach_port_t exception_port __attribute__((unused)),
exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt,
int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt,
thread_state_t new_state, mach_msg_type_number_t *new_stateCnt)
@@ -1499,7 +1499,7 @@
}
kern_return_t
-catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task,
+catch_mach_exception_raise_state_identity(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task,
exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt,
int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt,
thread_state_t new_state, mach_msg_type_number_t *new_stateCnt)
@@ -1519,3 +1519,51 @@
return 0;
}
+
+void
+launchd_log_vm_stats(void)
+{
+ static struct vm_statistics orig_stats;
+ static bool did_first_pass;
+ unsigned int count = HOST_VM_INFO_COUNT;
+ struct vm_statistics stats, *statsp;
+ mach_port_t mhs = mach_host_self();
+
+ statsp = did_first_pass ? &stats : &orig_stats;
+
+ if (!launchd_assumes(host_statistics(mhs, HOST_VM_INFO, (host_info_t)statsp, &count) == KERN_SUCCESS)) {
+ return;
+ }
+
+ launchd_assumes(count == HOST_VM_INFO_COUNT);
+
+ if (did_first_pass) {
+ runtime_syslog(LOG_DEBUG, "VM statistics (now - orig): Free: %d Active: %d Inactive: %d Reactivations: %d PageIns: %d PageOuts: %d Faults: %d COW-Faults: %d Purgeable: %d Purges: %d",
+ stats.free_count - orig_stats.free_count,
+ stats.active_count - orig_stats.active_count,
+ stats.inactive_count - orig_stats.inactive_count,
+ stats.reactivations - orig_stats.reactivations,
+ stats.pageins - orig_stats.pageins,
+ stats.pageouts - orig_stats.pageouts,
+ stats.faults - orig_stats.faults,
+ stats.cow_faults - orig_stats.cow_faults,
+ stats.purgeable_count - orig_stats.purgeable_count,
+ stats.purges - orig_stats.purges);
+ } else {
+ runtime_syslog(LOG_DEBUG, "VM statistics (now): Free: %d Active: %d Inactive: %d Reactivations: %d PageIns: %d PageOuts: %d Faults: %d COW-Faults: %d Purgeable: %d Purges: %d",
+ orig_stats.free_count,
+ orig_stats.active_count,
+ orig_stats.inactive_count,
+ orig_stats.reactivations,
+ orig_stats.pageins,
+ orig_stats.pageouts,
+ orig_stats.faults,
+ orig_stats.cow_faults,
+ orig_stats.purgeable_count,
+ orig_stats.purges);
+
+ did_first_pass = true;
+ }
+
+ launchd_mport_deallocate(mhs);
+}
Modified: trunk/launchd/src/launchd_runtime.h
===================================================================
--- trunk/launchd/src/launchd_runtime.h 2007-12-08 00:02:39 UTC (rev 23462)
+++ trunk/launchd/src/launchd_runtime.h 2007-12-12 20:32:53 UTC (rev 23463)
@@ -107,6 +107,8 @@
void launchd_runtime_init2(void);
void launchd_runtime(void) __attribute__((noreturn));
+void launchd_log_vm_stats(void);
+
int runtime_close(int fd);
int runtime_fsync(int fd);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20071212/af7bd911/attachment-0001.html
More information about the launchd-changes
mailing list