Projects
Browse Source     Search     Timeline     Wiki

Changeset 23463

Show
Ignore:
Timestamp:
12/12/07 12:32:53 (12 months ago)
Author:
zarzycki@…
Message:

Misc updates.

Location:
trunk/launchd/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/Makefile.am

    r23462 r23463  
    1 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__ 
     1AM_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__ 
    22 
    33CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h                \ 
     
    4747SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c 
    4848 
    49 launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter 
     49launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing 
    5050launchd_LDFLAGS = -lbsm 
    5151launchd_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  
    239239top_builddir = @top_builddir@ 
    240240top_srcdir = @top_srcdir@ 
    241 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__ 
     241AM_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__ 
    242242CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h                \ 
    243243             launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c        \ 
     
    255255@LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit 
    256256@LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c 
    257 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter 
     257@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing 
    258258@LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm 
    259259@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  
    177177 
    178178void 
    179 fatal_signal_handler(int sig, siginfo_t *si, void *uap) 
     179fatal_signal_handler(int sig, siginfo_t *si, void *uap __attribute__((unused))) 
    180180{ 
    181181        const char *doom_why = "at instruction"; 
     
    246246launchd_shutdown(void) 
    247247{ 
     248        struct timeval tvnow; 
    248249        struct stat sb; 
    249250 
     
    264265        } 
    265266 
     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 
    266273        launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL); 
    267274} 
     
    373380 
    374381void 
    375 pfsystem_callback(void *obj, struct kevent *kev) 
     382pfsystem_callback(void *obj __attribute__((unused)), struct kevent *kev) 
    376383{ 
    377384        bool new_networking_state; 
  • trunk/launchd/src/launchd_core_logic.c

    r23462 r23463  
    402402static void job_reparent_hack(job_t j, const char *where); 
    403403static void job_callback(void *obj, struct kevent *kev); 
    404 static void job_callback_proc(job_t j, int flags, int fflags); 
     404static void job_callback_proc(job_t j, int fflags); 
    405405static void job_callback_timer(job_t j, void *ident); 
    406406static void job_callback_read(job_t j, int ident); 
     
    753753                SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); 
    754754        } 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(); 
    755758                jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); 
    756759                runtime_closelog(); 
     
    11101113 
    11111114        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; 
    11131116 
    11141117                total_anon_children++; 
     
    23492352 
    23502353void 
    2351 job_callback_proc(job_t j, int flags, int fflags) 
     2354job_callback_proc(job_t j, int fflags) 
    23522355{ 
    23532356        bool program_changed = false; 
     
    23952398        } 
    23962399 
    2397         /* NOTE_REAP sanity checking is disabled for now while we try and diagnose 5289559 */ 
    2398 #if 0 
    23992400        if (j && (fflags & NOTE_REAP)) { 
    2400                 job_assumes(j, flags & EV_ONESHOT); 
    2401                 job_assumes(j, flags & EV_EOF); 
    2402  
    24032401                job_assumes(j, j->p == 0); 
    24042402        } 
    2405 #endif 
    24062403} 
    24072404 
     
    25112508        switch (kev->filter) { 
    25122509        case EVFILT_PROC: 
    2513                 return job_callback_proc(j, kev->flags, kev->fflags); 
     2510                return job_callback_proc(j, kev->fflags); 
    25142511        case EVFILT_TIMER: 
    25152512                return job_callback_timer(j, (void *)kev->ident); 
     
    25352532        pid_t c; 
    25362533        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; 
    25382535 
    25392536        if (!job_assumes(j, j->mgr != NULL)) { 
     
    26882685job_start_child(job_t j) 
    26892686{ 
     2687        typeof(posix_spawn) *psf; 
    26902688        const char *file2exec = "/usr/libexec/launchproxy"; 
    26912689        const char **argv; 
    26922690        posix_spawnattr_t spattr; 
    26932691        int gflags = GLOB_NOSORT|GLOB_NOCHECK|GLOB_TILDE|GLOB_DOOFFS; 
    2694         pid_t junk_pid; 
    26952692        glob_t g; 
    26962693        short spflags = POSIX_SPAWN_SETEXEC; 
     
    27702767        } 
    27712768 
    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); 
    27792777 
    27802778out_bad: 
     
    42354233        jobmgr_log(jm, LOG_DEBUG, "Garbage collecting."); 
    42364234 
    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  
    42514235        if (jm->hopefully_first_cnt) { 
    42524236                return jm; 
  • trunk/launchd/src/launchd_runtime.c

    r23453 r23463  
    870870 
    871871kern_return_t 
    872 do_mach_notify_port_destroyed(mach_port_t notify, mach_port_t rights) 
     872do_mach_notify_port_destroyed(mach_port_t notify __attribute__((unused)), mach_port_t rights) 
    873873{ 
    874874        /* This message is sent to us when a receive right is returned to us. */ 
     
    882882 
    883883kern_return_t 
    884 do_mach_notify_port_deleted(mach_port_t notify, mach_port_name_t name) 
     884do_mach_notify_port_deleted(mach_port_t notify __attribute__((unused)), mach_port_name_t name __attribute__((unused))) 
    885885{ 
    886886        /* If we deallocate/destroy/mod_ref away a port with a pending 
     
    893893 
    894894kern_return_t 
    895 do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount) 
     895do_mach_notify_no_senders(mach_port_t notify, mach_port_mscount_t mscount __attribute__((unused))) 
    896896{ 
    897897        job_t j = job_mig_intran(notify); 
     
    911911 
    912912kern_return_t 
    913 do_mach_notify_send_once(mach_port_t notify) 
     913do_mach_notify_send_once(mach_port_t notify __attribute__((unused))) 
    914914{ 
    915915        /* This message is sent to us every time we close a port that we have 
     
    922922 
    923923kern_return_t 
    924 do_mach_notify_dead_name(mach_port_t notify, mach_port_name_t name) 
     924do_mach_notify_dead_name(mach_port_t notify __attribute__((unused)), mach_port_name_t name) 
    925925{ 
    926926        /* This message is sent to us when one of our send rights no longer has 
     
    14681468 
    14691469kern_return_t 
    1470 catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 
     1470catch_mach_exception_raise(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task, 
    14711471                exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) 
    14721472{ 
     
    14851485 
    14861486kern_return_t 
    1487 catch_mach_exception_raise_state(mach_port_t exception_port, 
     1487catch_mach_exception_raise_state(mach_port_t exception_port __attribute__((unused)), 
    14881488                exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, 
    14891489                int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 
     
    15001500 
    15011501kern_return_t 
    1502 catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 
     1502catch_mach_exception_raise_state_identity(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task, 
    15031503                exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, 
    15041504                int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 
     
    15201520        return 0; 
    15211521} 
     1522 
     1523void 
     1524launchd_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  
    108108void launchd_runtime(void) __attribute__((noreturn)); 
    109109 
     110void launchd_log_vm_stats(void); 
     111 
    110112int runtime_close(int fd); 
    111113int runtime_fsync(int fd);