CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Watchdog Class Reference

#include <monitor.h>

Collaboration diagram for Watchdog:

Classes

struct  ControlFlow
 
struct  CrashData
 

Public Member Functions

 ~Watchdog ()
 
void Spawn ()
 
void RegisterOnCrash (void(*CleanupOnCrash)(void))
 

Static Public Member Functions

static WatchdogCreate (const std::string &crash_dump_path)
 
static pid_t GetPid ()
 
static void * MainWatchdogListener (void *data)
 

Private Types

typedef std::map< int, struct
sigaction > 
SigactionMap
 

Private Member Functions

 Watchdog (const std::string &crash_dump_path)
 
SigactionMap SetSignalHandlers (const SigactionMap &signal_handlers)
 
void Supervise ()
 
void LogEmergency (std::string msg)
 
std::string ReportStacktrace ()
 
std::string GenerateStackTrace (pid_t pid)
 
std::string ReadUntilGdbPrompt (int fd_pipe)
 

Static Private Member Functions

static WatchdogMe ()
 
static void SendTrace (int sig, siginfo_t *siginfo, void *context)
 

Private Attributes

bool spawned_
 
std::string crash_dump_path_
 
std::string exe_path_
 
pid_t watchdog_pid_
 
Pipepipe_watchdog_
 
Pipepipe_listener_
 The supervisee makes sure its watchdog does not die. More...
 
Pipepipe_terminate_
 Send the terminate signal to the listener. More...
 
pthread_t thread_listener_
 
void(* on_crash_ )(void)
 
platform_spinlock lock_handler_
 
stack_t sighandler_stack_
 
SigactionMap old_signal_handlers_
 

Static Private Attributes

static const unsigned kSignalHandlerStacksize = 2 * 1024 * 1024
 
static const unsigned kMaxBacktrace = 64
 
static Watchdoginstance_ = NULL
 

Detailed Description

This class can fork a watchdog process that listens on a pipe and prints a stackstrace into syslog, when cvmfs fails. The crash dump is also appended to the crash dump file, if the path is not empty. Singleton.

Definition at line 25 of file monitor.h.

Member Typedef Documentation

typedef std::map<int, struct sigaction> Watchdog::SigactionMap
private

Definition at line 36 of file monitor.h.

Constructor & Destructor Documentation

Watchdog::~Watchdog ( )

Definition at line 563 of file monitor.cc.

Here is the call graph for this function:

Watchdog::Watchdog ( const std::string &  crash_dump_path)
explicitprivate

Definition at line 547 of file monitor.cc.

Here is the call graph for this function:

Member Function Documentation

Watchdog * Watchdog::Create ( const std::string &  crash_dump_path)
static

Definition at line 59 of file monitor.cc.

Referenced by cvmcache_spawn_watchdog(), Init(), main(), swissknife::CommandSync::Main(), and PosixQuotaManager::MainCacheManager().

Here is the call graph for this function:

Here is the caller graph for this function:

string Watchdog::GenerateStackTrace ( pid_t  pid)
private

Uses an external shell and gdb to create a full stack trace of the dying process. The same shell is used to force-quit the client afterwards.

Definition at line 70 of file monitor.cc.

Here is the call graph for this function:

pid_t Watchdog::GetPid ( )
static

Definition at line 160 of file monitor.cc.

Referenced by TalkManager::MainResponder().

Here is the caller graph for this function:

void Watchdog::LogEmergency ( std::string  msg)
private

Log a string to syslog and into the crash dump file. We expect ideally nothing to be logged, so that file is created on demand.

Definition at line 174 of file monitor.cc.

void * Watchdog::MainWatchdogListener ( void *  data)
static

Definition at line 474 of file monitor.cc.

Here is the call graph for this function:

static Watchdog* Watchdog::Me ( )
inlinestaticprivate

Definition at line 64 of file monitor.h.

string Watchdog::ReadUntilGdbPrompt ( int  fd_pipe)
private

Reads from the file descriptor until the specific gdb prompt is reached or the pipe gets broken.

Parameters
fd_pipethe file descriptor of the pipe to be read
Returns
the data read from the pipe

Definition at line 203 of file monitor.cc.

void Watchdog::RegisterOnCrash ( void(*)(void)  CleanupOnCrash)

Definition at line 239 of file monitor.cc.

Referenced by Spawn().

Here is the caller graph for this function:

string Watchdog::ReportStacktrace ( )
private

Generates useful information from the backtrace log in the pipe.

Definition at line 247 of file monitor.cc.

Here is the call graph for this function:

void Watchdog::SendTrace ( int  sig,
siginfo_t *  siginfo,
void *  context 
)
staticprivate

Definition at line 288 of file monitor.cc.

Here is the call graph for this function:

Watchdog::SigactionMap Watchdog::SetSignalHandlers ( const SigactionMap signal_handlers)
private

Sets the signal handlers of the current process according to the ones defined in the given SigactionMap.

Parameters
signal_handlersa map of SIGNAL -> struct sigaction
Returns
a SigactionMap containing the old handlers

Definition at line 355 of file monitor.cc.

Referenced by MainWatchdogListener().

Here is the caller graph for this function:

void Watchdog::Spawn ( )

Fork the watchdog process.

Definition at line 376 of file monitor.cc.

Referenced by cvmcache_spawn_watchdog(), main(), swissknife::CommandSync::Main(), PosixQuotaManager::MainCacheManager(), and Spawn().

Here is the call graph for this function:

Here is the caller graph for this function:

void Watchdog::Supervise ( )
private

Definition at line 515 of file monitor.cc.

Here is the call graph for this function:

Member Data Documentation

std::string Watchdog::crash_dump_path_
private

Definition at line 77 of file monitor.h.

std::string Watchdog::exe_path_
private

Definition at line 78 of file monitor.h.

Watchdog * Watchdog::instance_ = NULL
staticprivate

Definition at line 63 of file monitor.h.

Referenced by Me(), and ~Watchdog().

const unsigned Watchdog::kMaxBacktrace = 64
staticprivate

If the GDB/LLDB method of generating a stack trace fails, fall back to libc's backtrace with a maximum depth.

Definition at line 61 of file monitor.h.

const unsigned Watchdog::kSignalHandlerStacksize = 2 * 1024 * 1024
staticprivate

Preallocated memory block to make sure that signal handler don't run into stack overflows.

Definition at line 56 of file monitor.h.

platform_spinlock Watchdog::lock_handler_
private

Definition at line 87 of file monitor.h.

Referenced by Watchdog(), and ~Watchdog().

SigactionMap Watchdog::old_signal_handlers_
private

Definition at line 89 of file monitor.h.

Referenced by MainWatchdogListener().

void(* Watchdog::on_crash_)(void)
private

Definition at line 86 of file monitor.h.

Pipe* Watchdog::pipe_listener_
private

The supervisee makes sure its watchdog does not die.

Definition at line 82 of file monitor.h.

Referenced by MainWatchdogListener(), and ~Watchdog().

Pipe* Watchdog::pipe_terminate_
private

Send the terminate signal to the listener.

Definition at line 84 of file monitor.h.

Referenced by MainWatchdogListener(), and ~Watchdog().

Pipe* Watchdog::pipe_watchdog_
private

Definition at line 80 of file monitor.h.

Referenced by ~Watchdog().

stack_t Watchdog::sighandler_stack_
private

Definition at line 88 of file monitor.h.

Referenced by Watchdog(), and ~Watchdog().

bool Watchdog::spawned_
private

Definition at line 76 of file monitor.h.

Referenced by ~Watchdog().

pthread_t Watchdog::thread_listener_
private

Definition at line 85 of file monitor.h.

Referenced by ~Watchdog().

pid_t Watchdog::watchdog_pid_
private

Definition at line 79 of file monitor.h.


The documentation for this class was generated from the following files: