Modified: branches/PR-7431992/launchd/src/launchd_runtime.c (23962 => 23963)
--- branches/PR-7431992/launchd/src/launchd_runtime.c 2009-12-03 00:21:03 UTC (rev 23962)
+++ branches/PR-7431992/launchd/src/launchd_runtime.c 2009-12-03 01:39:35 UTC (rev 23963)
@@ -102,8 +102,8 @@
static struct ldcred ldc;
static size_t runtime_busy_cnt;
static size_t runtime_standby_cnt;
+static size_t runtime_busy_time;
-
static STAILQ_HEAD(, logmsg_s) logmsg_queue = STAILQ_HEAD_INITIALIZER(logmsg_queue);
static size_t logmsg_queue_sz;
static size_t logmsg_queue_cnt;
@@ -1579,7 +1579,9 @@
_vproc_transaction_begin();
#endif
}
+
runtime_busy_cnt++;
+ runtime_remove_timer();
}
void
@@ -1595,7 +1597,9 @@
_vproc_transaction_end();
#endif
}
+
runtime_busy_cnt--;
+ runtime_install_timer();
}
void
@@ -1620,6 +1624,22 @@
runtime_standby_cnt--;
}
+void
+runtime_install_timer(void)
+{
+ if( !pid1_magic && runtime_busy_cnt == 0 ) {
+ launchd_assumes(kevent_mod((uintptr_t)&runtime_busy_time, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 30, NULL) != -1);
+ }
+}
+
+void
+runtime_remove_timer(void)
+{
+ if( !pid1_magic && runtime_busy_cnt > 0 ) {
+ launchd_assumes(kevent_mod((uintptr_t)&runtime_busy_time, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1);
+ }
+}
+
kern_return_t
catch_mach_exception_raise(mach_port_t exception_port __attribute__((unused)), mach_port_t thread, mach_port_t task,
exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt)
Modified: branches/PR-7431992/launchd/src/launchd_runtime.h (23962 => 23963)
--- branches/PR-7431992/launchd/src/launchd_runtime.h 2009-12-03 00:21:03 UTC (rev 23962)
+++ branches/PR-7431992/launchd/src/launchd_runtime.h 2009-12-03 01:39:35 UTC (rev 23963)
@@ -118,6 +118,8 @@
void runtime_del_ref(void);
void runtime_add_weak_ref(void);
void runtime_del_weak_ref(void);
+void runtime_install_timer(void);
+void runtime_remove_timer(void);
void launchd_runtime_init(void);
void launchd_runtime_init2(void);