FFmpegfs Fuse Multi Media Filesystem 2.16
|
Cache maintenance implementation More...
#include "cache_maintenance.h"
#include "ffmpegfs.h"
#include "logging.h"
#include <csignal>
#include <unistd.h>
#include <sys/shm.h>
#include <semaphore.h>
Go to the source code of this file.
Macros | |
#define | CLOCKID CLOCK_REALTIME |
Use real time clock here. More... | |
#define | SIGMAINT SIGRTMIN |
Map maintenance signal. More... | |
#define | SEM_OPEN_FILE "/" PACKAGE_NAME "_04806785-b5fb-4615-ba56-b30a2946e80b" |
Shared semaphore name, should be unique system wide. More... | |
Functions | |
static void | maintenance_handler (int sig, __attribute__((unused)) siginfo_t *si, __attribute__((unused)) void *uc) |
Run maintenance handler. More... | |
static bool | start_timer (time_t interval) |
Start the maintenance timer at predefined interval. More... | |
static bool | stop_timer () |
Stop the maintenance timer. More... | |
static bool | link_up () |
Set system wide inter process link up. More... | |
static void | master_check () |
Check if a master is already running. We become master if not. More... | |
static bool | link_down () |
Set system wide inter process link down. More... | |
bool | start_cache_maintenance (time_t interval) |
Start cache maintenance timer. More... | |
bool | stop_cache_maintenance () |
Stop cache maintenance timer. More... | |
Variables | |
static sigset_t | mask |
Process mask for timer. More... | |
static timer_t | timerid |
Timer id. More... | |
static sem_t * | sem |
Semaphore used to synchronise between master and slave processes. More... | |
static int | shmid |
Shared memory segment ID. More... | |
static pid_t * | pid_master |
PID of master process. More... | |
static bool | master |
If true, we are master. More... | |
Cache maintenance implementation
Definition in file cache_maintenance.cc.
#define CLOCKID CLOCK_REALTIME |
Use real time clock here.
Definition at line 41 of file cache_maintenance.cc.
#define SEM_OPEN_FILE "/" PACKAGE_NAME "_04806785-b5fb-4615-ba56-b30a2946e80b" |
Shared semaphore name, should be unique system wide.
Definition at line 44 of file cache_maintenance.cc.
#define SIGMAINT SIGRTMIN |
Map maintenance signal.
Definition at line 42 of file cache_maintenance.cc.
|
static |
Set system wide inter process link down.
Definition at line 271 of file cache_maintenance.cc.
References Logging::error(), Logging::info(), pid_master, sem, SEM_OPEN_FILE, and shmid.
Referenced by link_up(), and stop_cache_maintenance().
|
static |
Set system wide inter process link up.
Definition at line 172 of file cache_maintenance.cc.
References Logging::debug(), Logging::error(), Logging::info(), link_down(), master, pid_master, sem, SEM_OPEN_FILE, and shmid.
Referenced by start_cache_maintenance().
|
static |
Run maintenance handler.
[in] | sig | - Signal, must be SIGMAINT. |
[in] | si | |
[in] | uc |
Definition at line 67 of file cache_maintenance.cc.
References Logging::info(), master, master_check(), SIGMAINT, and transcoder_cache_maintenance().
Referenced by start_timer().
|
static |
Check if a master is already running. We become master if not.
Definition at line 238 of file cache_maintenance.cc.
References Logging::info(), master, pid_master, sem, and Logging::trace().
Referenced by maintenance_handler().
bool start_cache_maintenance | ( | time_t | interval | ) |
Start cache maintenance timer.
[in] | interval | - Interval in seconds to run timer at. |
Definition at line 319 of file cache_maintenance.cc.
References link_up(), and start_timer().
Referenced by ffmpegfs_init().
|
static |
Start the maintenance timer at predefined interval.
[in] | interval | - Timer interval in seconds. |
Definition at line 89 of file cache_maintenance.cc.
References CLOCKID, Logging::error(), format_time(), maintenance_handler(), mask, SIGMAINT, timerid, and Logging::trace().
Referenced by start_cache_maintenance().
bool stop_cache_maintenance | ( | ) |
Stop cache maintenance timer.
Definition at line 331 of file cache_maintenance.cc.
References link_down(), and stop_timer().
Referenced by ffmpegfs_destroy().
|
static |
Stop the maintenance timer.
Definition at line 155 of file cache_maintenance.cc.
References Logging::error(), Logging::info(), and timerid.
Referenced by stop_cache_maintenance().
|
static |
Process mask for timer.
Definition at line 46 of file cache_maintenance.cc.
Referenced by start_timer().
|
static |
If true, we are master.
Definition at line 52 of file cache_maintenance.cc.
Referenced by link_up(), maintenance_handler(), and master_check().
|
static |
PID of master process.
Definition at line 51 of file cache_maintenance.cc.
Referenced by link_down(), link_up(), and master_check().
|
static |
Semaphore used to synchronise between master and slave processes.
Definition at line 49 of file cache_maintenance.cc.
Referenced by link_down(), link_up(), and master_check().
|
static |
Shared memory segment ID.
Definition at line 50 of file cache_maintenance.cc.
Referenced by link_down(), and link_up().
|
static |
Timer id.
Definition at line 47 of file cache_maintenance.cc.
Referenced by start_timer(), and stop_timer().