Instance.cc File Reference
#include "squid.h"
#include "base/File.h"
#include "fs_io.h"
#include "Instance.h"
#include "parser/Tokenizer.h"
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "tools.h"
#include <cerrno>
Include dependency graph for Instance.cc:

Go to the source code of this file.

Functions

static SBuf PidFilenameCalc ()
 
static SBuf PidFileDescription (const SBuf &filename)
 
static SBuf PidFilename ()
 
static pid_t GetOtherPid (File &pidFile)
 
static bool ProcessIsRunning (const pid_t pid)
 determines whether a given process is running at the time of the call More...
 
static void ThrowIfAlreadyRunningWith (File &pidFile)
 quits if another Squid instance (that owns the given PID file) is running More...
 
static void RemoveInstance ()
 atexit() handler; removes the PID file created with Instance::WriteOurPid() More...
 

Variables

static SBuf TheFile
 
static SBuf ThePidFileToRemove
 ties Instance::WriteOurPid() scheduler and RemoveInstance(void) handler More...
 

Function Documentation

static pid_t GetOtherPid ( File pidFile)
static
Returns
the PID of another Squid instance (or throws)

Definition at line 68 of file Instance.cc.

References Parser::Tokenizer::atEnd(), CharacterSet::CR, debugs, Parser::Tokenizer::int64(), CharacterSet::LF, File::readSmall(), Parser::Tokenizer::skipOne(), TexcHere, and ToSBuf().

Referenced by Instance::Other(), and ThrowIfAlreadyRunningWith().

static SBuf PidFileDescription ( const SBuf filename)
static
Returns
PID file description for debugging messages and error reporting

Definition at line 51 of file Instance.cc.

References ToSBuf().

Referenced by PidFilename(), and RemoveInstance().

static SBuf PidFilename ( )
static

Instance entry points are expected to call this first.

Returns
PidFilenameCalc() result while updating TheFile context

Definition at line 59 of file Instance.cc.

References PidFileDescription(), and PidFilenameCalc().

Referenced by Instance::Other(), Instance::ThrowIfAlreadyRunning(), and Instance::WriteOurPid().

static SBuf PidFilenameCalc ( )
static

PidFilename() helper

Returns
PID file name or, if PID signaling was disabled, an empty SBuf

Definition at line 29 of file Instance.cc.

References SBuf::append(), SquidConfig::chroot_dir, Chrooted, Config, debugs, and SquidConfig::pidFilename.

Referenced by PidFilename().

static bool ProcessIsRunning ( const pid_t  pid)
static

Definition at line 94 of file Instance.cc.

References debugs, and xstrerr().

Referenced by ThrowIfAlreadyRunningWith().

static void RemoveInstance ( void  )
static
static void ThrowIfAlreadyRunningWith ( File pidFile)
static

Variable Documentation

SBuf TheFile
static

Describes the (last) instance PID file being processed. This hack shortens reporting code while keeping its messages consistent.

Definition at line 24 of file Instance.cc.

SBuf ThePidFileToRemove
static

Definition at line 157 of file Instance.cc.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors