mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 18:02:31 +08:00
fdbmonitor: update headers & libraries
This commit is contained in:
parent
9753013b65
commit
5064cc776b
@ -37,6 +37,10 @@
|
||||
#include <linux/limits.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/event.h>
|
||||
#include <mach/mach.h>
|
||||
@ -78,7 +82,7 @@
|
||||
|
||||
#ifdef __linux__
|
||||
typedef fd_set* fdb_fd_set;
|
||||
#elif defined __APPLE__
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
typedef int fdb_fd_set;
|
||||
#endif
|
||||
|
||||
@ -89,7 +93,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd, void* cmd ) {
|
||||
FD_SET( fd, list );
|
||||
if ( fd > *maxfd )
|
||||
*maxfd = fd;
|
||||
#elif defined __APPLE__
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
/* ignore maxfd */
|
||||
struct kevent ev;
|
||||
EV_SET( &ev, fd, EVFILT_READ, EV_ADD, 0, 0, cmd );
|
||||
@ -100,7 +104,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd, void* cmd ) {
|
||||
void unmonitor_fd( fdb_fd_set list, int fd ) {
|
||||
#ifdef __linux__
|
||||
FD_CLR( fd, list );
|
||||
#elif defined __APPLE__
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
struct kevent ev;
|
||||
EV_SET( &ev, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL );
|
||||
kevent( list, &ev, 1, NULL, 0, NULL ); // FIXME: check?
|
||||
@ -194,7 +198,7 @@ const char* get_value_multi(const CSimpleIni& ini, const char* key, ...) {
|
||||
}
|
||||
|
||||
double timer() {
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return double(ts.tv_sec) + (ts.tv_nsec * 1e-9);
|
||||
@ -913,7 +917,7 @@ void read_child_output( Command* cmd, int pipe_idx, fdb_fd_set fds ) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
void watch_conf_dir( int kq, int* confd_fd, std::string confdir ) {
|
||||
struct kevent ev;
|
||||
std::string original = confdir;
|
||||
@ -1266,12 +1270,12 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
|
||||
if (daemonize) {
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
if (daemon(0, 0)) {
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
log_err("daemon", errno, "Unable to daemonize");
|
||||
@ -1330,7 +1334,7 @@ int main(int argc, char** argv) {
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
int kq = kqueue();
|
||||
if ( kq < 0 ) {
|
||||
log_err( "kqueue", errno, "Unable to create kqueue" );
|
||||
@ -1375,11 +1379,11 @@ int main(int argc, char** argv) {
|
||||
/* normal will be restored in our main loop in the call to
|
||||
pselect, but none blocks all signals while processing events */
|
||||
sigprocmask(SIG_SETMASK, &full_mask, &normal_mask);
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
sigprocmask(0, NULL, &normal_mask);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
struct stat st_buf;
|
||||
struct timespec mtimespec;
|
||||
|
||||
@ -1438,7 +1442,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
load_conf(confpath.c_str(), uid, gid, &normal_mask, &rfds, &maxfd);
|
||||
reload_additional_watches = false;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
load_conf( confpath.c_str(), uid, gid, &normal_mask, watched_fds, &maxfd );
|
||||
watch_conf_file( kq, &conff_fd, confpath.c_str() );
|
||||
watch_conf_dir( kq, &confd_fd, confdir );
|
||||
@ -1476,7 +1480,7 @@ int main(int argc, char** argv) {
|
||||
if(nfds == 0) {
|
||||
reload = true;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
int nev = 0;
|
||||
if(timeout < 0) {
|
||||
nev = kevent( kq, NULL, 0, &ev, 1, NULL );
|
||||
|
Loading…
x
Reference in New Issue
Block a user