diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-14 05:17:41 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-14 05:17:41 +0000 |
commit | 1c2a195c13869e7a3cc5005a537c089e14a100d3 (patch) | |
tree | d45c7a1bb91dad0fd7eb57e062de64442a22d247 /ace/Log_Msg_IPC.cpp | |
parent | 619a8d9519a5f68281fb2f01dd4c977dc3386201 (diff) | |
download | ATCD-1c2a195c13869e7a3cc5005a537c089e14a100d3.tar.gz |
ChangeLogTag:Fri Oct 13 21:49:54 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Log_Msg_IPC.cpp')
-rw-r--r-- | ace/Log_Msg_IPC.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/ace/Log_Msg_IPC.cpp b/ace/Log_Msg_IPC.cpp new file mode 100644 index 00000000000..9d90638395e --- /dev/null +++ b/ace/Log_Msg_IPC.cpp @@ -0,0 +1,72 @@ +// $Id$ + +#include "ace/Log_Msg_IPC.h" +#include "ace/Log_Record.h" + +ACE_RCSID(ace, Log_Msg_IPC, "$Id$") + +ACE_Log_Msg_IPC::ACE_Log_Msg_IPC (void) +{ +} + +ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void) +{ + (void) this->close (); +} + +int +ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key) +{ + ACE_LOG_MSG_IPC_CONNECTOR con; + return con.connect (this->message_queue_, + ACE_LOG_MSG_IPC_ADDR (logger_key)); +} + +int +ACE_Log_Msg_IPC::reset (void) +{ + if (this->message_queue_.get_handle () != ACE_INVALID_HANDLE) + { + // If we don't do this, handles aren't reused on Win32 and the + // server eventually crashes! +#if defined (ACE_WIN32) + ACE_INT32 dummy = ~0; + this->message_queue_.send_n ((const void *) &dummy, + sizeof (ACE_INT32)); +#endif /* ACE_WIN32 */ + return this->close (); + } + return 0; +} + +int +ACE_Log_Msg_IPC::close (void) +{ + return this->message_queue_.close (); +} + +int +ACE_Log_Msg_IPC::log (ACE_Log_Record &log_record) +{ +#if defined (ACE_HAS_STREAM_PIPES) + ACE_Str_Buf log_msg (ACE_static_cast (void *, + &log_record), + ACE_static_cast (int, + log_record.length ())); + + // Try to use the <putpmsg> API if possible in order to + // ensure correct message queueing according to priority. + return + this->message_queue_.send + (ACE_static_cast (const ACE_Str_Buf *, 0), + &log_msg, + ACE_static_cast (int, log_record.priority ()), + MSG_BAND); +#else + // We're running over sockets, so we'll need to indicate the + // number of bytes to send. + return + this->message_queue_.send_n ((void *) &log_record, + log_record.length ()); +#endif /* ACE_HAS_STREAM_PIPES */ +} |