Changeset 23466
- Timestamp:
- 12/12/07 16:16:27 (12 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 5 modified
-
launchd.c (modified) (4 diffs)
-
launchd.h (modified) (1 diff)
-
launchd_core_logic.c (modified) (7 diffs)
-
launchd_runtime.c (modified) (4 diffs)
-
launchd_runtime.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchd.c
r23463 r23466 100 100 static pid_t crash_pid; 101 101 102 static bool shutdown_in_progress = false; 103 bool debug_shutdown_hangs = false; 102 bool shutdown_in_progress = false; 104 103 bool network_up = false; 105 104 … … 247 246 { 248 247 struct timeval tvnow; 249 struct stat sb;250 248 251 249 if (shutdown_in_progress) { … … 255 253 shutdown_in_progress = true; 256 254 257 if (getpid() == 1 && stat("/var/db/debugShutdownHangs", &sb) != -1) {255 if (getpid() == 1) { 258 256 /* 259 257 * When this changes to a more sustainable API, update this: … … 262 260 runtime_setlogmask(LOG_UPTO(LOG_DEBUG)); 263 261 prep_shutdown_log_dir(); 264 debug_shutdown_hangs = true;265 262 } 266 263 -
trunk/launchd/src/launchd.h
r23297 r23466 32 32 struct conncb; 33 33 34 extern bool debug_shutdown_hangs;34 extern bool shutdown_in_progress; 35 35 extern bool network_up; 36 36 -
trunk/launchd/src/launchd_core_logic.c
r23465 r23466 711 711 } 712 712 713 if (d ebug_shutdown_hangs&& jm->parentmgr == NULL && getpid() == 1) {713 if (do_apple_internal_logging() && jm->parentmgr == NULL && getpid() == 1) { 714 714 runtime_set_timeout(still_alive_with_check, 5); 715 715 } … … 4295 4295 { 4296 4296 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; 4298 4298 struct kinfo_proc *kp; 4299 4299 … … 4319 4319 4320 4320 if (p_i == 0 || p_i == 1) { 4321 kp_skipped++; 4321 4322 continue; 4322 4323 } … … 4331 4332 4332 4333 out: 4334 if (kp_cnt == kp_skipped) { 4335 jobmgr_log(jm, LOG_DEBUG, "No stray processes at shutdown"); 4336 } 4337 4333 4338 free(kp); 4334 4339 } … … 4767 4772 pid_t sp; 4768 4773 4769 if (!d ebug_shutdown_hangs) {4774 if (!do_apple_internal_logging()) { 4770 4775 return; 4771 4776 } … … 6703 6708 { 6704 6709 struct statfs buf[250]; 6705 int i, found, returned;6710 int r, i, found, returned; 6706 6711 6707 6712 do { … … 6721 6726 } 6722 6727 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) { 6725 6733 found++; 6726 6734 } -
trunk/launchd/src/launchd_runtime.c
r23463 r23466 1132 1132 runtime_fsync(int fd) 1133 1133 { 1134 if (d ebug_shutdown_hangs) {1134 if (do_apple_internal_logging()) { 1135 1135 return fcntl(fd, F_FULLFSYNC, NULL); 1136 1136 } else { … … 1170 1170 static struct timeval shutdown_start; 1171 1171 static struct timeval prev_msg; 1172 static int apple_internal_logging = 1;1173 1172 struct timeval tvnow, tvd_total, tvd_msg_delta = { 0, 0 }; 1174 struct stat sb;1175 1173 int saved_errno = errno; 1176 1174 char newmsg[10000]; 1177 1175 size_t i, j; 1178 1176 1179 if (apple_internal_logging == 1) {1180 apple_internal_logging = stat("/AppleInternal", &sb);1181 }1182 1183 1177 if (attr->priority == LOG_APPLEONLY) { 1184 if ( apple_internal_logging == 0) {1178 if (do_apple_internal_logging()) { 1185 1179 attr->priority = LOG_NOTICE; 1186 1180 } else { … … 1193 1187 } 1194 1188 1195 if ( !(debug_shutdown_hangs && getpid() == 1)) {1189 if (getpid() != 1 || !shutdown_in_progress) { 1196 1190 vsnprintf(newmsg, sizeof(newmsg), message, args); 1197 1191 logmsg_add(attr, saved_errno, newmsg); … … 1568 1562 launchd_mport_deallocate(mhs); 1569 1563 } 1564 1565 bool 1566 do_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 124 124 const char *proc_flags_to_C_names(unsigned int flags); 125 125 126 bool do_apple_internal_logging(void); 126 127 127 128 int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt);

