Revision: 23665 http://trac.macosforge.org/projects/launchd/changeset/23665 Author: dsorresso@apple.com Date: 2008-08-15 01:04:45 -0700 (Fri, 15 Aug 2008) Log Message: ----------- Frequency parameter is now a global, eschewing potential complications in passing an unsigned int as a void *. Also makes logic in the new thread loop more concise. Update thread function is now properly typed and returns NULL. Modified Paths: -------------- branches/PR-5039559/launchd/src/launchd.c Modified: branches/PR-5039559/launchd/src/launchd.c =================================================================== --- branches/PR-5039559/launchd/src/launchd.c 2008-08-15 03:51:47 UTC (rev 23664) +++ branches/PR-5039559/launchd/src/launchd.c 2008-08-15 08:04:45 UTC (rev 23665) @@ -67,6 +67,7 @@ #include <setjmp.h> #include <spawn.h> #include <sched.h> +#include <pthread.h> #include "libbootstrap_public.h" #include "libvproc_public.h" @@ -96,7 +97,7 @@ static void fatal_signal_handler(int sig, siginfo_t *si, void *uap); static void handle_pid1_crashes_separately(void); -static void update_thread(unsigned int freq); +static void *update_thread(void *nothing); static bool re_exec_in_single_user_mode; static void *crash_addr; @@ -105,6 +106,7 @@ bool shutdown_in_progress; bool fake_shutdown_in_progress; bool network_up; +unsigned int g_sync_frequency = 0; int main(int argc, char *const *argv) @@ -171,10 +173,9 @@ if( pid1_magic ) { /* Start the update thread -- rdar://problem/5039559 */ pthread_t t = NULL; - int freq = 30; - int err = pthread_create(&t, NULL, (void (*)(void *))update_thread, (void *)freq); + g_sync_frequency = 30; + int err = pthread_create(&t, NULL, update_thread, NULL); launchd_assumes(err == 0); - /* FIXME: Figure out what to do if we fail ... */ } //#endif @@ -200,12 +201,14 @@ launchd_assumes(sigaction(SIGSEGV, &fsa, NULL) != -1); } -static void update_thread(unsigned int freq) +void *update_thread(void *nothing __attribute__((unused))) { - while( true ) { + while( g_sync_frequency ) { sync(); - sleep(freq); + sleep(g_sync_frequency); } + + return NULL; } #define PID1_CRASH_LOGFILE "/var/log/launchd-pid1.crash"
participants (1)
-
source_changes@macosforge.org