FIFO_Recv.cpp

Go to the documentation of this file.
00001 // FIFO_Recv.cpp,v 4.17 2006/03/14 21:15:49 sjiang Exp
00002 
00003 #include "ace/FIFO_Recv.h"
00004 #include "ace/Log_Msg.h"
00005 #include "ace/OS_NS_fcntl.h"
00006 
00007 #if !defined (__ACE_INLINE__)
00008 #include "ace/FIFO_Recv.inl"
00009 #endif /* __ACE_INLINE__ */
00010 
00011 ACE_RCSID(ace, FIFO_Recv, "FIFO_Recv.cpp,v 4.17 2006/03/14 21:15:49 sjiang Exp")
00012 
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv)
00016 
00017 void
00018 ACE_FIFO_Recv::dump (void) const
00019 {
00020 #if defined (ACE_HAS_DUMP)
00021   ACE_TRACE ("ACE_FIFO_Recv::dump");
00022   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00023   ACE_FIFO::dump ();
00024   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("aux_handle_ = %d"), this->aux_handle_));
00025   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00026 #endif /* ACE_HAS_DUMP */
00027 }
00028 
00029 int
00030 ACE_FIFO_Recv::close (void)
00031 {
00032   ACE_TRACE ("ACE_FIFO_Recv::close");
00033   int result = ACE_FIFO::close ();
00034 
00035   if (this->aux_handle_ != ACE_INVALID_HANDLE)
00036     return ACE_OS::close (this->aux_handle_);
00037   else
00038     return result;
00039 }
00040 
00041 // Note that persistent means "open fifo for writing, as well as
00042 // reading."  This ensures that the fifo never gets EOF, even if there
00043 // aren't any writers at the moment!
00044 
00045 int
00046 ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name,
00047                      int flags,
00048                      mode_t perms,
00049                      int persistent,
00050                      LPSECURITY_ATTRIBUTES sa)
00051 {
00052   ACE_TRACE ("ACE_FIFO_Recv::open");
00053 
00054   if (ACE_FIFO::open (fifo_name, ACE_NONBLOCK | flags, perms, sa) == -1)
00055     return -1;
00056   else if (this->disable (ACE_NONBLOCK) == -1)
00057     return -1;
00058   else if (persistent
00059            && (this->aux_handle_ = ACE_OS::open (fifo_name, O_WRONLY, 0, sa)) == ACE_INVALID_HANDLE)
00060     return -1;
00061   else
00062     return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
00063 }
00064 
00065 ACE_FIFO_Recv::ACE_FIFO_Recv (void)
00066   : aux_handle_ (ACE_INVALID_HANDLE)
00067 {
00068   ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv");
00069 }
00070 
00071 ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name,
00072                               int flags,
00073                               mode_t perms,
00074                               int persistent,
00075                               LPSECURITY_ATTRIBUTES sa)
00076   : aux_handle_ (ACE_INVALID_HANDLE)
00077 {
00078   ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv");
00079 
00080   if (this->ACE_FIFO_Recv::open (fifo_name,
00081                                  flags,
00082                                  perms,
00083                                  persistent,
00084                                  sa) == -1)
00085     ACE_ERROR ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),  ACE_LIB_TEXT ("ACE_FIFO_Recv")));
00086 }
00087 
00088 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:50 2006 for ACE by doxygen 1.3.6