engine.h
Go to the documentation of this file.
/*
* Copyright (c) 2009 NLNet Labs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef DAEMON_ENGINE_H
#define DAEMON_ENGINE_H
#include "config.h"
#include <signal.h>
typedef struct engine_struct engine_type;
#include "daemon/cfg.h"
#include "cmdhandler.h"
#include "scheduler/task.h"
#include "scheduler/schedule.h"
#include "db/db_configuration.h"
#include "db/db_connection.h"
struct engine_struct {
engineconfig_type* config;
pid_t pid;
uid_t uid;
gid_t gid;
int daemonize;
int need_to_exit;
int need_to_reload;
int init_setup_done;
worker_type** workers;
schedule_type* taskq;
cmdhandler_type* cmdhandler;
/* Main thread blocks on this condition when there is nothing to do */
pthread_cond_t signal_cond;
pthread_mutex_t signal_lock;
db_configuration_list_t* dbcfg_list;
};
db_connection_t* get_database_connection(engine_type* engine);
ods_status engine_setup(void);
void engine_teardown(engine_type* engine);
void engine_init(engine_type* engine, int daemonize);
typedef void (*start_cb_t)(engine_type* engine);
int engine_run(engine_type* engine, start_cb_t start, int single_run);
void engine_stop(engine_type* engine);
void engine_wakeup_workers(engine_type* engine);
void engine_stop_workers(engine_type* engine);
void engine_start_workers(engine_type* engine);
engine_type* engine_alloc(void);
void engine_dealloc(engine_type* engine);
#endif /* DAEMON_ENGINE_H */
db_connection.h
db_configuration_list
Definition: db_configuration.h:93
engine_stop
void engine_stop(engine_type *engine)
engine_alloc
engine_type * engine_alloc(void)
Definition: engine.c:79
cfg.h
engine_stop_workers
void engine_stop_workers(engine_type *engine)
Definition: engine.c:193
engine_run
int engine_run(engine_type *engine, start_cb_t start, int single_run)
Definition: engine.c:643
engineconfig_struct
Definition: cfg.h:54
engine_teardown
void engine_teardown(engine_type *engine)
Definition: engine.c:586
engine_dealloc
void engine_dealloc(engine_type *engine)
Definition: engine.c:97
engine_struct::signal_cond
pthread_cond_t signal_cond
Definition: engine.h:64
engine_struct::dbcfg_list
db_configuration_list_t * dbcfg_list
Definition: engine.h:67
engine_struct::config
engineconfig_type * config
Definition: engine.h:48
engine_struct::workers
worker_type ** workers
Definition: engine.h:59
db_configuration.h
engine_struct::init_setup_done
int init_setup_done
Definition: engine.h:57
engine_start_workers
void engine_start_workers(engine_type *engine)
Definition: engine.c:174
engine_struct::gid
gid_t gid
Definition: engine.h:52
engine_struct::pid
pid_t pid
Definition: engine.h:50
engine_struct::cmdhandler
cmdhandler_type * cmdhandler
Definition: engine.h:61
engine_wakeup_workers
void engine_wakeup_workers(engine_type *engine)
Definition: engine.c:218
engine_setup
ods_status engine_setup(void)
Definition: engine.c:433
engine_struct::signal_lock
pthread_mutex_t signal_lock
Definition: engine.h:65
engine_struct
Definition: engine.h:47
engine_struct::taskq
schedule_type * taskq
Definition: engine.h:60
db_connection
Definition: db_connection.h:46
engine_struct::daemonize
int daemonize
Definition: engine.h:54
engine_struct::need_to_exit
int need_to_exit
Definition: engine.h:55
get_database_connection
db_connection_t * get_database_connection(engine_type *engine)
Definition: engine.c:226
engine_init
void engine_init(engine_type *engine, int daemonize)
Definition: engine.c:614
engine_struct::need_to_reload
int need_to_reload
Definition: engine.h:56
start_cb_t
void(* start_cb_t)(engine_type *engine)
Definition: engine.h:98
engine_struct::uid
uid_t uid
Definition: engine.h:51