Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / IPC_SAP.cpp
blobbc3e9f7afe0c213f1d393c06ebfe653902810963
1 // $Id: IPC_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/IPC_SAP.h"
5 #include "ace/Log_Msg.h"
6 #include "ace/OS_NS_unistd.h"
7 #include "ace/os_include/os_signal.h"
8 #include "ace/OS_NS_errno.h"
9 #include "ace/OS_NS_fcntl.h"
11 #if !defined (__ACE_INLINE__)
12 #include "ace/IPC_SAP.inl"
13 #endif /* __ACE_INLINE__ */
15 ACE_RCSID(ace, IPC_SAP, "$Id: IPC_SAP.cpp 80826 2008-03-04 14:51:23Z wotte $")
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
21 void
22 ACE_IPC_SAP::dump (void) const
24 #if defined (ACE_HAS_DUMP)
25 ACE_TRACE ("ACE_IPC_SAP::dump");
27 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
28 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %d"), this->handle_));
29 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d"), this->pid_));
30 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
31 #endif /* ACE_HAS_DUMP */
34 // Cache for the process ID.
35 pid_t ACE_IPC_SAP::pid_ = 0;
37 // This is the do-nothing constructor. It does not perform a
38 // ACE_OS::socket system call.
40 ACE_IPC_SAP::ACE_IPC_SAP (void)
41 : handle_ (ACE_INVALID_HANDLE)
43 // ACE_TRACE ("ACE_IPC_SAP::ACE_IPC_SAP");
46 int
47 ACE_IPC_SAP::enable (int value) const
49 ACE_TRACE ("ACE_IPC_SAP::enable");
51 // First-time in initialization.
52 if (ACE_IPC_SAP::pid_ == 0)
53 ACE_IPC_SAP::pid_ = ACE_OS::getpid ();
55 #if defined (ACE_WIN32) || defined (ACE_VXWORKS)
56 switch (value)
58 case ACE_NONBLOCK:
60 // nonblocking argument (1)
61 // blocking: (0)
62 int nonblock = 1;
63 return ACE_OS::ioctl (this->handle_,
64 FIONBIO,
65 &nonblock);
67 default:
68 ACE_NOTSUP_RETURN (-1);
70 #else /* ! ACE_WIN32 && ! ACE_VXWORKS */
71 switch (value)
73 #if defined (SIGURG)
74 case SIGURG:
75 case ACE_SIGURG:
76 #if defined (F_SETOWN)
77 return ACE_OS::fcntl (this->handle_,
78 F_SETOWN,
79 ACE_IPC_SAP::pid_);
80 #else
81 ACE_NOTSUP_RETURN (-1);
82 #endif /* F_SETOWN */
83 #endif /* SIGURG */
84 #if defined (SIGIO)
85 case SIGIO:
86 case ACE_SIGIO:
87 #if defined (F_SETOWN) && defined (FASYNC)
88 if (ACE_OS::fcntl (this->handle_,
89 F_SETOWN,
90 ACE_IPC_SAP::pid_) == -1
91 || ACE::set_flags (this->handle_,
92 FASYNC) == -1)
93 return -1;
94 break;
95 #else
96 ACE_NOTSUP_RETURN (-1);
97 #endif /* F_SETOWN && FASYNC */
98 #endif /* SIGIO <== */
99 #if defined (F_SETFD)
100 case ACE_CLOEXEC:
101 // Enables the close-on-exec flag.
102 if (ACE_OS::fcntl (this->handle_,
103 F_SETFD,
104 1) == -1)
105 return -1;
106 break;
107 #endif /* F_SETFD */
108 case ACE_NONBLOCK:
109 if (ACE::set_flags (this->handle_,
110 ACE_NONBLOCK) == ACE_INVALID_HANDLE)
111 return -1;
112 break;
113 default:
114 return -1;
116 return 0;
117 #endif /* ! ACE_WIN32 && ! ACE_VXWORKS */
119 /* NOTREACHED */
123 ACE_IPC_SAP::disable (int value) const
125 ACE_TRACE ("ACE_IPC_SAP::disable");
127 #if defined (ACE_WIN32) || defined (ACE_VXWORKS)
128 switch (value)
130 case ACE_NONBLOCK:
131 // nonblocking argument (1)
132 // blocking: (0)
134 int nonblock = 0;
135 return ACE_OS::ioctl (this->handle_,
136 FIONBIO,
137 &nonblock);
139 default:
140 ACE_NOTSUP_RETURN (-1);
142 #else /* ! ACE_WIN32 && ! ACE_VXWORKS */
143 switch (value)
145 #if defined (SIGURG)
146 case SIGURG:
147 case ACE_SIGURG:
148 #if defined (F_SETOWN)
149 return ACE_OS::fcntl (this->handle_,
150 F_SETOWN,
152 #else
153 ACE_NOTSUP_RETURN (-1);
154 #endif /* F_SETOWN */
155 #endif /* SIGURG */
156 #if defined (SIGIO)
157 case SIGIO:
158 case ACE_SIGIO:
159 #if defined (F_SETOWN) && defined (FASYNC)
160 if (ACE_OS::fcntl (this->handle_,
161 F_SETOWN,
162 0) == -1
163 || ACE::clr_flags (this->handle_,
164 FASYNC) == -1)
165 return -1;
166 break;
167 #else
168 ACE_NOTSUP_RETURN (-1);
169 #endif /* F_SETOWN && FASYNC */
170 #endif /* SIGIO <== */
171 #if defined (F_SETFD)
172 case ACE_CLOEXEC:
173 // Disables the close-on-exec flag.
174 if (ACE_OS::fcntl (this->handle_,
175 F_SETFD,
176 0) == -1)
177 return -1;
178 break;
179 #endif /* F_SETFD */
180 case ACE_NONBLOCK:
181 if (ACE::clr_flags (this->handle_,
182 ACE_NONBLOCK) == -1)
183 return -1;
184 break;
185 default:
186 return -1;
188 return 0;
189 #endif /* ! ACE_WIN32 && ! ACE_VXWORKS */
190 /* NOTREACHED */
193 ACE_END_VERSIONED_NAMESPACE_DECL