Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
EthanLogLoop Class Reference

Classes

struct  AddClientEvent
 
struct  Event
 
struct  SetClientBasePidEvent
 
struct  TerminateEvent
 

Public Member Functions

 EthanLogLoop (const std::string &memCgroupMountPoint)
 
int addClient (const ContainerId &id, const std::string &tag, unsigned allowedLevels, uint64_t rate=0, uint64_t burstSize=0)
 Creates a new logging client, which is just pipe with some meta data stored. More...
 
void setClientBasePid (const ContainerId &id, pid_t basePid)
 Sets the base pid number for the given container. More...
 

Private Member Functions

void eventLoop ()
 Event loop thread function. More...
 
void wakeLoop ()
 Wakes the event loop. More...
 

Static Private Member Functions

static int eventFdHandler (sd_event_source *source, int fd, uint32_t revents, void *userData)
 Handler for wake ups from the event fd. More...
 

Private Attributes

const std::string mMemCgroupMountPoint
 
std::thread mThread
 
std::mutex mLock
 
int mEventFd
 
std::deque< EventmEvents
 
std::list< std::unique_ptr< EthanLogClient > > mClients
 

Member Function Documentation

◆ addClient()

int EthanLogLoop::addClient ( const ContainerId id,
const std::string &  tag,
unsigned  allowedLevels,
uint64_t  rate = 0,
uint64_t  burstSize = 0 
)

Creates a new logging client, which is just pipe with some meta data stored.

Parameters
[in]idThe container id.
[in]tagThe identifier to assign to all log messages.
[in]allowedLevelsBitmask of allowed levels.
[in]rateThe rate limit (actually limiting TBD)
[in]burstSizeThe burst limit (actually limiting TBD)
Returns

◆ eventFdHandler()

int EthanLogLoop::eventFdHandler ( sd_event_source *  source,
int  fd,
uint32_t  revents,
void *  userData 
)
staticprivate

Handler for wake ups from the event fd.

This will either be called if the terminate flag is set or when a new client has been added to the list of clients.

Parameters
[in]sourceThe event loop source handler.
[in]fdShould be the event fd.
[in]reventsThe event that triggered the wake up.
[in]userDataPointer back to the instance of EthanLogLoop class.
Returns

◆ eventLoop()

void EthanLogLoop::eventLoop ( )
private

Event loop thread function.

Runs the event loop processing inputs from logging pipes until the terminate flag is set.

◆ setClientBasePid()

void EthanLogLoop::setClientBasePid ( const ContainerId id,
pid_t  basePid 
)

Sets the base pid number for the given container.

This is used so we can pass the real pid to journald.

Parameters
[in]idThe container id.
[in]basePidThe pid of the init process inside the container.

◆ wakeLoop()

void EthanLogLoop::wakeLoop ( )
private

Wakes the event loop.

Writes to the eventfd which should wake the event loop thread. This is used when either a new client is added or we wish to terminate the event loop thread.


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