Instance Namespace Reference

code related to Squid Instance and PID file management

Functions

void ThrowIfAlreadyRunning ()
 
void WriteOurPid ()
 creates a PID file; throws on error More...
 
pid_t Other ()
 
SBuf NamePrefix (const char *head, const char *tail=nullptr)
 

Function Documentation

◆ NamePrefix()

SBuf Instance::NamePrefix ( const char *  head,
const char *  tail = nullptr 
)

A service_name-derived string that is likely to be unique across all Squid instances concurrently running on the same host (as long as they do not disable PID file maintenance).

Parameters
headis used at the beginning of the generated name
tailis used at the end of the generated name (when not nil)
Returns
a head-...tail string suitable for making file and shm segment names

Definition at line 253 of file Instance.cc.

References SBuf::append(), head, PidFilenameHash(), and service_name.

Referenced by Ipc::Port::CoordinatorAddr(), and Ipc::Port::MakeAddr().

◆ Other()

pid_t Instance::Other ( )
Returns
another Squid instance PID Throws if PID file maintenance is disabled.

Definition at line 129 of file Instance.cc.

References GetOtherPid(), PidFilename(), FileOpeningConfig::ReadOnly(), and TexcHere.

Referenced by sendSignal().

◆ ThrowIfAlreadyRunning()

void Instance::ThrowIfAlreadyRunning ( )

Usually throws if another Squid instance is running. False positives are highly unlikely, but the caller must tolerate false negatives well: We may not detect another running instance and, hence, may not throw. Does nothing if PID file maintenance is disabled.

Definition at line 140 of file Instance.cc.

References debugs, File::Optional(), PidFilename(), FileOpeningConfig::ReadOnly(), TheFile, and ThrowIfAlreadyRunningWith().

Referenced by SquidMain().

◆ WriteOurPid()

void Instance::WriteOurPid ( )

Creates or updates the PID file for the current process. Does nothing if PID file maintenance is disabled.

Definition at line 187 of file Instance.cc.

References debugs, Important, Must, PidFilename(), SBuf::Printf(), FileOpeningConfig::ReadWrite(), RemoveInstance(), File::synchronize(), TheFile, ThePidFileToRemove, ThrowIfAlreadyRunningWith(), File::truncate(), and File::writeAll().

Referenced by SquidMain(), and watch_child().

 

Introduction

Documentation

Support

Miscellaneous