Projects
Browse Source     Search     Timeline     Wiki

Changeset 23466

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

Misc logging updates.

Location:
trunk/launchd/src
Files:
5 modified

Legend:

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

    r23463 r23466  
    100100static pid_t crash_pid; 
    101101 
    102 static bool shutdown_in_progress = false; 
    103 bool debug_shutdown_hangs = false; 
     102bool shutdown_in_progress = false; 
    104103bool network_up = false; 
    105104 
     
    247246{ 
    248247        struct timeval tvnow; 
    249         struct stat sb; 
    250248 
    251249        if (shutdown_in_progress) { 
     
    255253        shutdown_in_progress = true; 
    256254 
    257         if (getpid() == 1 && stat("/var/db/debugShutdownHangs", &sb) != -1) { 
     255        if (getpid() == 1) { 
    258256                /* 
    259257                 * When this changes to a more sustainable API, update this: 
     
    262260                runtime_setlogmask(LOG_UPTO(LOG_DEBUG)); 
    263261                prep_shutdown_log_dir(); 
    264                 debug_shutdown_hangs = true; 
    265262        } 
    266263 
  • trunk/launchd/src/launchd.h

    r23297 r23466  
    3232struct conncb; 
    3333 
    34 extern bool debug_shutdown_hangs; 
     34extern bool shutdown_in_progress; 
    3535extern bool network_up; 
    3636 
  • trunk/launchd/src/launchd_core_logic.c

    r23465 r23466  
    711711        } 
    712712 
    713         if (debug_shutdown_hangs && jm->parentmgr == NULL && getpid() == 1) { 
     713        if (do_apple_internal_logging() && jm->parentmgr == NULL && getpid() == 1) { 
    714714                runtime_set_timeout(still_alive_with_check, 5); 
    715715        } 
     
    42954295{ 
    42964296        int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; 
    4297         size_t i, kp_cnt, len = 10*1024*1024; 
     4297        size_t i, kp_cnt = 0, kp_skipped = 0, len = 10*1024*1024; 
    42984298        struct kinfo_proc *kp; 
    42994299 
     
    43194319 
    43204320                if (p_i == 0 || p_i == 1) { 
     4321                        kp_skipped++; 
    43214322                        continue; 
    43224323                } 
     
    43314332 
    43324333out: 
     4334        if (kp_cnt == kp_skipped) { 
     4335                jobmgr_log(jm, LOG_DEBUG, "No stray processes at shutdown"); 
     4336        } 
     4337 
    43334338        free(kp); 
    43344339} 
     
    47674772        pid_t sp; 
    47684773 
    4769         if (!debug_shutdown_hangs) { 
     4774        if (!do_apple_internal_logging()) { 
    47704775                return; 
    47714776        } 
     
    67036708{ 
    67046709        struct statfs buf[250]; 
    6705         int i, found, returned; 
     6710        int r, i, found, returned; 
    67066711 
    67076712        do { 
     
    67216726                        } 
    67226727 
    6723                         runtime_syslog(LOG_DEBUG, "About to unmount: %s", buf[i].f_mntonname); 
    6724                         if (launchd_assumes(unmount(buf[i].f_mntonname, 0) != -1)) { 
     6728                        r = unmount(buf[i].f_mntonname, 0); 
     6729 
     6730                        runtime_syslog(LOG_DEBUG, "unmount(\"%s\", 0): %s", buf[i].f_mntonname, r == -1 ? strerror(errno) : "Success"); 
     6731 
     6732                        if (r != -1) { 
    67256733                                found++; 
    67266734                        } 
  • trunk/launchd/src/launchd_runtime.c

    r23463 r23466  
    11321132runtime_fsync(int fd) 
    11331133{ 
    1134         if (debug_shutdown_hangs) { 
     1134        if (do_apple_internal_logging()) { 
    11351135                return fcntl(fd, F_FULLFSYNC, NULL); 
    11361136        } else { 
     
    11701170        static struct timeval shutdown_start; 
    11711171        static struct timeval prev_msg; 
    1172         static int apple_internal_logging = 1; 
    11731172        struct timeval tvnow, tvd_total, tvd_msg_delta = { 0, 0 }; 
    1174         struct stat sb; 
    11751173        int saved_errno = errno; 
    11761174        char newmsg[10000]; 
    11771175        size_t i, j; 
    11781176 
    1179         if (apple_internal_logging == 1) { 
    1180                 apple_internal_logging = stat("/AppleInternal", &sb); 
    1181         } 
    1182  
    11831177        if (attr->priority == LOG_APPLEONLY) { 
    1184                 if (apple_internal_logging == 0) { 
     1178                if (do_apple_internal_logging()) { 
    11851179                        attr->priority = LOG_NOTICE; 
    11861180                } else { 
     
    11931187        } 
    11941188 
    1195         if (!(debug_shutdown_hangs && getpid() == 1)) { 
     1189        if (getpid() != 1 || !shutdown_in_progress) { 
    11961190                vsnprintf(newmsg, sizeof(newmsg), message, args); 
    11971191                logmsg_add(attr, saved_errno, newmsg); 
     
    15681562        launchd_mport_deallocate(mhs); 
    15691563} 
     1564 
     1565bool 
     1566do_apple_internal_logging(void) 
     1567{ 
     1568        static int apple_internal_logging = 1; 
     1569        struct stat sb; 
     1570 
     1571        if (apple_internal_logging == 1) { 
     1572                apple_internal_logging = stat("/AppleInternal", &sb); 
     1573        } 
     1574 
     1575        return (apple_internal_logging == 0); 
     1576} 
  • trunk/launchd/src/launchd_runtime.h

    r23463 r23466  
    124124const char *proc_flags_to_C_names(unsigned int flags); 
    125125 
     126bool do_apple_internal_logging(void); 
    126127 
    127128int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt);