Changeset 23376
- Timestamp:
- 09/12/07 17:48:46 (15 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 3 modified
-
launchd_core_logic.c (modified) (17 diffs)
-
launchd_runtime.c (modified) (5 diffs)
-
launchd_runtime.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchd_core_logic.c
r23375 r23376 94 94 95 95 #define LAUNCHD_MIN_JOB_RUN_TIME 10 96 #define LAUNCHD_ADVISABLE_IDLE_TIMEOUT 3097 96 #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 98 97 #define LAUNCHD_SIGKILL_TIMER 5 … … 451 450 452 451 /* file local globals */ 453 static unsigned int total_children;452 static size_t total_children; 454 453 static mach_port_t the_exception_server; 455 454 static bool did_first_per_user_launchd_BootCache_hack; … … 647 646 still_alive_with_check(void) 648 647 { 649 jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with % u children.", total_children);648 jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu children.", total_children); 650 649 651 650 runtime_closelog(); /* hack to flush logs */ … … 741 740 struct envitem *ei; 742 741 742 if (j == workaround_5477111) { 743 job_log(j, LOG_NOTICE, "@@@@@ Tried to remove ahead of schedule!"); 744 } 745 743 746 if (j->p && j->anonymous) { 744 747 job_reap(j); … … 838 841 } 839 842 if (j->start_interval) { 843 runtime_del_ref(); 840 844 job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); 841 845 } … … 1123 1127 j->mgr = jm; 1124 1128 j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; 1125 j->timeout = LAUNCHD_ADVISABLE_IDLE_TIMEOUT;1129 j->timeout = RUNTIME_ADVISABLE_IDLE_TIMEOUT; 1126 1130 j->exit_timeout = LAUNCHD_DEFAULT_EXIT_TIMEOUT; 1127 1131 j->currently_ignored = true; … … 1461 1465 job_log(j, LOG_WARNING, "StartInterval is not greater than zero, ignoring"); 1462 1466 } else { 1467 runtime_add_ref(); 1463 1468 j->start_interval = value; 1464 1469 } … … 1951 1956 } 1952 1957 1958 if (!j->anonymous) { 1959 runtime_del_ref(); 1960 } 1953 1961 total_children--; 1954 1962 LIST_REMOVE(j, pid_hash_sle); … … 2389 2397 j->start_pending = false; 2390 2398 2399 runtime_add_ref(); 2391 2400 total_children++; 2392 2401 LIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); … … 3263 3272 calendarinterval_setalarm(j, ci); 3264 3273 3274 runtime_add_ref(); 3275 3265 3276 return true; 3266 3277 } … … 3273 3284 3274 3285 free(ci); 3286 3287 runtime_del_ref(); 3275 3288 } 3276 3289 … … 3330 3343 SLIST_INSERT_HEAD(&j->sockets, sg, sle); 3331 3344 3345 runtime_add_ref(); 3346 3332 3347 return true; 3333 3348 } … … 3346 3361 free(sg->fds); 3347 3362 free(sg); 3363 3364 runtime_del_ref(); 3348 3365 } 3349 3366 … … 3543 3560 return true; 3544 3561 } else if (j->mgr->shutting_down) { 3545 job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: % u", total_children);3562 job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: %lu", total_children); 3546 3563 return true; 3547 3564 } else if (j->legacy_mach_job) { … … 4560 4577 SLIST_INSERT_HEAD(&j->semaphores, si, sle); 4561 4578 4579 runtime_add_ref(); 4580 4562 4581 return true; 4563 4582 } … … 4573 4592 4574 4593 free(si); 4594 4595 runtime_del_ref(); 4575 4596 } 4576 4597 … … 5123 5144 case VPROC_GSK_START_INTERVAL: 5124 5145 if ((unsigned int)inval > 0) { 5146 if (j->start_interval == 0) { 5147 runtime_add_ref(); 5148 } 5125 5149 j->start_interval = inval; 5126 5150 job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); 5127 5151 } else if (j->start_interval) { 5128 5152 job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); 5153 if (j->start_interval != 0) { 5154 runtime_del_ref(); 5155 } 5129 5156 j->start_interval = 0; 5130 5157 } -
trunk/launchd/src/launchd_runtime.c
r23373 r23376 91 91 static mig_callback *mig_cb_table; 92 92 static size_t mig_cb_table_sz; 93 static timeout_callback runtime_idle_callback ;94 static mach_msg_timeout_t runtime_idle_timeout ;93 static timeout_callback runtime_idle_callback = launchd_shutdown; 94 static mach_msg_timeout_t runtime_idle_timeout = RUNTIME_ADVISABLE_IDLE_TIMEOUT * 1000; 95 95 static audit_token_t *au_tok; 96 static size_t runtime_busy_cnt; 96 97 97 98 … … 636 637 637 638 void 638 runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to)639 { 640 if ( to== 0 || to_cb == NULL) {639 runtime_set_timeout(timeout_callback to_cb, unsigned int sec) 640 { 641 if (sec == 0 || to_cb == NULL) { 641 642 runtime_idle_callback = NULL; 642 643 runtime_idle_timeout = 0; … … 644 645 645 646 runtime_idle_callback = to_cb; 646 runtime_idle_timeout = to;647 runtime_idle_timeout = sec * 1000; 647 648 } 648 649 … … 912 913 } 913 914 914 if ((tmp_options & MACH_RCV_MSG) && runtime_idle_callback ) {915 if ((tmp_options & MACH_RCV_MSG) && runtime_idle_callback && (runtime_busy_cnt == 0)) { 915 916 tmp_options |= MACH_RCV_TIMEOUT; 916 917 … … 1350 1351 return runtime_log_pack(outval, outvalCnt); 1351 1352 } 1353 1354 void 1355 runtime_add_ref(void) 1356 { 1357 runtime_busy_cnt++; 1358 } 1359 1360 void 1361 runtime_del_ref(void) 1362 { 1363 runtime_busy_cnt--; 1364 } -
trunk/launchd/src/launchd_runtime.h
r23362 r23376 57 57 boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); 58 58 59 void runtime_add_ref(void); 60 void runtime_del_ref(void); 61 59 62 void launchd_runtime_init(void); 60 63 void launchd_runtime_init2(void); … … 64 67 int runtime_fsync(int fd); 65 68 66 void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to); 69 #define RUNTIME_ADVISABLE_IDLE_TIMEOUT 30 70 71 void runtime_set_timeout(timeout_callback to_cb, unsigned int sec); 67 72 kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); 68 73 kern_return_t runtime_remove_mport(mach_port_t name);

