engine.h File Reference
`#include "config.h"`
`#include <signal.h>`
`#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"`

Go to the source code of this file.

## Data Structures

struct | engine_struct

## Typedefs

typedef struct engine_struct | engine_type
typedef void(* | start_cb_t) (engine_type *engine)

## Functions

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)
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)

## Typedef Documentation

## engine_type

typedef struct engine_struct engine_type

The engine.

Definition at line 38 of file engine.h.

## start_cb_t

typedef void(* start_cb_t) (engine_type *engine)

Definition at line 98 of file engine.h.

## Function Documentation

## engine_alloc()

engine_type* engine_alloc | ( | void |  | ) |

Create engine.

Definition at line 79 of file engine.c.

References engine_struct::dbcfg_list, engine_struct::signal_cond, engine_struct::signal_lock, and engine_struct::taskq.

## engine_dealloc()

void engine_dealloc | ( | engine_type * | engine | ) |

Definition at line 97 of file engine.c.

References db_configuration_list_free(), engine_struct::dbcfg_list, hsm_key_factory_deinit(), engine_struct::signal_cond, engine_struct::signal_lock, and engine_struct::taskq.

## engine_init()

void engine_init | ( | engine_type * | engine,
|  | int | daemonize
| ) |  |

Definition at line 614 of file engine.c.

References engine_struct::cmdhandler, engine_struct::config, engine_struct::daemonize, engine_struct::gid, engine_struct::init_setup_done, engine_struct::need_to_exit, engine_struct::need_to_reload, engine_struct::pid, engine_struct::uid, and engine_struct::workers.

## engine_run()

int engine_run | ( | engine_type * | engine,
|  | start_cb_t | start,
|  | int | single_run
| ) |  |

Run the engine after setting it up using engine_setup. When this function returns the runloop has finished and the engine is ready to stop.

Parameters

  [in] | engine | the engine returned from engine_start
  [in] | single_run | run once

Returns
  0 if terminated normally, 1 on unrecoverable error.

Run engine, run!.

Definition at line 643 of file engine.c.

References engine_start_workers(), engine_struct::need_to_exit, engine_struct::need_to_reload, and engine_struct::signal_lock.

## engine_setup()

ods_status engine_setup | ( | void |  | ) |

Setup the engine started by engine_create

Parameters

  [in] | engine | the engine returned from engine_start
  [in] | commands | NULL terminated list of command functions for the engine that the command handler can run.
  [in] | help | NULL terminated list of help functions that print help for the command to a socket.

Set up engine and return the setup status.

Definition at line 433 of file engine.c.

## engine_start_workers()

void engine_start_workers | ( | engine_type * | engine | ) |

start all workers.

Parameters

  [in] | engine | engine

Definition at line 174 of file engine.c.

References engine_struct::config.

Referenced by engine_run().

## engine_stop()

void engine_stop | ( | engine_type * | engine | ) |

Stop the engine after engine_runloop returns.

Parameters

  [in] | engine | engine

## engine_stop_workers()

void engine_stop_workers | ( | engine_type * | engine | ) |

signal all workers to stop. Blocks until all workers are joined.

Parameters

  [in] | engine | engine

Definition at line 193 of file engine.c.

References engine_struct::config.

## engine_teardown()

void engine_teardown | ( | engine_type * | engine | ) |

Clean up engine.

Parameters

  [in] | engine | engine

Clean up engine.

Definition at line 586 of file engine.c.

References engineconfig_struct::clisock_filename, engine_struct::cmdhandler, engine_struct::config, engineconfig_struct::num_worker_threads, engineconfig_struct::pid_filename, and engine_struct::workers.

## engine_wakeup_workers()

void engine_wakeup_workers | ( | engine_type * | engine | ) |

Wake up workers.

Parameters

  [in] | engine | engine

Wake up all workers.

Definition at line 218 of file engine.c.

## get_database_connection()

db_connection_t* get_database_connection | ( | engine_type * | engine | ) |

Try to open a connection to the database.

Parameters

  engine,the | engine containing database configuration

Returns
  connection on success, NULL on failure.

Definition at line 226 of file engine.c.

References db_connection_connect(), db_connection_free(), db_connection_new(), db_connection_set_configuration_list(), db_connection_setup(), and engine_struct::dbcfg_list.