Projects
Browse Source     Search     Timeline     Wiki

Changeset 23371

Show
Ignore:
Timestamp:
09/11/07 16:44:27 (15 months ago)
Author:
zarzycki@…
Message:

More wall-clock versus absolute-clock fun...

Files:
1 modified

Legend:

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

    r23369 r23371  
    349349        unsigned int exit_timeout; 
    350350        int stdout_err_fd; 
    351         struct timeval sent_sigterm_time; 
     351        uint64_t sent_sigterm_time; 
    352352        uint64_t start_time; 
    353353        uint32_t min_run_time; 
     
    448448static void extract_rcsid_substr(const char *i, char *o, size_t osz); 
    449449static void do_first_per_user_launchd_hack(void); 
     450static void do_file_init(void) __attribute__((constructor)); 
    450451 
    451452/* file local globals */ 
     
    454455static bool did_first_per_user_launchd_BootCache_hack; 
    455456static jobmgr_t background_jobmgr; 
     457static mach_timebase_info_data_t tbi; 
    456458 
    457459/* process wide globals */ 
     
    523525 
    524526        job_assumes(j, kill(j->p, SIGTERM) != -1); 
    525         job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); 
     527        j->sent_sigterm_time = mach_absolute_time(); 
    526528 
    527529        if (j->exit_timeout) { 
     
    18991901job_reap(job_t j) 
    19001902{ 
    1901         struct timeval tve, tvd; 
    19021903        struct rusage ru; 
    19031904        int status; 
     
    19441945        LIST_REMOVE(j, pid_hash_sle); 
    19451946 
    1946         job_assumes(j, gettimeofday(&tve, NULL) != -1); 
    1947  
    19481947        if (j->wait_reply_port) { 
    19491948                job_log(j, LOG_DEBUG, "MPM wait reply being sent"); 
     
    19521951        } 
    19531952 
    1954         if (j->sent_sigterm_time.tv_sec) { 
    1955                 timersub(&tve, &j->sent_sigterm_time,  &tvd); 
    1956  
    1957                 job_log(j, LOG_INFO, "Exited %ld.%06d seconds after %s was sent", 
    1958                                 tvd.tv_sec, tvd.tv_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); 
     1953        if (j->sent_sigterm_time) { 
     1954                uint64_t td_sec, td_usec, td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; 
     1955 
     1956                td_sec = td / NSEC_PER_SEC; 
     1957                td_usec = (td % NSEC_PER_SEC) / NSEC_PER_USEC; 
     1958 
     1959                job_log(j, LOG_INFO, "Exited %lld.%06lld seconds after %s was sent", 
     1960                                td_sec, td_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); 
    19591961        } 
    19601962 
     
    21762178        } else if (&j->exit_timeout == ident) { 
    21772179                if (j->sent_sigkill) { 
    2178                         struct timeval tvd, tve; 
    2179  
    2180                         job_assumes(j, gettimeofday(&tve, NULL) != -1); 
    2181                         timersub(&tve, &j->sent_sigterm_time,  &tvd); 
    2182                         tvd.tv_sec -= j->exit_timeout; 
    2183                         job_log(j, LOG_ERR, "Did not die after sending SIGKILL %lu seconds ago...", tvd.tv_sec); 
     2180                        uint64_t td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; 
     2181 
     2182                        td /= NSEC_PER_SEC; 
     2183                        td -= j->exit_timeout; 
     2184 
     2185                        job_log(j, LOG_ERR, "Did not die after sending SIGKILL %llu seconds ago...", td); 
    21842186                } else { 
    21852187                        job_force_sampletool(j); 
     
    22862288job_start(job_t j) 
    22872289{ 
    2288         static mach_timebase_info_data_t tbi; 
    22892290        uint64_t td, tnow = mach_absolute_time(); 
    22902291        int spair[2]; 
     
    22962297        u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT /* |NOTE_REAP */; 
    22972298 
    2298         if (tbi.denom == 0) { 
    2299                 launchd_assert(mach_timebase_info(&tbi) == 0); 
    2300         } 
    2301  
    23022299        if (!job_assumes(j, j->mgr != NULL)) { 
    23032300                return; 
     
    23212318        } 
    23222319 
    2323         j->sent_sigterm_time.tv_sec = 0; 
    2324         j->sent_sigterm_time.tv_usec = 0; 
     2320        j->sent_sigterm_time = 0; 
    23252321 
    23262322        if (!j->legacy_mach_job) { 
     
    63256321        free(w4r); 
    63266322} 
     6323 
     6324void 
     6325do_file_init(void) 
     6326{ 
     6327        launchd_assert(mach_timebase_info(&tbi) == 0); 
     6328 
     6329}