|
FreeNOS
|
#include <RecoveryServer.h>
Public Member Functions | |
| RecoveryServer () | |
| Class constructor function. More... | |
Public Member Functions inherited from ChannelServer< RecoveryServer, RecoveryMessage > | |
| ChannelServer (RecoveryServer *inst) | |
| Constructor function. More... | |
| virtual | ~ChannelServer () |
| Destructor function. More... | |
| int | run () |
| Enters an infinite loop, serving incoming requests. More... | |
| void | setTimeout (const uint msec) |
| Set a sleep timeout. More... | |
Private Member Functions | |
| void | restartProcess (RecoveryMessage *msg) |
| Restart a process. More... | |
| bool | reloadProgram (const ProcessID pid, const char *path) const |
| Overwrite the given process by fetching a fresh program data copy. More... | |
| bool | cleanupProgram (const ProcessID pid) const |
| Release and unmap program data. More... | |
| bool | rewriteProgram (const ProcessID pid, const Address program, const Size size) const |
| Overwrite process with given program data. More... | |
Additional Inherited Members | |
Public Types inherited from ChannelServer< RecoveryServer, RecoveryMessage > | |
| enum | Result |
| Result codes. More... | |
Protected Types inherited from ChannelServer< RecoveryServer, RecoveryMessage > | |
| typedef void(RecoveryServer ::* | IPCHandlerFunction) (RecoveryMessage *) |
| Member function pointer inside Base, to handle IPC messages. More... | |
| typedef void(RecoveryServer ::* | IRQHandlerFunction) (Size) |
| Member function pointer inside Base, to handle interrupts. More... | |
Protected Member Functions inherited from ChannelServer< RecoveryServer, RecoveryMessage > | |
| void | addIPCHandler (const Size slot, IPCHandlerFunction h, const bool sendReply=true) |
| Register a new IPC message action handler. More... | |
| void | addIRQHandler (const Size slot, IRQHandlerFunction h) |
| Register a new IRQ message vector handler. More... | |
| virtual void | timeout () |
| Called when sleep timeout is reached. More... | |
| virtual bool | retryRequests () |
| Retry any pending requests. More... | |
| virtual void | onProcessTerminated (const ProcessID pid) |
| Called whenever another Process is terminated. More... | |
| void | retryAllRequests () |
| Keep retrying requests until all served. More... | |
Protected Attributes inherited from ChannelServer< RecoveryServer, RecoveryMessage > | |
| RecoveryServer * | m_instance |
| Server object instance. More... | |
| ChannelClient * | m_client |
| Client for sending replies. More... | |
| ChannelRegistry & | m_registry |
| Contains registered channels. More... | |
| MemoryChannel | m_kernelEvent |
| Kernel event channel. More... | |
| Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCount > | m_ipcHandlers |
| IPC handler functions. More... | |
| Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCount > | m_irqHandlers |
| IRQ handler functions. More... | |
| ProcessID | m_self |
| ProcessID of ourselves. More... | |
| Timer::Info | m_time |
| System timer value. More... | |
| Timer::Info | m_expiry |
| System timer expiration value. More... | |
Recovery Server.
Provides fault tolerance to servers by restarting on errors (recovery)
Definition at line 53 of file RecoveryServer.h.
| RecoveryServer::RecoveryServer | ( | ) |
Class constructor function.
Definition at line 25 of file RecoveryServer.cpp.
References ChannelServer< RecoveryServer, RecoveryMessage >::addIPCHandler(), Recovery::RestartProcess, and restartProcess().
|
private |
Release and unmap program data.
| pid | Process identifier |
Definition at line 251 of file RecoveryServer.cpp.
References DEBUG, ERROR, MemoryMap::range(), ReleaseSections, API::Success, MemoryMap::UserData, MemoryMap::UserHeap, MemoryMap::UserPrivate, and VMCtl().
Referenced by reloadProgram().
|
private |
Overwrite the given process by fetching a fresh program data copy.
| pid | Process identifier |
| path | Path to the program data to use |
Definition at line 114 of file RecoveryServer.cpp.
References Memory::Range::access, cleanupProgram(), FileSystemClient::closeFile(), DEBUG, ERROR, Lz4Decompressor::getUncompressedSize(), Lz4Decompressor::initialize(), MapContiguous, FileSystemClient::openFile(), Memory::Range::phys, Lz4Decompressor::read(), Memory::Readable, FileSystemClient::readFile(), Release, rewriteProgram(), SELF, Memory::Range::size, FileSystem::FileStat::size, FileSystemClient::statFile(), FileSystem::Success, API::Success, Lz4Decompressor::Success, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.
Referenced by restartProcess().
|
private |
Restart a process.
| msg | RecoveryMessage pointer |
Definition at line 31 of file RecoveryServer.cpp.
References DEBUG, ERROR, InfoPID, Recovery::InvalidArgument, Recovery::IOError, MAX_PROCS, Recovery::NotFound, RecoveryMessage::pid, ProcessCtl(), MemoryMap::range(), API::Read, reloadProgram(), RecoveryMessage::result, Resume, String::split(), Stop, Recovery::Success, API::Success, MemoryMap::UserArgs, Memory::Range::virt, and VMCopy().
Referenced by RecoveryServer().
|
private |
Overwrite process with given program data.
| pid | Process identifier |
| program | Address containing the program data |
| size | Number of bytes in the program data |
Definition at line 288 of file RecoveryServer.cpp.
References Memory::Range::access, ExecutableFormat::Region::access, MemoryBlock::copy(), ExecutableFormat::Region::dataOffset, ExecutableFormat::Region::dataSize, DEBUG, entry, ExecutableFormat::entry(), ERROR, ExecutableFormat::find(), MapContiguous, ExecutableFormat::Region::memorySize, Memory::Range::phys, ProcessCtl(), ExecutableFormat::regions(), Reset, SELF, MemoryBlock::set(), Memory::Range::size, API::Success, ExecutableFormat::Success, UnMap, Memory::Range::virt, ExecutableFormat::Region::virt, VMCtl(), and ZERO.
Referenced by reloadProgram().
1.8.17