Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/ntp/ntpd/ntpd.c
Show All 21 Lines | |||||
#ifdef SIM | #ifdef SIM | ||||
# include "ntpsim.h" | # include "ntpsim.h" | ||||
#endif | #endif | ||||
#include "ntp_libopts.h" | #include "ntp_libopts.h" | ||||
#include "ntpd-opts.h" | #include "ntpd-opts.h" | ||||
/* there's a short treatise below what the thread stuff is for */ | /* there's a short treatise below what the thread stuff is for. | ||||
* [Bug 2954] enable the threading warm-up only for Linux. | |||||
*/ | |||||
#if defined(HAVE_PTHREADS) && HAVE_PTHREADS && !defined(NO_THREADS) | #if defined(HAVE_PTHREADS) && HAVE_PTHREADS && !defined(NO_THREADS) | ||||
# ifdef HAVE_PTHREAD_H | # ifdef HAVE_PTHREAD_H | ||||
# include <pthread.h> | # include <pthread.h> | ||||
# endif | # endif | ||||
# if defined(linux) | |||||
# define NEED_PTHREAD_WARMUP | # define NEED_PTHREAD_WARMUP | ||||
#endif | # endif | ||||
#endif | |||||
#ifdef HAVE_UNISTD_H | #ifdef HAVE_UNISTD_H | ||||
# include <unistd.h> | # include <unistd.h> | ||||
#endif | #endif | ||||
#ifdef HAVE_SYS_STAT_H | #ifdef HAVE_SYS_STAT_H | ||||
# include <sys/stat.h> | # include <sys/stat.h> | ||||
#endif | #endif | ||||
#include <stdio.h> | #include <stdio.h> | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | |||||
* actually nothing except waiting for cancellation and cancel it. If | * actually nothing except waiting for cancellation and cancel it. If | ||||
* this is done before all the limitations are put in place, the | * this is done before all the limitations are put in place, the | ||||
* machinery is pre-heated and all the runtime stuff should be in place | * machinery is pre-heated and all the runtime stuff should be in place | ||||
* and useable when needed. | * and useable when needed. | ||||
* | * | ||||
* This uses only the standard pthread API and should work with all | * This uses only the standard pthread API and should work with all | ||||
* implementations of pthreads. It is not necessary everywhere, but it's | * implementations of pthreads. It is not necessary everywhere, but it's | ||||
* cheap enough to go on nearly unnoticed. | * cheap enough to go on nearly unnoticed. | ||||
* | |||||
* Addendum: Bug 2954 showed that the assumption that this should work | |||||
* with all OS is wrong -- at least FreeBSD bombs heavily. | |||||
*/ | */ | ||||
#ifdef NEED_PTHREAD_WARMUP | #ifdef NEED_PTHREAD_WARMUP | ||||
/* simple thread function: sleep until cancelled, just to exercise | /* simple thread function: sleep until cancelled, just to exercise | ||||
* thread cancellation. | * thread cancellation. | ||||
*/ | */ | ||||
static void* | static void* | ||||
my_pthread_warmup_worker( | my_pthread_warmup_worker( | ||||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | # ifdef HAVE_SCHED_SETSCHEDULER | ||||
if (HAVE_OPT( PRIORITY )) { | if (HAVE_OPT( PRIORITY )) { | ||||
config_priority = OPT_VALUE_PRIORITY; | config_priority = OPT_VALUE_PRIORITY; | ||||
config_priority_override = 1; | config_priority_override = 1; | ||||
priority_done = 0; | priority_done = 0; | ||||
} | } | ||||
# endif | # endif | ||||
# ifdef HAVE_WORKING_FORK | # ifdef HAVE_WORKING_FORK | ||||
/* make sure the FDs are initialised */ | |||||
pipe_fds[0] = -1; | |||||
pipe_fds[1] = -1; | |||||
do { /* 'loop' once */ | do { /* 'loop' once */ | ||||
if (!HAVE_OPT( WAIT_SYNC )) | if (!HAVE_OPT( WAIT_SYNC )) | ||||
break; | break; | ||||
wait_sync = OPT_VALUE_WAIT_SYNC; | wait_sync = OPT_VALUE_WAIT_SYNC; | ||||
if (wait_sync <= 0) { | if (wait_sync <= 0) { | ||||
wait_sync = 0; | wait_sync = 0; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 905 Lines • Show Last 20 Lines |