Changeset 23463
- Timestamp:
- 12/12/07 12:32:53 (12 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 6 modified
-
Makefile.am (modified) (2 diffs)
-
Makefile.in (modified) (2 diffs)
-
launchd.c (modified) (4 diffs)
-
launchd_core_logic.c (modified) (10 diffs)
-
launchd_runtime.c (modified) (9 diffs)
-
launchd_runtime.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/Makefile.am
r23462 r23463 1 AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -W shadow -Wpadded-Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__1 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__ 2 2 3 3 CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ … … 47 47 SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c 48 48 49 launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter49 launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing 50 50 launchd_LDFLAGS = -lbsm 51 51 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 -
trunk/launchd/src/Makefile.in
r23462 r23463 239 239 top_builddir = @top_builddir@ 240 240 top_srcdir = @top_srcdir@ 241 AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -W shadow -Wpadded-Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__241 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__ 242 242 CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ 243 243 launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ … … 255 255 @LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit 256 256 @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c 257 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter257 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing 258 258 @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm 259 259 @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 mach_excServer.c -
trunk/launchd/src/launchd.c
r23408 r23463 177 177 178 178 void 179 fatal_signal_handler(int sig, siginfo_t *si, void *uap )179 fatal_signal_handler(int sig, siginfo_t *si, void *uap __attribute__((unused))) 180 180 { 181 181 const char *doom_why = "at instruction"; … … 246 246 launchd_shutdown(void) 247 247 { 248 struct timeval tvnow; 248 249 struct stat sb; 249 250 … … 264 265 } 265 266 267 if (launchd_assumes(gettimeofday(&tvnow, NULL) != -1)) { 268 runtime_syslog(LOG_NOTICE, "Shutdown began at: %lu.%06u", tvnow.tv_sec, tvnow.tv_usec); 269 } 270 271 launchd_log_vm_stats(); 272 266 273 launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL); 267 274 } … … 373 380 374 381 void 375 pfsystem_callback(void *obj , struct kevent *kev)382 pfsystem_callback(void *obj __attribute__((unused)), struct kevent *kev) 376 383 { 377 384 bool new_networking_state; -
trunk/launchd/src/launchd_core_logic.c
r23462 r23463 402 402 static void job_reparent_hack(job_t j, const char *where); 403 403 static void job_callback(void *obj, struct kevent *kev); 404 static void job_callback_proc(job_t j, int f lags, int fflags);404 static void job_callback_proc(job_t j, int fflags); 405 405 static void job_callback_timer(job_t j, void *ident); 406 406 static void job_callback_read(job_t j, int ident); … … 753 753 SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); 754 754 } else if (getpid() == 1) { 755 jobmgr_log(jm, LOG_DEBUG, "About to call: sync()"); 756 sync(); /* We're are going to rely on log timestamps to benchmark this call */ 757 launchd_log_vm_stats(); 755 758 jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); 756 759 runtime_closelog(); … … 1110 1113 1111 1114 if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) { 1112 u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT /* |NOTE_REAP */;1115 u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT|NOTE_REAP; 1113 1116 1114 1117 total_anon_children++; … … 2349 2352 2350 2353 void 2351 job_callback_proc(job_t j, int f lags, int fflags)2354 job_callback_proc(job_t j, int fflags) 2352 2355 { 2353 2356 bool program_changed = false; … … 2395 2398 } 2396 2399 2397 /* NOTE_REAP sanity checking is disabled for now while we try and diagnose 5289559 */2398 #if 02399 2400 if (j && (fflags & NOTE_REAP)) { 2400 job_assumes(j, flags & EV_ONESHOT);2401 job_assumes(j, flags & EV_EOF);2402 2403 2401 job_assumes(j, j->p == 0); 2404 2402 } 2405 #endif2406 2403 } 2407 2404 … … 2511 2508 switch (kev->filter) { 2512 2509 case EVFILT_PROC: 2513 return job_callback_proc(j, kev->f lags, kev->fflags);2510 return job_callback_proc(j, kev->fflags); 2514 2511 case EVFILT_TIMER: 2515 2512 return job_callback_timer(j, (void *)kev->ident); … … 2535 2532 pid_t c; 2536 2533 bool sipc = false; 2537 u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC /* NOTE_REAP */;2534 u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC|NOTE_REAP; 2538 2535 2539 2536 if (!job_assumes(j, j->mgr != NULL)) { … … 2688 2685 job_start_child(job_t j) 2689 2686 { 2687 typeof(posix_spawn) *psf; 2690 2688 const char *file2exec = "/usr/libexec/launchproxy"; 2691 2689 const char **argv; 2692 2690 posix_spawnattr_t spattr; 2693 2691 int gflags = GLOB_NOSORT|GLOB_NOCHECK|GLOB_TILDE|GLOB_DOOFFS; 2694 pid_t junk_pid;2695 2692 glob_t g; 2696 2693 short spflags = POSIX_SPAWN_SETEXEC; … … 2770 2767 } 2771 2768 2772 if (j->prog) { 2773 errno = posix_spawn(&junk_pid, j->inetcompat ? file2exec : j->prog, NULL, &spattr, (char *const*)argv, environ); 2774 job_log_error(j, LOG_ERR, "posix_spawn(\"%s\", ...)", j->prog); 2775 } else { 2776 errno = posix_spawnp(&junk_pid, j->inetcompat ? file2exec : argv[0], NULL, &spattr, (char *const*)argv, environ); 2777 job_log_error(j, LOG_ERR, "posix_spawnp(\"%s\", ...)", argv[0]); 2778 } 2769 psf = j->prog ? posix_spawn : posix_spawnp; 2770 2771 if (!j->inetcompat) { 2772 file2exec = j->prog ? j->prog : argv[0]; 2773 } 2774 2775 errno = psf(NULL, file2exec, NULL, &spattr, (char *const*)argv, environ); 2776 job_log_error(j, LOG_ERR, "posix_spawn(\"%s\", ...)", j->prog); 2779 2777 2780 2778 out_bad: … … 4235 4233 jobmgr_log(jm, LOG_DEBUG, "Garbage collecting."); 4236 4234 4237 /*4238 * Normally, we wait for all resources of a job (Unix PIDs/FDs and Mach ports)4239 * to reset before we conider the job truly dead and ready to be spawned again.4240 *4241 * In order to work around 5487724 and 3456090, we're going to call reboot()4242 * when the last PID dies and not wait for the associated resources to reset.4243 */4244 if (getpid() == 1 && jm->parentmgr == NULL && total_children == 0) {4245 jobmgr_log_stray_children(jm);4246 jobmgr_log(jm, LOG_DEBUG, "About to force a call to: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags));4247 runtime_closelog();4248 jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1);4249 }4250 4251 4235 if (jm->hopefully_first_cnt) { 4252 4236 return jm; -
trunk/launchd/src/launchd_runtime.c
r23453 r23463 870 870 871 871 kern_return_t 872 do_mach_notify_port_destroyed(mach_port_t notify , mach_port_t rights)872 do_mach_notify_port_destroyed(mach_port_t notify __attribute__((unused)), mach_port_t rights) 873 873 { 874 874 /* This message is sent to us when a receive right is returned to us. */ … … 882 882 883 883 kern_return_t 884 do_mach_notify_port_deleted(mach_port_t notify , mach_port_name_t name)884 do_mach_notify_port_deleted(mach_port_t notify __attribute__((unused)), mach_port_name_t name __attribute__((unused))) 885 885 { 886 886 /* If we deallocate/destroy/mod_ref away a port with a pending … … 893 893 894 894 kern_return_t 895 do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount )895 do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount __attribute__((unused))) 896 896 { 897 897 job_t j = job_mig_intran(notify); … … 911 911 912 912 kern_return_t 913 do_mach_notify_send_once(mach_port_t notify )913 do_mach_notify_send_once(mach_port_t notify __attribute__((unused))) 914 914 { 915 915 /* This message is sent to us every time we close a port that we have … … 922 922 923 923 kern_return_t 924 do_mach_notify_dead_name(mach_port_t notify , mach_port_name_t name)924 do_mach_notify_dead_name(mach_port_t notify __attribute__((unused)), mach_port_name_t name) 925 925 { 926 926 /* This message is sent to us when one of our send rights no longer has … … 1468 1468 1469 1469 kern_return_t 1470 catch_mach_exception_raise(mach_port_t exception_port , mach_port_t thread, mach_port_t task,1470 catch_mach_exception_raise(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task, 1471 1471 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) 1472 1472 { … … 1485 1485 1486 1486 kern_return_t 1487 catch_mach_exception_raise_state(mach_port_t exception_port ,1487 catch_mach_exception_raise_state(mach_port_t exception_port __attribute__((unused)), 1488 1488 exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1489 1489 int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, … … 1500 1500 1501 1501 kern_return_t 1502 catch_mach_exception_raise_state_identity(mach_port_t exception_port , mach_port_t thread, mach_port_t task,1502 catch_mach_exception_raise_state_identity(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task, 1503 1503 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1504 1504 int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, … … 1520 1520 return 0; 1521 1521 } 1522 1523 void 1524 launchd_log_vm_stats(void) 1525 { 1526 static struct vm_statistics orig_stats; 1527 static bool did_first_pass; 1528 unsigned int count = HOST_VM_INFO_COUNT; 1529 struct vm_statistics stats, *statsp; 1530 mach_port_t mhs = mach_host_self(); 1531 1532 statsp = did_first_pass ? &stats : &orig_stats; 1533 1534 if (!launchd_assumes(host_statistics(mhs, HOST_VM_INFO, (host_info_t)statsp, &count) == KERN_SUCCESS)) { 1535 return; 1536 } 1537 1538 launchd_assumes(count == HOST_VM_INFO_COUNT); 1539 1540 if (did_first_pass) { 1541 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", 1542 stats.free_count - orig_stats.free_count, 1543 stats.active_count - orig_stats.active_count, 1544 stats.inactive_count - orig_stats.inactive_count, 1545 stats.reactivations - orig_stats.reactivations, 1546 stats.pageins - orig_stats.pageins, 1547 stats.pageouts - orig_stats.pageouts, 1548 stats.faults - orig_stats.faults, 1549 stats.cow_faults - orig_stats.cow_faults, 1550 stats.purgeable_count - orig_stats.purgeable_count, 1551 stats.purges - orig_stats.purges); 1552 } else { 1553 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", 1554 orig_stats.free_count, 1555 orig_stats.active_count, 1556 orig_stats.inactive_count, 1557 orig_stats.reactivations, 1558 orig_stats.pageins, 1559 orig_stats.pageouts, 1560 orig_stats.faults, 1561 orig_stats.cow_faults, 1562 orig_stats.purgeable_count, 1563 orig_stats.purges); 1564 1565 did_first_pass = true; 1566 } 1567 1568 launchd_mport_deallocate(mhs); 1569 } -
trunk/launchd/src/launchd_runtime.h
r23445 r23463 108 108 void launchd_runtime(void) __attribute__((noreturn)); 109 109 110 void launchd_log_vm_stats(void); 111 110 112 int runtime_close(int fd); 111 113 int runtime_fsync(int fd);

