Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Log_Msg_IPC.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Log_Msg_IPC.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "ace/Log_Msg_IPC.h"
00005 #include "ace/Log_Record.h"
00006 
00007 ACE_RCSID(ace, Log_Msg_IPC, "$Id: Log_Msg_IPC.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $")
00008 
00009 ACE_Log_Msg_IPC::ACE_Log_Msg_IPC (void)
00010 {
00011 }
00012 
00013 ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void)
00014 {
00015   (void) this->close ();
00016 }
00017 
00018 int
00019 ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key)
00020 {
00021   ACE_LOG_MSG_IPC_CONNECTOR con;
00022   return con.connect (this->message_queue_,
00023                       ACE_LOG_MSG_IPC_ADDR (logger_key));
00024 }
00025 
00026 int
00027 ACE_Log_Msg_IPC::reset (void)
00028 {
00029   if (this->message_queue_.get_handle () != ACE_INVALID_HANDLE)
00030     {
00031       // If we don't do this, handles aren't reused on Win32 and the
00032       // server eventually crashes!
00033 #if defined (ACE_WIN32)
00034       ACE_INT32 dummy = ~0;
00035       this->message_queue_.send_n ((const void *) &dummy,
00036                                     sizeof (ACE_INT32));
00037 #endif /* ACE_WIN32 */
00038       return this->close ();
00039     }
00040   return 0;
00041 }
00042 
00043 int
00044 ACE_Log_Msg_IPC::close (void)
00045 {
00046   return this->message_queue_.close ();
00047 }
00048 
00049 int
00050 ACE_Log_Msg_IPC::log (ACE_Log_Record &log_record)
00051 {
00052 #if defined (ACE_HAS_STREAM_PIPES)
00053   ACE_Str_Buf log_msg (ACE_static_cast (void *,
00054                                         &log_record),
00055                        ACE_static_cast (int,
00056                                         log_record.length ()));
00057 
00058   // Try to use the <putpmsg> API if possible in order to
00059   // ensure correct message queueing according to priority.
00060   return
00061     this->message_queue_.send
00062       (ACE_static_cast (const ACE_Str_Buf *, 0),
00063        &log_msg,
00064        ACE_static_cast (int, log_record.priority ()),
00065        MSG_BAND);
00066 #else
00067   // We're running over sockets, so we'll need to indicate the
00068   // number of bytes to send.
00069   return
00070     this->message_queue_.send_n ((void *) &log_record,
00071                                   log_record.length ());
00072 #endif /* ACE_HAS_STREAM_PIPES */
00073 }

Generated on Mon Jun 16 11:20:00 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002