Projects
Browse Source     Search     Timeline     Wiki

Changeset 23589

Show
Ignore:
Timestamp:
2008-04-02 13:57:44 (6 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5834789> Observably inaccurate logging during shutdown (exit duration)

Location:
trunk/launchd/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd_core_logic.c

    r23586 r23589  
    23272327 
    23282328        if (j->sent_sigterm_time) { 
    2329                 uint64_t td_sec, td_usec, td = runtime_opaque_time_to_nano(runtime_get_opaque_time() - j->sent_sigterm_time); 
     2329                uint64_t td_sec, td_usec, td = runtime_get_nanoseconds_since(j->sent_sigterm_time); 
    23302330 
    23312331                td_sec = td / NSEC_PER_SEC; 
    23322332                td_usec = (td % NSEC_PER_SEC) / NSEC_PER_USEC; 
    23332333 
    2334                 job_log(j, LOG_INFO, "Exited %lld.%06lld seconds after %s was sent", 
    2335                                 td_sec, td_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); 
     2334                job_log(j, LOG_INFO, "Exited %lld.%06lld seconds after %s was sent", td_sec, td_usec, signal_to_C_name(SIGTERM)); 
    23362335        } 
    23372336 
     
    26212620        } else if (&j->exit_timeout == ident) { 
    26222621                if (j->sent_sigkill) { 
    2623                         uint64_t td = runtime_opaque_time_to_nano(runtime_get_opaque_time() - j->sent_sigterm_time); 
     2622                        uint64_t td = runtime_get_nanoseconds_since(j->sent_sigterm_time); 
    26242623 
    26252624                        td /= NSEC_PER_SEC; 
     
    27532752job_start(job_t j) 
    27542753{ 
    2755         uint64_t td, tnow = runtime_get_opaque_time(); 
     2754        uint64_t td; 
    27562755        int spair[2]; 
    27572756        int execspair[2]; 
     
    27712770        } 
    27722771 
    2773         job_assumes(j, tnow > j->start_time); 
    2774  
    27752772        /* 
    27762773         * Some users adjust the wall-clock and then expect software to not notice. 
     
    27782775         * wherever possible. 
    27792776         */ 
    2780         td = runtime_opaque_time_to_nano(tnow - j->start_time); 
     2777        td = runtime_get_nanoseconds_since(j->start_time); 
    27812778        td /= NSEC_PER_SEC; 
    27822779 
     
    28142811                job_assumes(j, kevent_mod(j->log_redirect_fd, EVFILT_READ, EV_ADD, 0, 0, j) != -1); 
    28152812        } 
    2816  
    2817         j->start_time = tnow; 
    28182813 
    28192814        switch (c = runtime_fork(j->weird_bootstrap ? j->j_port : j->mgr->jm_port)) { 
     
    28532848                break; 
    28542849        default: 
     2850                j->start_time = runtime_get_opaque_time(); 
     2851 
    28552852                job_log(j, LOG_DEBUG, "Started as PID: %u", c); 
    28562853 
  • trunk/launchd/src/launchd_runtime.c

    r23580 r23589  
    118118static mach_timebase_info_data_t tbi; 
    119119static uint64_t tbi_safe_math_max; 
     120static uint64_t time_of_mach_msg_return; 
    120121static double tbi_float_val; 
    121122 
     
    10261027                                msg_size, ipc_port_set, to, MACH_PORT_NULL); 
    10271028 
     1029                time_of_mach_msg_return = runtime_get_opaque_time(); 
     1030 
    10281031                tmp_options = options; 
    10291032 
     
    16401643 
    16411644INTERNAL_ABI uint64_t 
     1645runtime_get_opaque_time_of_event(void) 
     1646{ 
     1647        return time_of_mach_msg_return; 
     1648} 
     1649 
     1650INTERNAL_ABI uint64_t 
     1651runtime_get_nanoseconds_since(uint64_t o) 
     1652{ 
     1653        return runtime_opaque_time_to_nano(runtime_get_opaque_time_of_event() - o); 
     1654} 
     1655 
     1656INTERNAL_ABI uint64_t 
    16421657runtime_opaque_time_to_nano(uint64_t o) 
    16431658{ 
    1644 #if defined(__i386__) 
     1659#if defined(__i386__) || defined(__x86_64__) 
    16451660        if (unlikely(tbi.numer != tbi.denom)) { 
    1646 #elif defined(__ppc__) 
     1661#elif defined(__ppc__) || defined(__ppc64__) 
    16471662        if (likely(tbi.numer != tbi.denom)) { 
    16481663#else 
  • trunk/launchd/src/launchd_runtime.h

    r23580 r23589  
    188188INTERNAL_ABI void runtime_log_push(void); 
    189189 
    190 INTERNAL_ABI int64_t runtime_get_wall_time(void); 
    191 INTERNAL_ABI uint64_t runtime_get_opaque_time(void); 
    192 INTERNAL_ABI uint64_t runtime_opaque_time_to_nano(uint64_t o); 
     190INTERNAL_ABI int64_t runtime_get_wall_time(void) __attribute__((warn_unused_result)); 
     191INTERNAL_ABI uint64_t runtime_get_opaque_time(void) __attribute__((warn_unused_result)); 
     192INTERNAL_ABI uint64_t runtime_get_opaque_time_of_event(void) __attribute__((pure, warn_unused_result)); 
     193INTERNAL_ABI uint64_t runtime_opaque_time_to_nano(uint64_t o) __attribute__((const, warn_unused_result)); 
     194INTERNAL_ABI uint64_t runtime_get_nanoseconds_since(uint64_t o) __attribute__((pure, warn_unused_result)); 
    193195 
    194196INTERNAL_ABI kern_return_t launchd_set_bport(mach_port_t name);