A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Fatal Error Handler

Functions to help clean up when fatal error is encountered. More...

+ Collaboration diagram for Fatal Error Handler:

Functions

void ns3::FatalImpl::FlushStreams (void)
 Flush all currently registered streams. More...
 
void ns3::FatalImpl::RegisterStream (std::ostream *stream)
 Register a stream to be flushed on abnormal exit. More...
 
void ns3::FatalImpl::UnregisterStream (std::ostream *stream)
 Unregister a stream for flushing on abnormal exit. More...
 

Detailed Description

Functions to help clean up when fatal error is encountered.

The functions in this group are used to perform limited clean up, like flushing active streams, when fatal error are encountered (through assertion fail, calls to NS_ABORT_* and calls to NS_FATAL_ERROR.

Currently, other than flushing active ostreams, these functions does not interfere with outside memory. There is still a residual risk that may be invalid ostream pointers may be present, and may corrupt the memory on the attempt to execute the flush() function.

Function Documentation

void ns3::FatalImpl::FlushStreams ( void  )

Flush all currently registered streams.

This function iterates through each registered stream and unregister them. The default SIGSEGV handler is overridden when this function is being executed, and will be restored when this function returns.

If a SIGSEGV is encountered (most likely due to bad ostream* being registered, or a registered osteam* pointing to an ostream that had already been destroyed), this function will skip the bad ostream* and continue to flush the next stram. The function will then terminate raising SIGIOT (aka SIGABRT)

DO NOT call this function until the program is ready to crash.

Definition at line 116 of file fatal-impl.cc.

References NS_LOG_FUNCTION_NOARGS, ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList(), s, and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler().

Referenced by ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::FatalImpl::RegisterStream ( std::ostream *  stream)

Register a stream to be flushed on abnormal exit.

Parameters
streamThe stream to be flushed on abnormal exit.

If a std::terminate() call is encountered after the stream had been registered and before it had been unregistered, stream->flush() will be called. Users of this function is to ensure stream remains valid until it had been unregistered.

Definition at line 80 of file fatal-impl.cc.

References ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList(), and NS_LOG_FUNCTION.

Referenced by ns3::AsciiFile::AsciiFile(), ns3::OutputStreamWrapper::OutputStreamWrapper(), and ns3::PcapFile::PcapFile().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::FatalImpl::UnregisterStream ( std::ostream *  stream)

Unregister a stream for flushing on abnormal exit.

Parameters
streamThe stream to be unregistered.

After a stream had been unregistered, stream->flush() will no longer be called should abnormal termination is encountered.

If stream is not registered, nothing will happen.

Definition at line 87 of file fatal-impl.cc.

References NS_LOG_FUNCTION, and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList().

Referenced by ns3::AsciiFile::~AsciiFile(), ns3::OutputStreamWrapper::~OutputStreamWrapper(), and ns3::PcapFile::~PcapFile().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: