engine.c File Reference
`#include "config.h"`
`#include <pthread.h>`
`#include "daemon/cfg.h"`
`#include "daemon/enforcercommands.h"`
`#include "clientpipe.h"`
`#include "cmdhandler.h"`
`#include "locks.h"`
`#include "daemon/engine.h"`
`#include "scheduler/schedule.h"`
`#include "scheduler/task.h"`
`#include "file.h"`
`#include "log.h"`
`#include "privdrop.h"`
`#include "status.h"`
`#include "util.h"`
`#include "db/db_configuration.h"`
`#include "db/db_connection.h"`
`#include "db/database_version.h"`
`#include "hsmkey/hsm_key_factory.h"`
`#include "libhsm.h"`
`#include <errno.h>`
`#include <libxml/parser.h>`
`#include <signal.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <strings.h>`
`#include <sys/socket.h>`
`#include <sys/types.h>`
`#include <sys/un.h>`
`#include <time.h>`
`#include <unistd.h>`
`#include <fcntl.h>`

Go to the source code of this file.

## Functions

engine_type * | engine_alloc (void)
void | engine_dealloc (engine_type *engine)
void | engine_start_workers (engine_type *engine)
void | engine_stop_workers (engine_type *engine)
void | engine_wakeup_workers (engine_type *engine)
db_connection_t * | get_database_connection (engine_type *engine)
ods_status | engine_setup ()
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)

## Function Documentation

## engine_alloc()

engine_type * engine_alloc | ( | void |  | ) |

Create engine.

Definition at line 79 of file engine.c.

Referenced by main().

## engine_dealloc()

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

Definition at line 97 of file engine.c.

References db_configuration_list_free(), and hsm_key_factory_deinit().

Referenced by main().

## engine_init()

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

Definition at line 612 of file engine.c.

Referenced by main().

## engine_run()

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

Run engine, run!.

Definition at line 643 of file engine.c.

References engine_start_workers(), and engine_stop_workers().

Referenced by main().

## engine_setup()

ods_status engine_setup | ( | void |  | ) |

Set up engine and return the setup status.

Definition at line 432 of file engine.c.

References db_connection_free(), enforcercommands, and get_database_connection().

Referenced by main().

## 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 get_database_connection().

Referenced by engine_run().

## 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 db_connection_free(), and engine_wakeup_workers().

Referenced by engine_run().

## engine_teardown()

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

Clean up engine.

Definition at line 584 of file engine.c.

Referenced by main().

## engine_wakeup_workers()

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

Wake up all workers.

Definition at line 218 of file engine.c.

Referenced by engine_stop_workers().

## 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(), and db_connection_setup().

Referenced by autostart(), engine_setup(), and engine_start_workers().