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

IPC_SAP.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: IPC_SAP.cpp,v 1.1.1.3.40.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "ace/IPC_SAP.h"
00005 #include "ace/Log_Msg.h"
00006 
00007 #if defined (ACE_LACKS_INLINE_FUNCTIONS)
00008 #include "ace/IPC_SAP.i"
00009 #endif
00010 
00011 ACE_RCSID(ace, IPC_SAP, "$Id: IPC_SAP.cpp,v 1.1.1.3.40.1 2003/03/13 19:44:21 chad Exp $")
00012 
00013 ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
00014 
00015 void
00016 ACE_IPC_SAP::dump (void) const
00017 {
00018   ACE_TRACE ("ACE_IPC_SAP::dump");
00019 
00020   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00021   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("handle_ = %d"), this->handle_));
00022   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %d"), this->pid_));
00023   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00024 }
00025 
00026 // Cache for the process ID.
00027 pid_t ACE_IPC_SAP::pid_ = 0;
00028 
00029 // This is the do-nothing constructor.  It does not perform a
00030 // ACE_OS::socket system call.
00031 
00032 ACE_IPC_SAP::ACE_IPC_SAP (void)
00033   : handle_ (ACE_INVALID_HANDLE)
00034 {
00035   // ACE_TRACE ("ACE_IPC_SAP::ACE_IPC_SAP");
00036 }
00037 
00038 int
00039 ACE_IPC_SAP::enable (int value) const
00040 {
00041   ACE_TRACE ("ACE_IPC_SAP::enable");
00042 
00043   // First-time in initialization.
00044   if (ACE_IPC_SAP::pid_ == 0)
00045     ACE_IPC_SAP::pid_ = ACE_OS::getpid ();
00046 
00047 #if defined (ACE_WIN32) || defined (VXWORKS)
00048   switch (value)
00049     {
00050     case ACE_NONBLOCK:
00051       {
00052         // nonblocking argument (1)
00053         // blocking:            (0)
00054         u_long nonblock = 1;
00055         return ACE_OS::ioctl (this->handle_,
00056                               FIONBIO,
00057                               &nonblock);
00058       }
00059     default:
00060       ACE_NOTSUP_RETURN (-1);
00061     }
00062 #else  /* ! ACE_WIN32 && ! VXWORKS */
00063   switch (value)
00064     {
00065 #if defined (SIGURG)
00066     case SIGURG:
00067     case ACE_SIGURG:
00068 #if defined (F_SETOWN)
00069       return ACE_OS::fcntl (this->handle_,
00070                             F_SETOWN,
00071                             ACE_IPC_SAP::pid_);
00072 #else
00073       ACE_NOTSUP_RETURN (-1);
00074 #endif /* F_SETOWN */
00075 #endif /* SIGURG */
00076 #if defined (SIGIO)
00077     case SIGIO:
00078     case ACE_SIGIO:
00079 #if defined (F_SETOWN) && defined (FASYNC)
00080       if (ACE_OS::fcntl (this->handle_,
00081                          F_SETOWN,
00082                          ACE_IPC_SAP::pid_) == -1
00083           || ACE_Flag_Manip::set_flags (this->handle_,
00084                                         FASYNC) == -1)
00085         return -1;
00086       break;
00087 #else
00088       ACE_NOTSUP_RETURN (-1);
00089 #endif /* F_SETOWN && FASYNC */
00090 #endif /* SIGIO <== */
00091 #if defined (F_SETFD)
00092     case ACE_CLOEXEC:
00093       // Enables the close-on-exec flag.
00094       if (ACE_OS::fcntl (this->handle_,
00095                          F_SETFD,
00096                          1) == -1)
00097         return -1;
00098       break;
00099 #endif /* F_SETFD */
00100     case ACE_NONBLOCK:
00101       if (ACE_Flag_Manip::set_flags (this->handle_,
00102                                      ACE_NONBLOCK) == ACE_INVALID_HANDLE)
00103         return -1;
00104       break;
00105     default:
00106       return -1;
00107     }
00108   return 0;
00109 #endif /* ! ACE_WIN32 && ! VXWORKS */
00110 
00111   /* NOTREACHED */
00112 }
00113 
00114 int
00115 ACE_IPC_SAP::disable (int value) const
00116 {
00117   ACE_TRACE ("ACE_IPC_SAP::disable");
00118 
00119 #if defined (ACE_WIN32) || defined (VXWORKS)
00120   switch (value)
00121     {
00122     case ACE_NONBLOCK:
00123       // nonblocking argument (1)
00124       // blocking:            (0)
00125       {
00126         u_long nonblock = 0;
00127         return ACE_OS::ioctl (this->handle_,
00128                               FIONBIO,
00129                               &nonblock);
00130       }
00131     default:
00132       ACE_NOTSUP_RETURN (-1);
00133     }
00134 #else  /* ! ACE_WIN32 && ! VXWORKS */
00135   switch (value)
00136     {
00137 #if defined (SIGURG)
00138     case SIGURG:
00139     case ACE_SIGURG:
00140 #if defined (F_SETOWN)
00141       return ACE_OS::fcntl (this->handle_,
00142                             F_SETOWN,
00143                             0);
00144 #else
00145       ACE_NOTSUP_RETURN (-1);
00146 #endif /* F_SETOWN */
00147 #endif /* SIGURG */
00148 #if defined (SIGIO)
00149     case SIGIO:
00150     case ACE_SIGIO:
00151 #if defined (F_SETOWN) && defined (FASYNC)
00152       if (ACE_OS::fcntl (this->handle_,
00153                          F_SETOWN,
00154                          0) == -1
00155           || ACE_Flag_Manip::clr_flags (this->handle_,
00156                                         FASYNC) == -1)
00157         return -1;
00158       break;
00159 #else
00160       ACE_NOTSUP_RETURN (-1);
00161 #endif /* F_SETOWN && FASYNC */
00162 #endif /* SIGIO <== */
00163 #if defined (F_SETFD)
00164     case ACE_CLOEXEC:
00165       // Disables the close-on-exec flag.
00166       if (ACE_OS::fcntl (this->handle_,
00167                          F_SETFD,
00168                          0) == -1)
00169         return -1;
00170       break;
00171 #endif /* F_SETFD */
00172     case ACE_NONBLOCK:
00173       if (ACE_Flag_Manip::clr_flags (this->handle_,
00174                                      ACE_NONBLOCK) == -1)
00175         return -1;
00176       break;
00177     default:
00178       return -1;
00179     }
00180   return 0;
00181 #endif /* ! ACE_WIN32 && ! VXWORKS */
00182   /* NOTREACHED */
00183 }

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