Classes | |
struct | If_Then_Else< true, Ta, Tb > |
struct | If_Then_Else< false, Ta, Tb > |
struct | VP_traits |
Value_Ptr traits template structure. More... | |
class | Value_Ptr |
Smart pointer implementation designed for use as a class member. More... | |
struct | If_Then_Else |
Compile-time selection of type based on a boolean value. More... | |
I/O operations | |
Notes on common parameters: handle is the connected endpoint that will be used for I/O. buf is the buffer to write from or receive into. len is the number of bytes to transfer.
The timeout parameter in the following methods indicates how long to blocking trying to transfer data. If timeout == 0, then the call behaves as a normal send/recv call, i.e., for blocking sockets, the call will block until action is possible; for non-blocking sockets, If timeout != 0, the call will wait until the relative time specified in *timeout elapses.
The "_n()" I/O methods keep looping until all the data has been transferred. These methods also work for sockets in non-blocking mode i.e., they keep looping on The return values for the "*_n()" methods match the return values from the non "_n()" methods and are specified as follows:
On partial transfers, i.e., if any data is transferred before timeout / error / Methods with iovec parameter are I/O vector variants of the I/O operations.
Methods with the extra flags argument will always result in | |
ACE_Export ssize_t | recv (ACE_HANDLE handle, void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | t_rcv (ACE_HANDLE handle, void *buf, size_t len, int *flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | recv (ACE_HANDLE handle, void *buf, size_t len, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | recvfrom (ACE_HANDLE handle, char *buf, int len, int flags, struct sockaddr *addr, int *addrlen, const ACE_Time_Value *timeout=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | recv_n (ACE_HANDLE handle, void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | t_rcv_n (ACE_HANDLE handle, void *buf, size_t len, int *flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | recv_n (ACE_HANDLE handle, void *buf, size_t len, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_Export ssize_t | recv (ACE_HANDLE handle, size_t n,...) |
Receive into a variable number of pieces. | |
ACE_Export ssize_t | recvv (ACE_HANDLE handle, iovec *iov, int iovcnt, const ACE_Time_Value *timeout=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | recvv_n (ACE_HANDLE handle, iovec *iov, int iovcnt, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_Export ssize_t | recv_n (ACE_HANDLE handle, ACE_Message_Block *message_block, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_Export ssize_t | send (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | t_snd (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | send (ACE_HANDLE handle, const void *buf, size_t len, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags, const ACE_Time_Value *timeout=0) |
ACE_Export ssize_t | sendto (ACE_HANDLE handle, const char *buf, int len, int flags, const struct sockaddr *addr, int addrlen, const ACE_Time_Value *timeout=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | send_n (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | t_snd_n (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | send_n (ACE_HANDLE handle, const void *buf, size_t len, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_Export ssize_t | send (ACE_HANDLE handle, size_t n,...) |
Varargs variant. | |
ACE_Export ssize_t | sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt, const ACE_Time_Value *timeout=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | sendv_n (ACE_HANDLE handle, const iovec *iov, int iovcnt, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_Export ssize_t | send_n (ACE_HANDLE handle, const ACE_Message_Block *message_block, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | read_n (ACE_HANDLE handle, void *buf, size_t len, size_t *bytes_transferred=0) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | write_n (ACE_HANDLE handle, const void *buf, size_t len, size_t *bytes_transferred=0) |
ACE_Export ssize_t | write_n (ACE_HANDLE handle, const ACE_Message_Block *message_block, size_t *bytes_transferred=0) |
ACE_Export ssize_t | readv_n (ACE_HANDLE handle, iovec *iov, int iovcnt, size_t *bytes_transferred=0) |
ACE_Export ssize_t | writev_n (ACE_HANDLE handle, const iovec *iov, int iovcnt, size_t *bytes_transferred=0) |
Functions | |
ACE_Export u_int | major_version (void) |
e.g., the "5" in ACE 5.1.12. | |
ACE_Export u_int | minor_version (void) |
e.g., the "1" in ACE 5.1.12. | |
ACE_Export u_int | beta_version (void) |
ACE_Export const ACE_TCHAR * | compiler_name (void) |
E.g., the "SunPro C++" in SunPro C++ 4.32.0. | |
ACE_Export u_int | compiler_major_version (void) |
E.g., the "4" in SunPro C++ 4.32.0. | |
ACE_Export u_int | compiler_minor_version (void) |
E.g., the "32" in SunPro C++ 4.32.0. | |
ACE_Export u_int | compiler_beta_version (void) |
E.g., the "0" in SunPro C++ 4.32.0. | |
ACE_Export int | out_of_handles (int error) |
ACE_Export bool | wild_match (const char *s, const char *pattern, bool case_sensitive=true) |
ACE_Export int | handle_timed_accept (ACE_HANDLE listener, ACE_Time_Value *timeout, int restart) |
ACE_Export ACE_HANDLE | handle_timed_complete (ACE_HANDLE listener, const ACE_Time_Value *timeout, int is_tli=0) |
ACE_Export int | set_handle_limit (int new_limit=-1, int increase_limit_only=0) |
ACE_Export int | max_handles (void) |
ACE_Export ACE_TCHAR * | strenvdup (const ACE_TCHAR *str) |
ACE_Export const char * | strend (const char *s) |
ACE_Export char * | strnew (const char *s) |
ACE_NAMESPACE_INLINE_FUNCTION void | strdelete (char *s) |
Delete the memory allocated by strnew . | |
ACE_Export char * | strndup (const char *str, size_t n) |
ACE_Export char * | strnnew (const char *str, size_t n) |
ACE_Export const wchar_t * | strend (const wchar_t *s) |
ACE_Export wchar_t * | strnew (const wchar_t *s) |
ACE_NAMESPACE_INLINE_FUNCTION void | strdelete (wchar_t *s) |
ACE_Export wchar_t * | strndup (const wchar_t *str, size_t n) |
ACE_Export wchar_t * | strnnew (const wchar_t *str, size_t n) |
ACE_Export const ACE_TCHAR * | execname (const ACE_TCHAR *pathname) |
ACE_Export const ACE_TCHAR * | basename (const ACE_TCHAR *pathname, ACE_TCHAR delim=ACE_DIRECTORY_SEPARATOR_CHAR) |
ACE_Export const ACE_TCHAR * | dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim=ACE_DIRECTORY_SEPARATOR_CHAR) |
ACE_Export ACE_TCHAR * | timestamp (ACE_TCHAR date_and_time[], int time_len, int return_pointer_to_first_digit=0) |
ACE_Export pid_t | fork (const ACE_TCHAR *program_name=ACE_LIB_TEXT("< unknown >"), int avoid_zombies=0) |
ACE_Export int | daemonize (const ACE_TCHAR pathname[]=ACE_LIB_TEXT("/"), int close_all_handles=ACE_DEFAULT_CLOSE_ALL_HANDLES, const ACE_TCHAR program_name[]=ACE_LIB_TEXT("< unknown >")) |
ACE_Export size_t | round_to_pagesize (off_t len) |
Rounds the request to a multiple of the page size. | |
ACE_Export size_t | round_to_allocation_granularity (off_t len) |
Rounds the request to a multiple of the allocation granularity. | |
ACE_Export size_t | format_hexdump (const char *buffer, size_t size, ACE_TCHAR *obuf, size_t obuf_sz) |
ACE_Export u_long | hash_pjw (const char *str) |
Computes the hash value of {str} using the "Hash PJW" routine. | |
ACE_Export u_long | hash_pjw (const char *str, size_t len) |
Computes the hash value of {str} using the "Hash PJW" routine. | |
ACE_Export u_long | hash_pjw (const wchar_t *str) |
Computes the hash value of {str} using the "Hash PJW" routine. | |
ACE_Export u_long | hash_pjw (const wchar_t *str, size_t len) |
Computes the hash value of {str} using the "Hash PJW" routine. | |
ACE_Export ACE_UINT16 | crc_ccitt (const char *str) |
Computes CRC-CCITT for the string. | |
ACE_Export ACE_UINT16 | crc_ccitt (const void *buf, size_t len, ACE_UINT16 crc=0) |
Computes CRC-CCITT for the buffer. | |
ACE_Export ACE_UINT16 | crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc=0) |
Computes CRC-CCITT for the @ len iovec buffers. | |
ACE_Export ACE_UINT32 | crc32 (const char *str) |
Computes the ISO 8802-3 standard 32 bits CRC for the string. | |
ACE_Export ACE_UINT32 | crc32 (const void *buf, size_t len, ACE_UINT32 crc=0) |
Computes the ISO 8802-3 standard 32 bits CRC for the buffer. | |
ACE_Export ACE_UINT32 | crc32 (const iovec *iov, int len, ACE_UINT32 crc=0) |
ACE_Export u_long | gcd (u_long x, u_long y) |
Euclid's greatest common divisor algorithm. | |
ACE_Export u_long | minimum_frame_size (u_long period1, u_long period2) |
Calculates the minimum enclosing frame size for the given values. | |
ACE_Export u_long | is_prime (const u_long n, const u_long min_factor, const u_long max_factor) |
ACE_Export int | map_errno (int error) |
ACE_Export const ACE_TCHAR * | sock_error (int error) |
ACE_Export bool | is_sock_error (int error) |
ACE_Export int | process_active (pid_t pid) |
ACE_Export int | terminate_process (pid_t pid) |
ACE_NAMESPACE_INLINE_FUNCTION void | unique_name (const void *object, ACE_TCHAR *name, size_t length) |
ACE_NAMESPACE_INLINE_FUNCTION u_long | log2 (u_long num) |
Computes the base 2 logarithm of {num}. | |
ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR | nibble2hex (u_int n) |
Hex conversion utility. | |
ACE_NAMESPACE_INLINE_FUNCTION u_char | hex2byte (ACE_TCHAR c) |
Convert a hex character to its byte representation. | |
ACE_Export char | debug (void) |
ACE_Export void | debug (char d) |
ACE_Export int | select (int width, ACE_Handle_Set *readfds, ACE_Handle_Set *writefds=0, ACE_Handle_Set *exceptfds=0, const ACE_Time_Value *timeout=0) |
Wrapper facade for select that uses ACE_Handle_Sets . | |
ACE_Export int | select (int width, ACE_Handle_Set &readfds, const ACE_Time_Value *timeout=0) |
ACE_NAMESPACE_INLINE_FUNCTION int | handle_read_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) |
Timed wait for handle to get read ready. | |
ACE_NAMESPACE_INLINE_FUNCTION int | handle_write_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) |
Timed wait for handle to get write ready. | |
ACE_NAMESPACE_INLINE_FUNCTION int | handle_exception_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout) |
Timed wait for handle to get exception ready. | |
ACE_Export int | handle_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout, int read_ready, int write_ready, int exception_ready) |
Timed wait for handle to get read, write, or exception ready. | |
ACE_Export int | enter_recv_timedwait (ACE_HANDLE handle, const ACE_Time_Value *timeout, int &val) |
ACE_Export int | enter_send_timedwait (ACE_HANDLE handle, const ACE_Time_Value *timeout, int &val) |
ACE_Export void | record_and_set_non_blocking_mode (ACE_HANDLE handle, int &val) |
ACE_Export void | restore_non_blocking_mode (ACE_HANDLE handle, int val) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | recv_i (ACE_HANDLE handle, void *buf, size_t len) |
ACE_Export ssize_t | recv_n_i (ACE_HANDLE handle, void *buf, size_t len, int flags, size_t *bytes_transferred) |
ACE_Export ssize_t | recv_n_i (ACE_HANDLE handle, void *buf, size_t len, int flags, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | t_rcv_n_i (ACE_HANDLE handle, void *buf, size_t len, int *flags, size_t *bytes_transferred) |
ACE_Export ssize_t | t_rcv_n_i (ACE_HANDLE handle, void *buf, size_t len, int *flags, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | recv_n_i (ACE_HANDLE handle, void *buf, size_t len, size_t *bytes_transferred) |
ACE_Export ssize_t | recv_n_i (ACE_HANDLE handle, void *buf, size_t len, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | recvv_n_i (ACE_HANDLE handle, iovec *iov, int iovcnt, size_t *bytes_transferred) |
ACE_Export ssize_t | recvv_n_i (ACE_HANDLE handle, iovec *iov, int iovcnt, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_NAMESPACE_INLINE_FUNCTION ssize_t | send_i (ACE_HANDLE handle, const void *buf, size_t len) |
ACE_Export ssize_t | send_n_i (ACE_HANDLE handle, const void *buf, size_t len, int flags, size_t *bytes_transferred) |
ACE_Export ssize_t | send_n_i (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | t_snd_n_i (ACE_HANDLE handle, const void *buf, size_t len, int flags, size_t *bytes_transferred) |
ACE_Export ssize_t | t_snd_n_i (ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | send_n_i (ACE_HANDLE handle, const void *buf, size_t len, size_t *bytes_transferred) |
ACE_Export ssize_t | send_n_i (ACE_HANDLE handle, const void *buf, size_t len, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export ssize_t | sendv_n_i (ACE_HANDLE handle, const iovec *iov, int iovcnt, size_t *bytes_transferred) |
ACE_Export ssize_t | sendv_n_i (ACE_HANDLE handle, const iovec *iov, int iovcnt, const ACE_Time_Value *timeout, size_t *bytes_transferred) |
ACE_Export int | set_flags (ACE_HANDLE handle, int flags) |
Set flags associated with handle. | |
ACE_Export int | clr_flags (ACE_HANDLE handle, int flags) |
Clear flags associated with handle. | |
ACE_NAMESPACE_INLINE_FUNCTION int | get_flags (ACE_HANDLE handle) |
Return the current setting of flags associated with handle. | |
ACE_Export ACE_HANDLE | handle_timed_open (ACE_Time_Value *timeout, const ACE_TCHAR *name, int flags, int perms, LPSECURITY_ATTRIBUTES sa=0) |
ACE_Export int | init (void) |
ACE_Export int | fini (void) |
ACE_Export int | ldfind (const ACE_TCHAR *filename, ACE_TCHAR pathname[], size_t maxpathnamelen) |
ACE_Export FILE * | ldopen (const ACE_TCHAR *filename, const ACE_TCHAR *type) |
ACE_Export ACE_TCHAR * | ldname (const ACE_TCHAR *entry_point) |
ACE_Export int | get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len) |
ACE_Export ACE_HANDLE | open_temp_file (const ACE_TCHAR *name, int mode, int perm=0) |
ACE_Export size_t | strrepl (char *s, char search, char replace) |
ACE_Export char * | strsplit_r (char *s, const char *token, char *&next_start) |
ACE_Export size_t | strrepl (wchar_t *s, wchar_t search, wchar_t replace) |
As strrepl, but for wide characters. | |
ACE_Export wchar_t * | strsplit_r (wchar_t *s, const wchar_t *token, wchar_t *&next_start) |
As strsplit_r, but for wide characters. | |
ACE_Export int | bind_port (ACE_HANDLE handle, ACE_UINT32 ip_addr=INADDR_ANY, int address_family=AF_UNSPEC) |
Bind a new unused port to handle. | |
ACE_Export int | get_bcast_addr (ACE_UINT32 &bcast_addr, const ACE_TCHAR *hostname=0, ACE_UINT32 host_addr=0, ACE_HANDLE handle=ACE_INVALID_HANDLE) |
ACE_Export int | get_ip_interfaces (size_t &count, ACE_INET_Addr *&addr_array) |
ACE_Export int | count_interfaces (ACE_HANDLE handle, size_t &how_many) |
ACE_Export ACE_HANDLE | get_handle (void) |
ACE_Export int | ipv6_enabled (void) |
Variables | |
size_t | allocation_granularity_ = 0 |
size_t | pagesize_ = 0 |
char | debug_ |
unsigned int | init_fini_count_ = 0 |
The ACE namespace contains all types (classes, structures, typedefs, etc), and global functions and variables in the ACE framework.
|
Returns the "basename" of a pathname separated by delim. For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when delim is '/'. Definition at line 406 of file ACE.cpp. References ACE_TCHAR, ACE_TRACE, and ACE_OS::strrchr(). Referenced by ACE_MT_MEM_IO::init(), and ACE_Name_Options::process_name().
00407 { 00408 ACE_TRACE ("ACE::basename"); 00409 const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); 00410 00411 if (temp == 0) 00412 return pathname; 00413 else 00414 return temp + 1; 00415 } |
|
e.g., the "12" in ACE 5.1.12. Returns 0 for "stable" (non-beta) releases. Definition at line 119 of file ACE.cpp. References ACE_BETA_VERSION.
00120 { 00121 return ACE_BETA_VERSION; 00122 } |
|
Bind a new unused port to handle.
Definition at line 284 of file Sock_Connect.cpp. References ACE_INET_Addr, ACE_MAX_DEFAULT_PORT, ACE_TRACE, ACE_OS::bind(), EADDRINUSE, ACE_INET_Addr::get_addr(), ACE_Addr::get_size(), IPPORT_RESERVED, and ACE_INET_Addr::set(). Referenced by ACE_SOCK_CODgram::open(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_SOCK_Dgram::shared_open(), ACE_SOCK_Acceptor::shared_open(), and ACE_ICMP_Socket::shared_open().
00285 { 00286 ACE_TRACE ("ACE::bind_port"); 00287 00288 ACE_INET_Addr addr; 00289 00290 #if defined (ACE_HAS_IPV6) 00291 if (address_family != PF_INET6) 00292 // What do we do if it is PF_"INET6? Since it's 4 bytes, it must be an 00293 // IPV4 address. Is there a difference? Why is this test done? dhinton 00294 #else /* ACE_HAS_IPV6 */ 00295 ACE_UNUSED_ARG (address_family); 00296 #endif /* !ACE_HAS_IPV6 */ 00297 addr = ACE_INET_Addr ((u_short)0, ip_addr); 00298 #if defined (ACE_HAS_IPV6) 00299 else if (ip_addr != INADDR_ANY) 00300 // address_family == PF_INET6 and a non default IP address means to bind 00301 // to the IPv4-mapped IPv6 address 00302 addr.set ((u_short)0, ip_addr, 1, 1); 00303 #endif /* ACE_HAS_IPV6 */ 00304 00305 #if !defined (ACE_LACKS_WILDCARD_BIND) 00306 // The OS kernel should select a free port for us. 00307 return ACE_OS::bind (handle, 00308 (sockaddr*)addr.get_addr(), 00309 addr.get_size()); 00310 #else 00311 static u_short upper_limit = ACE_MAX_DEFAULT_PORT; 00312 int round_trip = upper_limit; 00313 int lower_limit = IPPORT_RESERVED; 00314 00315 // We have to select the port explicitly. 00316 00317 for (;;) 00318 { 00319 addr.set((u_short)upper_limit,ip_addr); 00320 00321 if (ACE_OS::bind (handle, 00322 (sockaddr*)addr.get_addr() 00323 addr.get_size()) >= 0) 00324 { 00325 #if defined (ACE_WIN32) 00326 upper_limit--; 00327 #endif /* ACE_WIN32 */ 00328 return 0; 00329 } 00330 else if (errno != EADDRINUSE) 00331 return -1; 00332 else 00333 { 00334 upper_limit--; 00335 00336 // Wrap back around when we reach the bottom. 00337 if (upper_limit <= lower_limit) 00338 upper_limit = ACE_MAX_DEFAULT_PORT; 00339 00340 // See if we have already gone around once! 00341 if (upper_limit == round_trip) 00342 { 00343 errno = EAGAIN; 00344 return -1; 00345 } 00346 } 00347 } 00348 #endif /* ACE_HAS_WILDCARD_BIND */ 00349 } |
|
Clear flags associated with handle.
Definition at line 62 of file Flag_Manip.cpp. References ACE_CLR_BITS, ACE_NONBLOCK, ACE_NOTSUP_RETURN, ACE_TRACE, F_GETFL, ACE_OS::fcntl(), and ACE_OS::ioctl(). Referenced by ACE_IPC_SAP::disable(), ACE_IO_SAP::disable(), restore_non_blocking_mode(), ACE_SOCK_SEQPACK_Acceptor::shared_accept_finish(), ACE_SOCK_Acceptor::shared_accept_finish(), and ACE_MEM_Acceptor::shared_accept_finish().
00063 { 00064 ACE_TRACE ("ACE::clr_flags"); 00065 00066 #if defined (ACE_LACKS_FCNTL) 00067 switch (flags) 00068 { 00069 case ACE_NONBLOCK: 00070 // nonblocking argument (1) 00071 // blocking: (0) 00072 { 00073 int nonblock = 0; 00074 return ACE_OS::ioctl (handle, FIONBIO, &nonblock); 00075 } 00076 default: 00077 ACE_NOTSUP_RETURN (-1); 00078 } 00079 #else 00080 int val = ACE_OS::fcntl (handle, F_GETFL, 0); 00081 00082 if (val == -1) 00083 return -1; 00084 00085 // Turn flags off. 00086 ACE_CLR_BITS (val, flags); 00087 00088 if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) 00089 return -1; 00090 else 00091 return 0; 00092 #endif /* ACE_LACKS_FCNTL */ 00093 } |
|
E.g., the "0" in SunPro C++ 4.32.0.
Definition at line 155 of file ACE.cpp.
00156 { 00157 #ifdef ACE_CC_BETA_VERSION 00158 return ACE_CC_BETA_VERSION; 00159 #else 00160 return 0; 00161 #endif 00162 } |
|
E.g., the "4" in SunPro C++ 4.32.0.
Definition at line 135 of file ACE.cpp.
00136 { 00137 #ifdef ACE_CC_MAJOR_VERSION 00138 return ACE_CC_MAJOR_VERSION; 00139 #else 00140 return 0; 00141 #endif 00142 } |
|
E.g., the "32" in SunPro C++ 4.32.0.
Definition at line 145 of file ACE.cpp.
00146 { 00147 #ifdef ACE_CC_MINOR_VERSION 00148 return ACE_CC_MINOR_VERSION; 00149 #else 00150 return 0; 00151 #endif 00152 } |
|
E.g., the "SunPro C++" in SunPro C++ 4.32.0.
Definition at line 125 of file ACE.cpp. References ACE_LIB_TEXT.
00126 { 00127 #ifdef ACE_CC_NAME 00128 return ACE_CC_NAME; 00129 #else 00130 return ACE_LIB_TEXT (""); 00131 #endif 00132 } |
|
Helper routine for get_ip_interfaces, differs by UNIX platform so put into own subroutine. perform some ioctls to retrieve ifconf list of ifreq structs. Definition at line 1345 of file Sock_Connect.cpp. References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NOTSUP_RETURN, caddr_t, ACE_OS::fclose(), ACE_OS::fopen(), ACE_OS::free(), ACE_OS::ioctl(), LM_ERROR, ACE_OS::malloc(), and ACE_OS::memset(). Referenced by get_ip_interfaces().
01346 { 01347 #if defined (sparc) && defined (SIOCGIFNUM) 01348 int tmp_how_many; // For 64 bit Solaris 01349 if (ACE_OS::ioctl (handle, 01350 SIOCGIFNUM, 01351 (caddr_t) &tmp_how_many) == -1) 01352 ACE_ERROR_RETURN ((LM_ERROR, 01353 ACE_LIB_TEXT ("%p\n"), 01354 ACE_LIB_TEXT ("ACE::count_interfaces:") 01355 ACE_LIB_TEXT ("ioctl - SIOCGIFNUM failed")), 01356 -1); 01357 how_many = (size_t) tmp_how_many; 01358 return 0; 01359 #elif defined (ACE_HAS_GETIFADDRS) 01360 ACE_UNUSED_ARG (handle); 01361 01362 struct ifaddrs *ifap; 01363 struct ifaddrs *p_if; 01364 01365 if (::getifaddrs (&ifap) != 0) 01366 return -1; 01367 01368 // Count number of interfaces. 01369 size_t num_ifs = 0; 01370 for (p_if = ifap; p_if != 0; p_if = p_if->ifa_next) 01371 ++num_ifs; 01372 01373 ::freeifaddrs (ifap); 01374 01375 how_many = num_ifs; 01376 return 0; 01377 #elif defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (_AIX) || defined (ACE_OPENVMS) 01378 // Note: DEC CXX doesn't define "unix". BSD compatible OS: HP UX, 01379 // AIX, SunOS 4.x perform some ioctls to retrieve ifconf list of 01380 // ifreq structs no SIOCGIFNUM on SunOS 4.x, so use guess and scan 01381 // algorithm 01382 01383 // Probably hard to put this many ifs in a unix box.. 01384 const int MAX_IF = 50; 01385 01386 // HACK - set to an unreasonable number 01387 int num_ifs = MAX_IF; 01388 01389 struct ifconf ifcfg; 01390 size_t ifreq_size = num_ifs * sizeof (struct ifreq); 01391 struct ifreq *p_ifs = 01392 (struct ifreq *) ACE_OS::malloc (ifreq_size); 01393 01394 if (!p_ifs) 01395 { 01396 errno = ENOMEM; 01397 return -1; 01398 } 01399 01400 ACE_OS::memset (p_ifs, 0, ifreq_size); 01401 ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); 01402 01403 ifcfg.ifc_req = p_ifs; 01404 ifcfg.ifc_len = ifreq_size; 01405 01406 #if defined (AIX) 01407 int cmd = CSIOCGIFCONF; 01408 #else 01409 int cmd = SIOCGIFCONF; 01410 #endif /* AIX */ 01411 if (ACE_OS::ioctl (handle, 01412 cmd, 01413 (caddr_t) &ifcfg) == -1) 01414 { 01415 ACE_OS::free (ifcfg.ifc_req); 01416 ACE_ERROR_RETURN ((LM_ERROR, 01417 ACE_LIB_TEXT ("%p\n"), 01418 ACE_LIB_TEXT ("ACE::count_interfaces:") 01419 ACE_LIB_TEXT ("ioctl - SIOCGIFCONF failed")), 01420 -1); 01421 } 01422 01423 int if_count = 0, i; 01424 01425 // get if address out of ifreq buffers. ioctl puts a blank-named 01426 // interface to mark the end of the returned interfaces. 01427 for (i = 0; 01428 i < num_ifs; 01429 i++) 01430 { 01431 /* In OpenBSD, the length of the list is returned. */ 01432 ifcfg.ifc_len -= sizeof (struct ifreq); 01433 if (ifcfg.ifc_len < 0) 01434 break; 01435 01436 if_count++; 01437 #if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) 01438 p_ifs++; 01439 #else 01440 if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr)) 01441 { 01442 p_ifs++; 01443 } 01444 else 01445 { 01446 p_ifs = (struct ifreq *) 01447 (p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr); 01448 } 01449 #endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ 01450 } 01451 01452 ACE_OS::free (ifcfg.ifc_req); 01453 01454 # if defined (ACE_HAS_IPV6) 01455 FILE* fp; 01456 01457 if ((fp = ACE_OS::fopen (ACE_LIB_TEXT ("/proc/net/if_inet6"), ACE_LIB_TEXT ("r"))) != NULL) 01458 { 01459 // Scan the lines according to the expected format but don't really read any input 01460 while (fscanf (fp, "%*32s %*02x %*02x %*02x %*02x %*8s\n") != EOF) 01461 { 01462 if_count++; 01463 } 01464 ACE_OS::fclose (fp); 01465 } 01466 # endif /* ACE_HAS_IPV6 */ 01467 01468 how_many = if_count; 01469 return 0; 01470 #else 01471 ACE_UNUSED_ARG (handle); 01472 ACE_UNUSED_ARG (how_many); 01473 ACE_NOTSUP_RETURN (-1); // no implementation 01474 #endif /* sparc && SIOCGIFNUM */ 01475 } |
|
Computes the ISO 8802-3 standard 32 bits CRC for the @ len iovec buffers. Definition at line 142 of file ACE_crc32.cpp. References COMPUTE, iovec::iov_base, and iovec::iov_len.
|
|
Computes the ISO 8802-3 standard 32 bits CRC for the buffer.
Definition at line 126 of file ACE_crc32.cpp. References COMPUTE.
00127 { 00128 crc = ~crc; 00129 00130 for (const char *p = (const char *) buffer, 00131 *e = (const char *) buffer + len; 00132 p != e; 00133 ++p) 00134 { 00135 COMPUTE (crc, *p); 00136 } 00137 00138 return ~crc; 00139 } |
|
Computes the ISO 8802-3 standard 32 bits CRC for the string.
Definition at line 111 of file ACE_crc32.cpp. References COMPUTE. Referenced by ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool(), and ACE_SV_Semaphore_Simple::name_2_key().
00112 { 00113 ACE_UINT32 crc = 0xFFFFFFFF; 00114 00115 for (const char *p = string; 00116 *p != 0; 00117 ++p) 00118 { 00119 COMPUTE (crc, *p); 00120 } 00121 00122 return ~crc; 00123 } |
|
Computes CRC-CCITT for the @ len iovec buffers.
Definition at line 109 of file ACE_crc_ccitt.cpp. References COMPUTE, iovec::iov_base, and iovec::iov_len.
|
|
Computes CRC-CCITT for the buffer.
Definition at line 93 of file ACE_crc_ccitt.cpp. References COMPUTE.
00094 { 00095 crc = ~crc; 00096 00097 for (const char *p = (const char *) buffer, 00098 *e = (const char *) buffer + len; 00099 p != e; 00100 ++p) 00101 { 00102 COMPUTE (crc, *p); 00103 } 00104 00105 return ~crc; 00106 } |
|
Computes CRC-CCITT for the string.
Definition at line 78 of file ACE_crc_ccitt.cpp. References COMPUTE.
00079 { 00080 ACE_UINT16 crc = 0xFFFF; 00081 00082 for (const char *p = string; 00083 *p != 0; 00084 ++p) 00085 { 00086 COMPUTE (crc, *p); 00087 } 00088 00089 return ~crc; 00090 } |
|
Become a daemon process using the algorithm in Richard Stevens "Advanced Programming in the UNIX Environment." If close_all_handles is non-zero then all open file handles are closed. Definition at line 2808 of file ACE.cpp. References ACE_NOTSUP_RETURN, ACE_TCHAR, ACE_TRACE, ACE_OS::chdir(), ACE_OS::close(), ACE_OS::exit(), ACE_OS::fork(), max_handles(), pid_t, ACE_OS::setsid(), SIG_IGN, SIGHUP, ACE_OS::signal(), and ACE_OS::umask(). Referenced by ACE_Service_Config::open_i().
02811 { 02812 ACE_TRACE ("ACE::daemonize"); 02813 #if !defined (ACE_LACKS_FORK) 02814 pid_t pid = ACE_OS::fork (); 02815 02816 if (pid == -1) 02817 return -1; 02818 else if (pid != 0) 02819 ACE_OS::exit (0); // Parent exits. 02820 02821 // 1st child continues. 02822 ACE_OS::setsid (); // Become session leader. 02823 02824 ACE_OS::signal (SIGHUP, SIG_IGN); 02825 02826 pid = ACE_OS::fork (program_name); 02827 02828 if (pid != 0) 02829 ACE_OS::exit (0); // First child terminates. 02830 02831 // Second child continues. 02832 02833 if (pathname != 0) 02834 // change working directory. 02835 ACE_OS::chdir (pathname); 02836 02837 ACE_OS::umask (0); // clear our file mode creation mask. 02838 02839 // Close down the I/O handles. 02840 if (close_all_handles) 02841 for (int i = ACE::max_handles () - 1; i >= 0; i--) 02842 ACE_OS::close (i); 02843 02844 return 0; 02845 #else 02846 ACE_UNUSED_ARG (pathname); 02847 ACE_UNUSED_ARG (close_all_handles); 02848 ACE_UNUSED_ARG (program_name); 02849 02850 ACE_NOTSUP_RETURN (-1); 02851 #endif /* ACE_LACKS_FORK */ 02852 } |
|
Definition at line 172 of file ACE.cpp.
00173 { 00174 ACE::debug_ = c; 00175 } |
|
|
Returns the "dirname" of a pathname. For instance, the dirname of "/tmp/foo.cpp" is "/tmp" when delim is '/'. If pathname has no delim ".\0" is returned. This method does not modify pathname and is not reentrant. Definition at line 418 of file ACE.cpp. References ACE_TCHAR, ACE_TRACE, MAXPATHLEN, ACE_OS::strrchr(), and ACE_OS::strsncpy().
00419 { 00420 ACE_TRACE ("ACE::dirname"); 00421 static ACE_TCHAR return_dirname[MAXPATHLEN + 1]; 00422 00423 const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); 00424 00425 if (temp == 0) 00426 { 00427 return_dirname[0] = '.'; 00428 return_dirname[1] = '\0'; 00429 00430 return return_dirname; 00431 } 00432 else 00433 { 00434 // When the len is truncated, there are problems! This should 00435 // not happen in normal circomstances 00436 size_t len = temp - pathname + 1; 00437 if (len > (sizeof return_dirname / sizeof (ACE_TCHAR))) 00438 len = sizeof return_dirname / sizeof (ACE_TCHAR); 00439 00440 ACE_OS::strsncpy (return_dirname, 00441 pathname, 00442 len); 00443 return return_dirname; 00444 } 00445 } |
|
Wait for timeout before proceeding to a Definition at line 2296 of file ACE.cpp. References handle_read_ready(), and record_and_set_non_blocking_mode(). Referenced by recv(), recvfrom(), recvmsg(), recvv(), and t_rcv().
02299 { 02300 int result = ACE::handle_read_ready (handle, 02301 timeout); 02302 02303 if (result == -1) 02304 return -1; 02305 02306 ACE::record_and_set_non_blocking_mode (handle, 02307 val); 02308 02309 return result; 02310 } |
|
Wait for timeout before proceeding to a Definition at line 2313 of file ACE.cpp. References handle_write_ready(), and record_and_set_non_blocking_mode(). Referenced by send(), sendmsg(), sendto(), sendv(), and t_snd().
02316 { 02317 int result = ACE::handle_write_ready (handle, 02318 timeout); 02319 02320 if (result == -1) 02321 return -1; 02322 02323 ACE::record_and_set_non_blocking_mode (handle, 02324 val); 02325 02326 return result; 02327 } |
|
On Windows, determines if a specified pathname ends with ".exe" (not case sensitive). If on Windows and there is no ".exe" suffix, a new ACE_TCHAR array is allocated and a copy of
Definition at line 287 of file ACE.cpp. References ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_OS::strcasecmp(), ACE_OS::strcpy(), ACE_OS::strecpy(), ACE_OS::strlen(), and ACE_OS::strrchr().
00288 { 00289 #if defined (ACE_WIN32) 00290 const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_LIB_TEXT ('.')); 00291 if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_LIB_TEXT (".exe")) != 0) 00292 { 00293 ACE_TCHAR *new_name; 00294 00295 size_t size = 00296 ACE_OS::strlen (old_name) 00297 + ACE_OS::strlen (ACE_LIB_TEXT (".exe")) 00298 + 1; 00299 00300 ACE_NEW_RETURN (new_name, 00301 ACE_TCHAR[size], 00302 0); 00303 ACE_TCHAR *end = new_name; 00304 00305 end = ACE_OS::strecpy (new_name, old_name); 00306 00307 // Concatenate the .exe suffix onto the end of the executable. 00308 // end points _after_ the terminating nul. 00309 ACE_OS::strcpy (end - 1, ACE_LIB_TEXT (".exe")); 00310 00311 return new_name; 00312 } 00313 #endif /* ACE_WIN32 */ 00314 return old_name; 00315 } |
|
Shut down ACE library services. Can be called only once per program invocation.
Definition at line 27 of file Init_ACE.cpp. References ACE_TRACE, ACE_Object_Manager::fini(), and ACE_Object_Manager::instance().
00028 { 00029 ACE_TRACE ("ACE::fini"); 00030 00031 if (ACE::init_fini_count_ > 0) 00032 { 00033 if (--ACE::init_fini_count_ == 0) 00034 return ACE_Object_Manager::instance ()->fini (); 00035 else 00036 // Wait for remaining fini () calls. 00037 return 1; 00038 } 00039 else 00040 // More ACE::fini () calls than ACE::init () calls. Bad 00041 // application! 00042 return -1; 00043 } |
|
if avoid_zombies == 0 call Definition at line 2855 of file ACE.cpp. References ACE_OS::_exit(), ACE_exitcode, ACE_TCHAR, ACE_OS::fork(), pid_t, ACE_OS::waitpid(), WEXITSTATUS, and WIFEXITED. Referenced by ACE_Process_Strategy< SVC_HANDLER >::activate_svc_handler(), and ACE_Process::spawn().
02857 { 02858 if (avoid_zombies == 0) 02859 return ACE_OS::fork (program_name); 02860 else 02861 { 02862 // This algorithm is adapted from an example in the Stevens book 02863 // "Advanced Programming in the Unix Environment" and an item in 02864 // Andrew Gierth's Unix Programming FAQ. It creates an orphan 02865 // process that's inherited by the init process; init cleans up 02866 // when the orphan process terminates. 02867 // 02868 // Another way to avoid zombies is to ignore or catch the 02869 // SIGCHLD signal; we don't use that approach here. 02870 02871 pid_t pid = ACE_OS::fork (); 02872 if (pid == 0) 02873 { 02874 // The child process forks again to create a grandchild. 02875 switch (ACE_OS::fork (program_name)) 02876 { 02877 case 0: // grandchild returns 0. 02878 return 0; 02879 case -1: // assumes all errnos are < 256 02880 ACE_OS::_exit (errno); 02881 default: // child terminates, orphaning grandchild 02882 ACE_OS::_exit (0); 02883 } 02884 } 02885 02886 // Parent process waits for child to terminate. 02887 #if defined (ACE_HAS_UNION_WAIT) 02888 union wait status; 02889 if (pid < 0 || ACE_OS::waitpid (pid, &(status.w_status), 0) < 0) 02890 #else 02891 ACE_exitcode status; 02892 if (pid < 0 || ACE_OS::waitpid (pid, &status, 0) < 0) 02893 #endif /* ACE_HAS_UNION_WAIT */ 02894 return -1; 02895 02896 // child terminated by calling exit()? 02897 if (WIFEXITED ((status))) 02898 { 02899 // child terminated normally? 02900 if (WEXITSTATUS ((status)) == 0) 02901 return 1; 02902 else 02903 errno = WEXITSTATUS ((status)); 02904 } 02905 else 02906 // child didn't call exit(); perhaps it received a signal? 02907 errno = EINTR; 02908 02909 return -1; 02910 } 02911 } |
|
Format buffer into printable format. This is useful for debugging. Definition at line 2364 of file ACE.cpp. References ACE_OS::ace_isprint(), ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, and ACE_OS::sprintf().
02368 { 02369 ACE_TRACE ("ACE::format_hexdump"); 02370 02371 u_char c; 02372 ACE_TCHAR textver[16 + 1]; 02373 02374 // We can fit 16 bytes output in text mode per line, 4 chars per byte. 02375 size_t maxlen = (obuf_sz / 68) * 16; 02376 02377 if (size > maxlen) 02378 size = maxlen; 02379 02380 size_t i; 02381 02382 size_t lines = size / 16; 02383 for (i = 0; i < lines; i++) 02384 { 02385 size_t j; 02386 02387 for (j = 0 ; j < 16; j++) 02388 { 02389 c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j] 02390 ACE_OS::sprintf (obuf, 02391 ACE_LIB_TEXT ("%02x "), 02392 c); 02393 obuf += 3; 02394 if (j == 7) 02395 { 02396 ACE_OS::sprintf (obuf, 02397 ACE_LIB_TEXT (" ")); 02398 ++obuf; 02399 } 02400 textver[j] = ACE_OS::ace_isprint (c) ? c : '.'; 02401 } 02402 02403 textver[j] = 0; 02404 02405 ACE_OS::sprintf (obuf, 02406 ACE_LIB_TEXT (" %s\n"), 02407 textver); 02408 02409 while (*obuf != '\0') 02410 obuf++; 02411 } 02412 02413 if (size % 16) 02414 { 02415 for (i = 0 ; i < size % 16; i++) 02416 { 02417 c = (u_char) buffer[size - size % 16 + i]; 02418 ACE_OS::sprintf (obuf, 02419 ACE_LIB_TEXT ("%02x "), 02420 c); 02421 obuf += 3; 02422 if (i == 7) 02423 { 02424 ACE_OS::sprintf (obuf, 02425 ACE_LIB_TEXT (" ")); 02426 ++obuf; 02427 } 02428 textver[i] = ACE_OS::ace_isprint (c) ? c : '.'; 02429 } 02430 02431 for (i = size % 16; i < 16; i++) 02432 { 02433 ACE_OS::sprintf (obuf, 02434 ACE_LIB_TEXT (" ")); 02435 obuf += 3; 02436 if (i == 7) 02437 { 02438 ACE_OS::sprintf (obuf, 02439 ACE_LIB_TEXT (" ")); 02440 obuf++; 02441 } 02442 textver[i] = ' '; 02443 } 02444 02445 textver[i] = 0; 02446 ACE_OS::sprintf (obuf, 02447 ACE_LIB_TEXT (" %s\n"), 02448 textver); 02449 } 02450 return size; 02451 } |
|
Euclid's greatest common divisor algorithm.
Definition at line 3018 of file ACE.cpp. Referenced by minimum_frame_size(), and ACE_Get_Opt::permute_args().
03019 { 03020 while (y != 0) 03021 { 03022 u_long r = x % y; 03023 x = y; 03024 y = r; 03025 } 03026 03027 return x; 03028 } |
|
Get our broadcast address based on our host_addr. If hostname is non-0 we'll use it to determine our IP address. If handle is not ACE_INVALID_HANDLE then we'll use this to determine our broadcast address, otherwise we'll have to create a socket internally (and free it). Returns -1 on failure and 0 on success. Definition at line 352 of file Sock_Connect.cpp. References ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, ACE_TRACE, ACE_UINT64, caddr_t, ACE_OS::close(), ACE_OS::gethostbyname(), ACE_OS::ioctl(), LM_ERROR, ACE_OS::memcpy(), ACE_OS::memset(), SIOCGIFBRDADDR, and ACE_OS::socket().
00356 { 00357 ACE_TRACE ("ACE::get_bcast_addr"); 00358 00359 #if !defined(ACE_WIN32) && !defined(__INTERIX) 00360 ACE_HANDLE s = handle; 00361 00362 if (s == ACE_INVALID_HANDLE) 00363 s = ACE_OS::socket (AF_INET, SOCK_STREAM, 0); 00364 00365 if (s == ACE_INVALID_HANDLE) 00366 ACE_ERROR_RETURN ((LM_ERROR, 00367 ACE_LIB_TEXT ("%p\n"), 00368 ACE_LIB_TEXT ("ACE_OS::socket")), 00369 -1); 00370 00371 struct ifconf ifc; 00372 char buf[BUFSIZ]; 00373 00374 ifc.ifc_len = sizeof buf; 00375 ifc.ifc_buf = buf; 00376 00377 // Get interface structure and initialize the addresses using UNIX 00378 // techniques 00379 #if defined (AIX) 00380 int cmd = CSIOCGIFCONF; 00381 #else 00382 int cmd = SIOCGIFCONF; 00383 #endif /* AIX */ 00384 if (ACE_OS::ioctl (s, cmd, (char *) &ifc) == -1) 00385 ACE_ERROR_RETURN ((LM_ERROR, 00386 ACE_LIB_TEXT ("%p\n"), 00387 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00388 ACE_LIB_TEXT ("ioctl (get interface configuration)")), 00389 -1); 00390 00391 struct ifreq *ifr = ifc.ifc_req; 00392 00393 struct sockaddr_in ip_addr; 00394 00395 // Get host ip address if necessary. 00396 if (host_name) 00397 { 00398 hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); 00399 00400 if (hp == 0) 00401 return -1; 00402 else 00403 #if !defined(_UNICOS) 00404 ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr, 00405 (char *) hp->h_addr, 00406 hp->h_length); 00407 #else /* _UNICOS */ 00408 { 00409 ACE_UINT64 haddr; // a place to put the address 00410 char * haddrp = (char *) &haddr; // convert to char pointer 00411 ACE_OS::memcpy(haddrp,(char *) hp->h_addr,hp->h_length); 00412 ip_addr.sin_addr.s_addr = haddr; 00413 } 00414 #endif /* ! _UNICOS */ 00415 } 00416 else 00417 { 00418 ACE_OS::memset ((void *) &ip_addr, 0, sizeof ip_addr); 00419 #if !defined(_UNICOS) 00420 ACE_OS::memcpy ((void *) &ip_addr.sin_addr, 00421 (void*) &host_addr, 00422 sizeof ip_addr.sin_addr); 00423 #else /* _UNICOS */ 00424 ip_addr.sin_addr.s_addr = host_addr; // just copy to the bitfield 00425 #endif /* ! _UNICOS */ 00426 } 00427 00428 #if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) 00429 for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0; 00430 n--, ifr++) 00431 #else 00432 // see mk_broadcast@SOCK_Dgram_Bcast.cpp 00433 for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) && 00434 ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? 00435 (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1); 00436 ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? 00437 (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len, 00438 ifr = (struct ifreq *) 00439 ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) : 00440 (nbytes -= sizeof (struct ifreq), ifr++))) 00441 #endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ 00442 { 00443 struct sockaddr_in if_addr; 00444 00445 // Compare host ip address with interface ip address. 00446 ACE_OS::memcpy (&if_addr, 00447 &ifr->ifr_addr, 00448 sizeof if_addr); 00449 00450 if (ip_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) 00451 continue; 00452 00453 if (ifr->ifr_addr.sa_family != AF_INET) 00454 { 00455 ACE_ERROR ((LM_ERROR, 00456 ACE_LIB_TEXT ("%p\n"), 00457 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00458 ACE_LIB_TEXT ("Not AF_INET"))); 00459 continue; 00460 } 00461 00462 struct ifreq flags = *ifr; 00463 struct ifreq if_req = *ifr; 00464 00465 if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) 00466 { 00467 ACE_ERROR ((LM_ERROR, 00468 ACE_LIB_TEXT ("%p\n"), 00469 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00470 ACE_LIB_TEXT (" ioctl (get interface flags)"))); 00471 continue; 00472 } 00473 00474 if (ACE_BIT_DISABLED (flags.ifr_flags, IFF_UP)) 00475 { 00476 ACE_ERROR ((LM_ERROR, 00477 ACE_LIB_TEXT ("%p\n"), 00478 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00479 ACE_LIB_TEXT ("Network interface is not up"))); 00480 continue; 00481 } 00482 00483 if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) 00484 continue; 00485 00486 if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) 00487 { 00488 if (ACE_OS::ioctl (s, 00489 SIOCGIFBRDADDR, 00490 (char *) &if_req) == -1) 00491 ACE_ERROR ((LM_ERROR, 00492 ACE_LIB_TEXT ("%p\n"), 00493 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00494 ACE_LIB_TEXT ("ioctl (get broadaddr)"))); 00495 else 00496 { 00497 ACE_OS::memcpy (reinterpret_cast<sockaddr_in *> (&ip_addr), 00498 reinterpret_cast<sockaddr_in *> (&if_req.ifr_broadaddr), 00499 sizeof if_req.ifr_broadaddr); 00500 00501 ACE_OS::memcpy ((void *) &host_addr, 00502 (void *) &ip_addr.sin_addr, 00503 sizeof host_addr); 00504 00505 if (handle == ACE_INVALID_HANDLE) 00506 ACE_OS::close (s); 00507 00508 bcast_addr = host_addr; 00509 return 0; 00510 } 00511 } 00512 else 00513 ACE_ERROR ((LM_ERROR, 00514 ACE_LIB_TEXT ("%p\n"), 00515 ACE_LIB_TEXT ("ACE::get_bcast_addr:") 00516 ACE_LIB_TEXT ("Broadcast is not enable for this interface."))); 00517 00518 if (handle == ACE_INVALID_HANDLE) 00519 ACE_OS::close (s); 00520 00521 bcast_addr = host_addr; 00522 return 0; 00523 } 00524 00525 return 0; 00526 #else 00527 ACE_UNUSED_ARG (handle); 00528 ACE_UNUSED_ARG (host_addr); 00529 ACE_UNUSED_ARG (host_name); 00530 bcast_addr = (ACE_UINT32 (INADDR_BROADCAST)); 00531 return 0; 00532 #endif /* !ACE_WIN32 && !__INTERIX */ 00533 } |
|
Return the current setting of flags associated with handle.
Definition at line 11 of file Flag_Manip.inl. References ACE_TRACE, F_GETFL, and ACE_OS::fcntl(). Referenced by record_and_set_non_blocking_mode().
00012 { 00013 ACE_TRACE ("ACE::get_flags"); 00014 00015 #if defined (ACE_LACKS_FCNTL) 00016 // ACE_OS::fcntl is not supported. It 00017 // would be better to store ACE's notion of the flags 00018 // associated with the handle, but this works for now. 00019 ACE_UNUSED_ARG (handle); 00020 return 0; 00021 #else 00022 return ACE_OS::fcntl (handle, F_GETFL, 0); 00023 #endif /* ACE_LACKS_FCNTL */ 00024 } |
|
Routine to return a handle from which Definition at line 1480 of file Sock_Connect.cpp. References ACE_OS::open(), and ACE_OS::socket(). Referenced by get_ip_interfaces().
01481 { 01482 // Solaris 2.x 01483 ACE_HANDLE handle = ACE_INVALID_HANDLE; 01484 #if defined (sparc) 01485 handle = ACE_OS::open ("/dev/udp", O_RDONLY); 01486 #elif defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (_AIX) || (defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600)) || defined (ACE_OPENVMS) 01487 // Note: DEC CXX doesn't define "unix" BSD compatible OS: HP UX, 01488 // AIX, SunOS 4.x 01489 01490 handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); 01491 #endif /* sparc */ 01492 return handle; 01493 } |
|
Return count and array of all configured IP interfaces on this host, rc = 0 on success (count == number of interfaces else -1). Caller is responsible for calling delete [] on addr_array. Definition at line 540 of file Sock_Connect.cpp. References ACE_ERROR_RETURN, ACE_INET_Addr, ACE_LIB_TEXT, ACE_MAX_FULLY_QUALIFIED_NAME_LEN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_TCHAR, ACE_TRACE, ACE_TString, ACE_WINDOWS_IS_WIN2K, ACE_WINDOWS_IS_WIN95, ACE_WINDOWS_IS_WIN98, ACE_WINDOWS_IS_WINME, ACE_WINDOWS_IS_WINNT, ACE_WINDOWS_VERSION, caddr_t, ACE_OS::close(), count_interfaces(), ACE_Tokenizer::delimiter(), ACE_String_Base< CHAR >::fast_rep(), ACE_OS::fclose(), ACE_OS::fopen(), ACE_Auto_Basic_Array_Ptr< X >::get(), get_handle(), get_reg_value(), get_windows_version(), ACE_OS::ioctl(), ACE_String_Base< CHAR >::length(), LM_ERROR, ACE_OS::memset(), ACE_Tokenizer::next(), ACE_INET_Addr::set(), ACE_OS::sprintf(), ACE_OS::strcat(), ACE_OS::strcmp(), and ACE_String_Base< CHAR >::substring(). Referenced by ACE_SOCK_Dgram_Mcast::subscribe_ifs(), and ACE_SOCK_Dgram_Mcast::unsubscribe_ifs().
00542 { 00543 ACE_TRACE ("ACE::get_ip_interfaces"); 00544 00545 count = 0; 00546 addrs = 0; 00547 00548 #if defined (ACE_WIN32) 00549 // Win32 can do this by a simple API call if MSVC 5 or later is the compiler. 00550 // Not sure if Borland supplies the needed header/lib, but it might. 00551 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) 00552 int i, n_interfaces, status; 00553 00554 INTERFACE_INFO info[64]; 00555 SOCKET sock; 00556 00557 // Get an (overlapped) DGRAM socket to test with 00558 sock = socket (AF_INET, SOCK_DGRAM, 0); 00559 if (sock == INVALID_SOCKET) 00560 return -1; 00561 00562 DWORD bytes; 00563 status = WSAIoctl(sock, 00564 SIO_GET_INTERFACE_LIST, 00565 0, 00566 0, 00567 info, 00568 sizeof(info), 00569 &bytes, 00570 0, 00571 0); 00572 closesocket (sock); 00573 if (status == SOCKET_ERROR) 00574 return -1; 00575 00576 n_interfaces = bytes / sizeof(INTERFACE_INFO); 00577 if (n_interfaces == 0) 00578 return 0; 00579 00580 // SIO_GET_INTERFACE_LIST does not work for IPv6 00581 // Instead recent versions of Winsock2 add the new opcode SIO_ADDRESS_LIST_QUERY. 00582 // If this is not available forget about IPv6 local interfaces:-/ 00583 # if defined (ACE_HAS_IPV6) && defined (SIO_ADDRESS_LIST_QUERY) 00584 int n_v6_interfaces = 0; 00585 00586 LPSOCKET_ADDRESS_LIST v6info; 00587 char *buffer; 00588 DWORD buflen = sizeof (SOCKET_ADDRESS_LIST) + (63 * sizeof (SOCKET_ADDRESS)); 00589 ACE_NEW_RETURN (buffer, 00590 char[buflen], 00591 -1); 00592 v6info = reinterpret_cast<LPSOCKET_ADDRESS_LIST> (buffer); 00593 00594 // Get an (overlapped) DGRAM socket to test with. 00595 // If it fails only return IPv4 interfaces. 00596 sock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP); 00597 if (sock == INVALID_SOCKET) 00598 { 00599 delete [] buffer; 00600 return -1; 00601 } 00602 00603 status = WSAIoctl(sock, 00604 SIO_ADDRESS_LIST_QUERY, 00605 0, 00606 0, 00607 v6info, 00608 buflen, 00609 &bytes, 00610 0, 00611 0); 00612 closesocket (sock); 00613 if (status == SOCKET_ERROR) 00614 { 00615 delete [] buffer; // clean up 00616 return -1; 00617 } 00618 00619 n_v6_interfaces = v6info->iAddressCount; 00620 00621 ACE_NEW_RETURN (addrs, 00622 ACE_INET_Addr[n_interfaces + n_v6_interfaces], 00623 -1); 00624 # else /* ACE_HAS_IPV6 */ 00625 ACE_NEW_RETURN (addrs, 00626 ACE_INET_Addr[n_interfaces], 00627 -1); 00628 # endif /* !ACE_HAS_IPV6 */ 00629 00630 // Now go through the list and transfer the good ones to the list of 00631 // because they're down or don't have an IP address. 00632 for (count = 0, i = 0; i < n_interfaces; ++i) 00633 { 00634 LPINTERFACE_INFO lpii; 00635 struct sockaddr_in *addrp = 0; 00636 00637 lpii = &info[i]; 00638 if (!(lpii->iiFlags & IFF_UP)) 00639 continue; 00640 00641 // We assume IPv4 addresses here 00642 addrp = reinterpret_cast<struct sockaddr_in *> (&lpii->iiAddress.AddressIn); 00643 if (addrp->sin_addr.s_addr == INADDR_ANY) 00644 continue; 00645 00646 // Set the address for the caller. 00647 addrs[count].set(addrp, sizeof(sockaddr_in)); 00648 ++count; 00649 } 00650 00651 # if defined (ACE_HAS_IPV6) 00652 // Now go through the list and transfer the good ones to the list of 00653 // because they're down or don't have an IP address. 00654 for (i = 0; i < n_v6_interfaces; i++) 00655 { 00656 struct sockaddr_in6 *addr6p; 00657 00658 if (v6info->Address[i].lpSockaddr->sa_family != AF_INET6) 00659 continue; 00660 00661 addr6p = reinterpret_cast<struct sockaddr_in6 *> (v6info->Address[i].lpSockaddr); 00662 if (IN6_IS_ADDR_UNSPECIFIED(&addr6p->sin6_addr)) // IN6ADDR_ANY? 00663 continue; 00664 00665 // Set the address for the caller. 00666 addrs[count].set(reinterpret_cast<struct sockaddr_in *> (addr6p), sizeof(sockaddr_in6)); 00667 ++count; 00668 } 00669 00670 delete [] buffer; // Clean up 00671 # endif /* ACE_HAS_IPV6 */ 00672 00673 if (count == 0) 00674 { 00675 delete [] addrs; 00676 addrs = 0; 00677 } 00678 00679 return 0; 00680 00681 #else /* Winsock 2 && MSVC 5 or later */ 00682 00683 // PharLap ETS has kernel routines to rummage through the device 00684 // configs and extract the interface info. Sort of a pain in the 00685 // butt, but better than trying to figure out where it moved to in 00686 // the registry... :-| 00687 # if defined (ACE_HAS_PHARLAP) 00688 # if !defined (ACE_HAS_PHARLAP_RT) 00689 ACE_NOTSUP_RETURN (-1); 00690 # endif /* ACE_HAS_PHARLAP_RT */ 00691 00692 // Locate all of the IP devices in the system, saving a DEVHANDLE 00693 // for each. Then allocate the ACE_INET_Addrs needed and fetch all 00694 // the IP addresses. To locate the devices, try the available 00695 // device name roots and increment the device number until the 00696 // kernel says there are no more of that type. 00697 const size_t ACE_MAX_ETS_DEVICES = 64; // Arbitrary, but should be enough. 00698 DEVHANDLE ip_dev[ACE_MAX_ETS_DEVICES]; 00699 EK_TCPIPCFG *devp; 00700 size_t i, j; 00701 ACE_TCHAR dev_name[16]; 00702 00703 count = 0; 00704 for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) 00705 { 00706 // Ethernet. 00707 ACE_OS::sprintf (dev_name, 00708 "ether%d", 00709 i); 00710 ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); 00711 if (ip_dev[count] == 0) 00712 break; 00713 } 00714 for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) 00715 { 00716 // SLIP. 00717 ACE_OS::sprintf (dev_name, 00718 "sl%d", 00719 i); 00720 ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); 00721 if (ip_dev[count] == 0) 00722 break; 00723 } 00724 for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) 00725 { 00726 // PPP. 00727 ACE_OS::sprintf (dev_name, 00728 "ppp%d", 00729 i); 00730 ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); 00731 if (ip_dev[count] == 0) 00732 break; 00733 } 00734 00735 if (count > 0) 00736 ACE_NEW_RETURN (addrs, 00737 ACE_INET_Addr[count], 00738 -1); 00739 else 00740 addrs = 0; 00741 00742 for (i = 0, j = 0; i < count; i++) 00743 { 00744 devp = EtsTCPGetDeviceCfg (ip_dev[i]); 00745 if (devp != 0) 00746 { 00747 addrs[j].set (0, 00748 devp->nwIPAddress, 00749 0); // Already in net order. 00750 j++; 00751 } 00752 // There's no call to close the DEVHANDLE. 00753 } 00754 00755 count = j; 00756 if (count == 0 && addrs != 0) 00757 { 00758 delete [] addrs; 00759 addrs = 0; 00760 } 00761 00762 return 0; 00763 00764 # else /* ACE_HAS_PHARLAP */ 00765 00766 # if defined (ACE_HAS_WINCE) 00767 00768 // CE does not support Winsock2 (yet) and has many variations on registry setting. 00769 // Thus, it is better to use GetAdapterInfo defined in iphlpapi.h, which is a 00770 // standard library for CE. iphlpapi.lib should come with the CE SDK and should 00771 // be included in the machine. 00772 // Note: This call is supported only in WinCE 3.0 or later. Also, even though 00773 // "iphlpapi.dll" may not be found in the /Windows directory on some machines, 00774 // it will (must) support iphlpapi API's because it is part of the standard 00775 // library for WinCE. 00776 00777 IP_ADAPTER_INFO* adapterInfo = 0; 00778 ULONG sz = 0; 00779 DWORD result = ::GetAdaptersInfo(adapterInfo, &sz); 00780 00781 while (result != ERROR_SUCCESS) 00782 { 00783 switch (result) 00784 { 00785 case ERROR_BUFFER_OVERFLOW: // MUST come here at the first run because sz = 0 00786 adapterInfo = (PIP_ADAPTER_INFO)(new char[sz]); // I know, I know, this is ugly. 00787 00788 result = ::GetAdaptersInfo(adapterInfo, &sz); 00789 if (result == ERROR_SUCCESS) { 00790 const char* invalid_IP = "0.0.0.0"; 00791 00792 // find out how many interfaces are there 00793 { 00794 IP_ADAPTER_INFO* tempAdapterInfo = adapterInfo; 00795 int n_interfaces = 0; 00796 while (tempAdapterInfo != 0) { 00797 IP_ADDR_STRING* addr = &tempAdapterInfo->IpAddressList; 00798 while (addr != 0) { 00799 if (ACE_OS::strcmp(addr->IpAddress.String, invalid_IP) != 0) { 00800 // skip invalid IP address 00801 ++n_interfaces; 00802 } 00803 addr = addr->Next; 00804 } 00805 tempAdapterInfo = tempAdapterInfo->Next; 00806 } 00807 if (n_interfaces == 0) { 00808 ACE_ERROR_RETURN ((LM_ERROR, 00809 ACE_LIB_TEXT ("%p\nACE::get_ip_interfaces - "), 00810 ACE_LIB_TEXT ("No adapter found.")), 00811 -1); 00812 } 00813 00814 ACE_NEW_RETURN (addrs, ACE_INET_Addr[n_interfaces], -2); 00815 } 00816 00817 // find out valid IP addresses and put them into the addr 00818 while (adapterInfo != 0) { 00819 IP_ADDR_STRING* addr = &adapterInfo->IpAddressList; 00820 while (addr != 0) { 00821 if (ACE_OS::strcmp(addr->IpAddress.String, invalid_IP) != 0) { 00822 addrs[count++] = ACE_INET_Addr((u_short) 0, addr->IpAddress.String); 00823 } 00824 addr = addr->Next; 00825 } 00826 adapterInfo = adapterInfo->Next; 00827 } 00828 } 00829 // if second GetAdaptersInfo call fails, let other cases take care of it 00830 break; 00831 00832 case ERROR_NOT_SUPPORTED: // OS does not support this method 00833 ACE_ERROR_RETURN ((LM_ERROR, 00834 ACE_LIB_TEXT ("%p\nACE::get_ip_interfaces - "), 00835 ACE_LIB_TEXT ("This version of WinCE does not support GetAdapterInfo.")), 00836 -1); 00837 break; 00838 00839 case ERROR_NO_DATA: // no adapter installed 00840 ACE_ERROR_RETURN ((LM_ERROR, 00841 ACE_LIB_TEXT ("%p\nACE::get_ip_interfaces - "), 00842 ACE_LIB_TEXT ("No network adapter installed.")), 00843 -1); 00844 break; 00845 00846 case ERROR_INVALID_PARAMETER: 00847 ACE_ERROR_RETURN ((LM_ERROR, 00848 ACE_LIB_TEXT ("%p\nACE::get_ip_interfaces - "), 00849 ACE_LIB_TEXT ("Invalid parameter.")), 00850 -1); 00851 break; 00852 00853 default: 00854 ACE_ERROR_RETURN ((LM_ERROR, 00855 ACE_LIB_TEXT ("%p\nACE::get_ip_interfaces - "), 00856 ACE_LIB_TEXT ("Adapter info access permission denied.")), 00857 -1); 00858 break; 00859 } 00860 } 00861 00862 delete [] adapterInfo; 00863 return 0; 00864 00865 # endif // ACE_HAS_WINCE 00866 00867 // 00868 // No Winsock2. 00869 // Get interface information from the registry. 00870 // As this information is in different locations of the registry 00871 // on different windows versions, we need to ask at runtime. 00872 // 00873 00874 // Normally we have to look under one key for interfaces name, 00875 // and under a second key for ip address of those interfaces. 00876 // Exact values and the way to search depend on windows version. 00877 00878 // This is the first key we have to look for. 00879 const ACE_TCHAR *BASE_KEY1; 00880 00881 // This is the name we have to look for under the first key. 00882 // If this is == 0, we need to look for subkeys, not the values from 00883 // a name. 00884 const ACE_TCHAR *KEY1_NAME_ID; 00885 00886 // The second key is normally constructed concatenating a prefix, 00887 // the value found on KEY1_NAME_ID stripped from the first s_offset 00888 // characters, and a suffix. 00889 unsigned int s_offset; 00890 const ACE_TCHAR *PREFFIX_KEY2; 00891 const ACE_TCHAR *SUFFIX_KEY2; 00892 00893 // If != 0, look for the value of KEY1_NAME_ID not directly under 00894 // BASE_KEY1, but on every subkey of BASE_KEY1. 00895 int use_subkeys; 00896 00897 // When we search for IP Addresses below, we look for a key with a 00898 // name in this array (null terminated). 00899 // For some windows versions, there is an 00900 // aditional key for ppp interfaces that will be stored on [1]. 00901 const ACE_TCHAR *IPADDR_NAME_ID[3] = { 00902 ACE_LIB_TEXT ("IPAddress"), 0, 0 00903 }; 00904 00905 // Skip addresses that match this. 00906 const ACE_TCHAR *INVALID_TCPIP_DEVICE_ADDR = ACE_LIB_TEXT ("0.0.0.0"); 00907 00908 ACE_WINDOWS_VERSION winver = get_windows_version(); 00909 00910 switch (winver) 00911 { 00912 case ACE_WINDOWS_IS_WINNT: 00913 PREFFIX_KEY2 = ACE_LIB_TEXT ("SYSTEM\\CurrentControlSet\\Services\\"); 00914 BASE_KEY1 = 00915 ACE_LIB_TEXT ("SYSTEM\\CurrentControlSet\\Services") 00916 ACE_LIB_TEXT ("\\Tcpip\\Linkage"); 00917 SUFFIX_KEY2 = ACE_LIB_TEXT ("\\Parameters\\Tcpip"); 00918 KEY1_NAME_ID = ACE_LIB_TEXT ("Bind"); 00919 s_offset = 8; 00920 use_subkeys = 0; 00921 break; 00922 00923 case ACE_WINDOWS_IS_WIN2K: 00924 BASE_KEY1 = 00925 ACE_LIB_TEXT ("SYSTEM\\CurrentControlSet\\Services") 00926 ACE_LIB_TEXT ("\\Tcpip\\Parameters\\Interfaces\\"); 00927 PREFFIX_KEY2 = BASE_KEY1; 00928 SUFFIX_KEY2 = ACE_LIB_TEXT (""); 00929 KEY1_NAME_ID = 0; 00930 s_offset = 0; 00931 use_subkeys = 1; 00932 // PPP. 00933 IPADDR_NAME_ID[1] = ACE_LIB_TEXT ("DhcpIPAddress"); 00934 break; 00935 00936 // If ACE_HAS_WINNT4 we can safely assume the ones below will 00937 // not be needed. 00938 # if !defined(ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0) 00939 case ACE_WINDOWS_IS_WIN95: 00940 case ACE_WINDOWS_IS_WIN98: 00941 case ACE_WINDOWS_IS_WINME: 00942 PREFFIX_KEY2 = 00943 ACE_LIB_TEXT ("SYSTEM\\CurrentControlSet\\Services\\Class\\"); 00944 BASE_KEY1 = ACE_LIB_TEXT ("Enum\\Network\\MSTCP"); 00945 SUFFIX_KEY2 = ACE_LIB_TEXT (""); 00946 KEY1_NAME_ID = ACE_LIB_TEXT ("Driver"); 00947 use_subkeys = 1; 00948 s_offset = 0; 00949 break; 00950 # endif /* !ACE_HAS_WINNT4 */ 00951 00952 default: 00953 return -1; 00954 } 00955 00956 ACE_TCHAR raw_buffer[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1]; 00957 DWORD raw_buflen = ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1; 00958 00959 if (KEY1_NAME_ID == 0) 00960 { 00961 if (::get_reg_subkeys (BASE_KEY1, 00962 raw_buffer, 00963 raw_buflen)) 00964 return -1; 00965 } 00966 else 00967 { 00968 if (::get_reg_value (BASE_KEY1, 00969 KEY1_NAME_ID, 00970 raw_buffer, 00971 raw_buflen, 00972 use_subkeys)) 00973 return -1; 00974 } 00975 // return buffer contains 0 delimited strings 00976 00977 ACE_Tokenizer dev_names (raw_buffer); 00978 dev_names.delimiter (ACE_LIB_TEXT ('\0')); 00979 int n_interfaces = 0; 00980 00981 // Count the number of interfaces 00982 while (dev_names.next () != 0) 00983 ++n_interfaces; 00984 00985 // case 1. no interfaces present, empty string? OS version change? 00986 if (n_interfaces == 0) 00987 return 0; 00988 00989 ACE_NEW_RETURN (addrs, 00990 ACE_INET_Addr[n_interfaces], 00991 -2); 00992 00993 ACE_TCHAR buffer[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1]; 00994 DWORD buf_len = ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 1; 00995 00996 count = 0; 00997 for (int i = 0; i < n_interfaces; i++) 00998 { 00999 for (const ACE_TCHAR **ipaddr_name_id = IPADDR_NAME_ID; 01000 *ipaddr_name_id != 0; 01001 ++ipaddr_name_id) 01002 { 01003 // a. construct name to access IP Address for this interface 01004 ACE_TString ifdevkey (PREFFIX_KEY2); 01005 ACE_TString the_dev = dev_names.next (); 01006 01007 if (the_dev.length() < s_offset) 01008 { 01009 return -3; // Something's wrong 01010 } 01011 01012 // rest of string from offset. 01013 the_dev = the_dev.substring (s_offset); 01014 01015 ifdevkey += the_dev; 01016 ifdevkey += SUFFIX_KEY2; 01017 01018 // b. extract value 01019 // Gets overwritten on each call 01020 buf_len = sizeof (buffer); 01021 if (get_reg_value (ifdevkey.fast_rep (), 01022 *ipaddr_name_id, 01023 buffer, 01024 buf_len)) 01025 continue; // Skip unknown devices. 01026 01027 if (ACE_OS::strcmp (buffer, 01028 INVALID_TCPIP_DEVICE_ADDR) == 0) 01029 continue; // Don't count this device 01030 01031 // c. store in hostinfo object array and up the counter 01032 addrs[count++] = 01033 ACE_INET_Addr ((u_short) 0, buffer); 01034 } 01035 } 01036 01037 return 0; 01038 # endif /* ACE_HAS_PHARLAP */ 01039 # endif /* Winsock 2 && MSVC 5 or later */ 01040 01041 #elif defined (ACE_HAS_GETIFADDRS) 01042 // Take advantage of the BSD getifaddrs function that simplifies 01043 // access to connected interfaces. 01044 struct ifaddrs *ifap; 01045 struct ifaddrs *p_if; 01046 01047 if (::getifaddrs (&ifap) != 0) 01048 return -1; 01049 01050 // Count number of interfaces. 01051 size_t num_ifs = 0; 01052 for (p_if = ifap; p_if != 0; p_if = p_if->ifa_next) 01053 ++num_ifs; 01054 01055 // Now create and initialize output array. 01056 ACE_NEW_RETURN (addrs, 01057 ACE_INET_Addr[num_ifs], 01058 -1); // caller must free 01059 01060 // Pull the address out of each INET interface. Not every interface 01061 // is for IP, so be careful to count properly. When setting the 01062 // INET_Addr, note that the 3rd arg (0) says to leave the byte order 01063 // (already in net byte order from the interface structure) as is. 01064 count = 0; 01065 01066 for (p_if = ifap; 01067 p_if != 0; 01068 p_if = p_if->ifa_next) 01069 { 01070 if (p_if->ifa_addr && 01071 p_if->ifa_addr->sa_family == AF_INET) 01072 { 01073 struct sockaddr_in *addr = 01074 reinterpret_cast<sockaddr_in *> (p_if->ifa_addr); 01075 01076 // Sometimes the kernel returns 0.0.0.0 as the interface 01077 // address, skip those... 01078 if (addr->sin_addr.s_addr != INADDR_ANY) 01079 { 01080 addrs[count].set ((u_short) 0, 01081 addr->sin_addr.s_addr, 01082 0); 01083 ++count; 01084 } 01085 } 01086 # if defined (ACE_HAS_IPV6) 01087 else if (p_if->ifa_addr && 01088 p_if->ifa_addr->sa_family == AF_INET6) 01089 { 01090 struct sockaddr_in6 *addr = 01091 reinterpret_cast<sockaddr_in6 *> (p_if->ifa_addr); 01092 01093 // Skip the ANY address 01094 if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr)) 01095 { 01096 addrs[count].set(reinterpret_cast<struct sockaddr_in *> (addr), 01097 sizeof(sockaddr_in6)); 01098 ++count; 01099 } 01100 } 01101 # endif /* ACE_HAS_IPV6 */ 01102 } 01103 01104 ::freeifaddrs (ifap); 01105 01106 return 0; 01107 01108 #elif defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (_AIX) || defined (ACE_OPENVMS) 01109 // COMMON (SVR4 and BSD) UNIX CODE 01110 01111 size_t num_ifs, num_ifs_found; 01112 01113 // Call specific routine as necessary. 01114 ACE_HANDLE handle = get_handle(); 01115 01116 if (handle == ACE_INVALID_HANDLE) 01117 ACE_ERROR_RETURN ((LM_ERROR, 01118 ACE_LIB_TEXT ("%p\n"), 01119 ACE_LIB_TEXT ("ACE::get_ip_interfaces:open")), 01120 -1); 01121 if (ACE::count_interfaces (handle, num_ifs)) 01122 { 01123 ACE_OS::close (handle); 01124 return -1; 01125 } 01126 01127 // ioctl likes to have an extra ifreq structure to mark the end of 01128 // what it returned, so increase the num_ifs by one. 01129 ++num_ifs; 01130 01131 struct ifreq *ifs = 0; 01132 ACE_NEW_RETURN (ifs, 01133 struct ifreq[num_ifs], 01134 -1); 01135 ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct ifreq)); 01136 01137 ACE_Auto_Array_Ptr<struct ifreq> p_ifs (ifs); 01138 01139 if (p_ifs.get() == 0) 01140 { 01141 ACE_OS::close (handle); 01142 errno = ENOMEM; 01143 return -1; 01144 } 01145 01146 struct ifconf ifcfg; 01147 ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); 01148 ifcfg.ifc_req = p_ifs.get (); 01149 ifcfg.ifc_len = num_ifs * sizeof (struct ifreq); 01150 01151 #if defined (AIX) 01152 int cmd = CSIOCGIFCONF; 01153 #else 01154 int cmd = SIOCGIFCONF; 01155 #endif /* AIX */ 01156 if (ACE_OS::ioctl (handle, 01157 cmd, 01158 (caddr_t) &ifcfg) == -1) 01159 { 01160 ACE_OS::close (handle); 01161 ACE_ERROR_RETURN ((LM_ERROR, 01162 ACE_LIB_TEXT ("%p\n"), 01163 ACE_LIB_TEXT ("ACE::get_ip_interfaces:") 01164 ACE_LIB_TEXT ("ioctl - SIOCGIFCONF failed")), 01165 -1); 01166 } 01167 01168 ACE_OS::close (handle); 01169 01170 // Now create and initialize output array. 01171 01172 ACE_NEW_RETURN (addrs, 01173 ACE_INET_Addr[num_ifs], 01174 -1); // caller must free 01175 01176 struct ifreq *pcur = p_ifs.get (); 01177 num_ifs_found = ifcfg.ifc_len / sizeof (struct ifreq); // get the number of returned ifs 01178 01179 // Pull the address out of each INET interface. Not every interface 01180 // is for IP, so be careful to count properly. When setting the 01181 // INET_Addr, note that the 3rd arg (0) says to leave the byte order 01182 // (already in net byte order from the interface structure) as is. 01183 count = 0; 01184 01185 for (size_t i = 0; 01186 i < num_ifs_found; 01187 i++) 01188 { 01189 if (pcur->ifr_addr.sa_family == AF_INET) 01190 { 01191 #if !defined(_UNICOS) 01192 struct sockaddr_in *addr = 01193 reinterpret_cast<sockaddr_in *> (&pcur->ifr_addr); 01194 01195 // Sometimes the kernel returns 0.0.0.0 as the interface 01196 // address, skip those... 01197 if (addr->sin_addr.s_addr != 0) 01198 { 01199 addrs[count].set ((u_short) 0, 01200 addr->sin_addr.s_addr, 01201 0); 01202 count++; 01203 } 01204 #else /* ! _UNICOS */ 01205 // need to explicitly copy on the Cray, since the bitfields kinda 01206 // screw things up here 01207 struct sockaddr_in inAddr; 01208 01209 inAddr.sin_len = pcur->ifr_addr.sa_len; 01210 inAddr.sin_family = pcur->ifr_addr.sa_family; 01211 memcpy((void *)&(inAddr.sin_addr), 01212 (const void *)&(pcur->ifr_addr.sa_data[8]), 01213 sizeof(struct in_addr)); 01214 01215 if (inAddr.sin_addr.s_addr != 0) 01216 { 01217 addrs[count].set(&inAddr, sizeof(struct sockaddr_in)); 01218 ++count; 01219 } 01220 #endif /* ! _UNICOS */ 01221 } 01222 01223 #if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) 01224 ++pcur; 01225 #else 01226 if (pcur->ifr_addr.sa_len <= sizeof (struct sockaddr)) 01227 { 01228 ++pcur; 01229 } 01230 else 01231 { 01232 pcur = (struct ifreq *) 01233 (pcur->ifr_addr.sa_len + (caddr_t) &pcur->ifr_addr); 01234 } 01235 #endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ 01236 } 01237 01238 # if defined (ACE_HAS_IPV6) 01239 // Retrieve IPv6 local interfaces by scanning /proc/net/if_inet6 if it exists. 01240 // If we cannot open it then ignore possible IPv6 interfaces, we did our best;-) 01241 FILE* fp; 01242 char addr_p[8][5]; 01243 char s_ipaddr[64]; 01244 int scopeid; 01245 struct addrinfo hints, *res0; 01246 int error; 01247 01248 ACE_OS::memset (&hints, 0, sizeof (hints)); 01249 hints.ai_flags = AI_NUMERICHOST; 01250 hints.ai_family = AF_INET6; 01251 01252 if ((fp = ACE_OS::fopen (ACE_LIB_TEXT ("/proc/net/if_inet6"), ACE_LIB_TEXT ("r"))) != NULL) 01253 { 01254 while (fscanf (fp, 01255 "%4s%4s%4s%4s%4s%4s%4s%4s %02x %*02x %*02x %*02x %*8s\n", 01256 addr_p[0], addr_p[1], addr_p[2], addr_p[3], 01257 addr_p[4], addr_p[5], addr_p[6], addr_p[7], &scopeid) != EOF) 01258 { 01259 // Format the address intoa proper IPv6 decimal address specification and 01260 // resolve the resulting text using getaddrinfo(). 01261 01262 const char* ip_fmt = "%s:%s:%s:%s:%s:%s:%s:%s%%%d"; 01263 ACE_OS::sprintf (s_ipaddr, 01264 ip_fmt, 01265 addr_p[0], addr_p[1], addr_p[2], addr_p[3], 01266 addr_p[4], addr_p[5], addr_p[6], addr_p[7], scopeid); 01267 01268 error = getaddrinfo (s_ipaddr, 0, &hints, &res0); 01269 if (error) 01270 continue; 01271 01272 if (res0->ai_family == AF_INET6 && 01273 !IN6_IS_ADDR_UNSPECIFIED (&reinterpret_cast<sockaddr_in6 *> (res0->ai_addr)->sin6_addr)) 01274 { 01275 addrs[count].set(reinterpret_cast<sockaddr_in *> (res0->ai_addr), res0->ai_addrlen); 01276 ++count; 01277 } 01278 freeaddrinfo (res0); 01279 01280 } 01281 ACE_OS::fclose (fp); 01282 } 01283 # endif /* ACE_HAS_IPV6 */ 01284 01285 return 0; 01286 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) 01287 count = 0; 01288 // Loop through each address structure 01289 for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next) 01290 { 01291 ++count; 01292 } 01293 01294 // Now create and initialize output array. 01295 ACE_NEW_RETURN (addrs, 01296 ACE_INET_Addr[count], 01297 -1); // caller must free 01298 count = 0; 01299 for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next) 01300 { 01301 struct ifnet* ifp = ia->ia_ifa.ifa_ifp; 01302 if (ifp != 0) 01303 { 01304 // Get the current interface name 01305 char interface[64]; 01306 ACE_OS::sprintf(interface, "%s%d", ifp->if_name, ifp->if_unit); 01307 01308 // Get the address for the current interface 01309 char address [INET_ADDR_LEN]; 01310 STATUS status = ifAddrGet(interface, address); 01311 01312 if (status == OK) 01313 { 01314 // Concatenate a ':' at the end. This is because in 01315 // ACE_INET_Addr::string_to_addr, the ip_address is 01316 // obtained using ':' as the delimiter. Since, using 01317 // ifAddrGet(), we just get the IP address, I am adding 01318 // a ":" to get with the general case. 01319 ACE_OS::strcat (address, ":"); 01320 addrs[count].set (address); 01321 } 01322 else 01323 { 01324 ACE_ERROR_RETURN ((LM_ERROR, 01325 ACE_LIB_TEXT ("ACE::get_ip_interface failed\n") 01326 ACE_LIB_TEXT ("Couldnt get the IP Address\n")), 01327 -1); 01328 } 01329 ++count; 01330 } 01331 } 01332 return 0; 01333 #else 01334 ACE_UNUSED_ARG (count); 01335 ACE_UNUSED_ARG (addrs); 01336 ACE_NOTSUP_RETURN (-1); // no implementation 01337 #endif /* ACE_WIN32 */ 01338 } |
|
Returns the temporary directory including the trailing slash in buffer. Returns -1 for an error or if the buffer_len is not long enough. Definition at line 593 of file Lib_Find.cpp. References ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT_CHAR_TO_TCHAR, ACE_OS::getenv(), ACE_OS::strcpy(), and ACE_OS::strlen(). Referenced by ACE_MEM_Acceptor::accept(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Name_Options::ACE_Name_Options(), ACE_System_Time::ACE_System_Time(), and ACE_FILE_Addr::set().
00594 { 00595 int result; 00596 #if defined (ACE_WIN32) 00597 result = ACE_TEXT_GetTempPath (static_cast<DWORD> (buffer_len), 00598 buffer); 00599 00600 // Make sure to return -1 if there is an error 00601 if (result == 0 && ::GetLastError () != ERROR_SUCCESS 00602 || result > static_cast<int> (buffer_len)) 00603 result = -1; 00604 00605 #else /* ACE_WIN32 */ 00606 00607 // NOTE! Non-Windows platforms don't deal with wide chars for env. 00608 // variables, so do this narrow-char and convert to wide for the 00609 // caller if necessary. 00610 00611 // On non-win32 platforms, check to see what the TMPDIR environment 00612 // variable is defined to be. If it doesn't exist, just use /tmp 00613 const char *tmpdir = ACE_OS::getenv ("TMPDIR"); 00614 00615 if (tmpdir == 0) 00616 tmpdir = "/tmp"; 00617 00618 size_t len = ACE_OS::strlen (tmpdir); 00619 00620 // Check to see if the buffer is large enough for the string, 00621 // another /, and its null character (hence the + 2) 00622 if ((len + 2) > buffer_len) 00623 { 00624 result = -1; 00625 } 00626 else 00627 { 00628 ACE_OS::strcpy (buffer, ACE_TEXT_CHAR_TO_TCHAR (tmpdir)); 00629 00630 // Add a trailing slash because we cannot assume there is already one 00631 // at the end. And having an extra one should not cause problems. 00632 buffer[len] = ACE_LIB_TEXT ('/'); 00633 buffer[len + 1] = 0; 00634 result = 0; 00635 } 00636 #endif /* ACE_WIN32 */ 00637 return result; 00638 } |
|
Timed wait for handle to get exception ready.
Definition at line 263 of file ACE.inl. References handle_ready().
00265 { 00266 return ACE::handle_ready (handle, 00267 timeout, 00268 0, 00269 0, 00270 1); 00271 } |
|
Timed wait for handle to get read ready.
Definition at line 241 of file ACE.inl. References handle_ready(). Referenced by enter_recv_timedwait(), recv_n_i(), recvv_n_i(), and t_rcv_n_i().
00243 { 00244 return ACE::handle_ready (handle, 00245 timeout, 00246 1, 00247 0, 00248 0); 00249 } |
|
Timed wait for handle to get read, write, or exception ready.
Definition at line 2242 of file ACE.cpp. References ETIME, ACE_Handle_Set::fdset(), ACE_OS::poll(), ACE_OS::select(), and ACE_Handle_Set::set_bit(). Referenced by handle_exception_ready(), handle_read_ready(), and handle_write_ready().
02247 { 02248 #if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02249 ACE_UNUSED_ARG (write_ready); 02250 ACE_UNUSED_ARG (exception_ready); 02251 02252 struct pollfd fds; 02253 02254 fds.fd = handle; 02255 fds.events = read_ready ? POLLIN : POLLOUT; 02256 fds.revents = 0; 02257 02258 int result = ACE_OS::poll (&fds, 1, timeout); 02259 #else 02260 ACE_Handle_Set handle_set; 02261 handle_set.set_bit (handle); 02262 02263 // Wait for data or for the timeout to elapse. 02264 int select_width; 02265 # if defined (ACE_WIN32) 02266 // This arg is ignored on Windows and causes pointer truncation 02267 // warnings on 64-bit compiles. 02268 select_width = 0; 02269 # else 02270 select_width = int (handle) + 1; 02271 # endif /* ACE_WIN64 */ 02272 int result = ACE_OS::select (select_width, 02273 read_ready ? handle_set.fdset () : 0, // read_fds. 02274 write_ready ? handle_set.fdset () : 0, // write_fds. 02275 exception_ready ? handle_set.fdset () : 0, // exception_fds. 02276 timeout); 02277 02278 #endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02279 02280 switch (result) 02281 { 02282 case 0: // Timer expired. 02283 errno = ETIME; 02284 /* FALLTHRU */ 02285 case -1: // we got here directly - select() returned -1. 02286 return -1; 02287 case 1: // Handle has data. 02288 /* FALLTHRU */ 02289 default: // default is case result > 0; return a 02290 // ACE_ASSERT (result == 1); 02291 return result; 02292 } 02293 } |
|
Wait up to timeout amount of time to passively establish a connection. This method doesn't perform the Definition at line 2731 of file ACE.cpp. References ACE_TRACE, ETIMEDOUT, EWOULDBLOCK, ACE_OS::poll(), ACE_Time_Value::sec(), ACE_OS::select(), ACE_Handle_Set::set_bit(), and ACE_Time_Value::usec(). Referenced by ACE_TLI_Acceptor::accept(), ACE_SPIPE_Acceptor::accept(), ACE_SOCK_SEQPACK_Acceptor::shared_accept_start(), and ACE_SOCK_Acceptor::shared_accept_start().
02734 { 02735 ACE_TRACE ("ACE::handle_timed_accept"); 02736 // Make sure we don't bomb out on erroneous values. 02737 if (listener == ACE_INVALID_HANDLE) 02738 return -1; 02739 02740 #if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02741 02742 struct pollfd fds; 02743 02744 fds.fd = listener; 02745 fds.events = POLLIN; 02746 fds.revents = 0; 02747 02748 #else 02749 // Use the select() implementation rather than poll(). 02750 ACE_Handle_Set rd_handle; 02751 rd_handle.set_bit (listener); 02752 #endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02753 02754 // We need a loop here if <restart> is enabled. 02755 02756 for (;;) 02757 { 02758 #if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02759 02760 int n = ACE_OS::poll (&fds, 1, timeout); 02761 02762 #else 02763 int select_width; 02764 # if defined (ACE_WIN32) 02765 // This arg is ignored on Windows and causes pointer truncation 02766 // warnings on 64-bit compiles. 02767 select_width = 0; 02768 # else 02769 select_width = int (listener) + 1; 02770 # endif /* ACE_WIN32 */ 02771 int n = ACE_OS::select (select_width, 02772 rd_handle, 0, 0, 02773 timeout); 02774 #endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02775 02776 switch (n) 02777 { 02778 case -1: 02779 if (errno == EINTR && restart) 02780 continue; 02781 else 02782 return -1; 02783 /* NOTREACHED */ 02784 case 0: 02785 if (timeout != 0 02786 && timeout->sec () == 0 02787 && timeout->usec () == 0) 02788 errno = EWOULDBLOCK; 02789 else 02790 errno = ETIMEDOUT; 02791 return -1; 02792 /* NOTREACHED */ 02793 case 1: 02794 return 0; 02795 /* NOTREACHED */ 02796 default: 02797 errno = EINVAL; 02798 return -1; 02799 /* NOTREACHED */ 02800 } 02801 } 02802 } |
|
Wait up to timeout amount of time to complete an actively established non-blocking connection. If is_tli is non-0 then we are being called by a TLI wrapper (which behaves slightly differently from a socket wrapper). Definition at line 2573 of file ACE.cpp. References ACE_TRACE, ECONNREFUSED, ETIME, EWOULDBLOCK, ACE_OS::getsockopt(), ACE_Handle_Set::is_set(), ACE_OS::poll(), recv(), ACE_OS::select(), and ACE_Handle_Set::set_bit(). Referenced by ACE_TLI_Connector::complete(), ACE_SOCK_SEQPACK_Connector::complete(), and ACE_SOCK_Connector::complete().
02576 { 02577 ACE_TRACE ("ACE::handle_timed_complete"); 02578 02579 #if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02580 02581 struct pollfd fds; 02582 02583 fds.fd = h; 02584 fds.events = POLLIN | POLLOUT; 02585 fds.revents = 0; 02586 02587 #else 02588 ACE_Handle_Set rd_handles; 02589 ACE_Handle_Set wr_handles; 02590 02591 rd_handles.set_bit (h); 02592 wr_handles.set_bit (h); 02593 #endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02594 02595 #if defined (ACE_WIN32) 02596 // Winsock is different - it sets the exception bit for failed connect, 02597 // unlike other platforms, where the read bit is set. 02598 ACE_Handle_Set ex_handles; 02599 ex_handles.set_bit (h); 02600 #endif /* ACE_WIN32 */ 02601 02602 int need_to_check = 0; 02603 int known_failure = 0; 02604 02605 #if defined (ACE_WIN32) 02606 int n = ACE_OS::select (0, // Ignored on Windows: int (h) + 1, 02607 0, 02608 wr_handles, 02609 ex_handles, 02610 timeout); 02611 #else 02612 # if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02613 02614 int n = ACE_OS::poll (&fds, 1, timeout); 02615 02616 # else 02617 int n = ACE_OS::select (int (h) + 1, 02618 rd_handles, 02619 wr_handles, 02620 0, 02621 timeout); 02622 # endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02623 #endif /* ACE_WIN32 */ 02624 02625 // If we failed to connect within the time period allocated by the 02626 // caller, then we fail (e.g., the remote host might have been too 02627 // busy to accept our call). 02628 if (n <= 0) 02629 { 02630 if (n == 0 && timeout != 0) 02631 errno = ETIME; 02632 return ACE_INVALID_HANDLE; 02633 } 02634 02635 // Usually, a ready-for-write handle is successfully connected, and 02636 // ready-for-read (exception on Win32) is a failure. On fails, we 02637 // need to grab the error code via getsockopt. On possible success for 02638 // any platform where we can't tell just from select() (e.g. AIX), 02639 // we also need to check for success/fail. 02640 #if defined (ACE_WIN32) 02641 ACE_UNUSED_ARG (is_tli); 02642 02643 // On Win32, ex_handle set indicates a failure. We'll do the check 02644 // to try and get an errno value, but the connect failed regardless of 02645 // what getsockopt says about the error. 02646 if (ex_handles.is_set (h)) 02647 { 02648 need_to_check = 1; 02649 known_failure = 1; 02650 } 02651 #elif defined (ACE_VXWORKS) 02652 ACE_UNUSED_ARG (is_tli); 02653 02654 // Force the check on VxWorks. The read handle for "h" is not set, 02655 // so "need_to_check" is false at this point. The write handle is 02656 // set, for what it's worth. 02657 need_to_check = 1; 02658 #else 02659 if (is_tli) 02660 02661 # if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02662 need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT); 02663 # else 02664 need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h); 02665 # endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02666 02667 else 02668 #if defined(AIX) 02669 // AIX is broken... both success and failed connect will set the 02670 // write handle only, so always check. 02671 need_to_check = 1; 02672 #else 02673 # if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) 02674 need_to_check = (fds.revents & POLLIN); 02675 # else 02676 need_to_check = rd_handles.is_set (h); 02677 # endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ 02678 #endif /* AIX */ 02679 #endif /* ACE_WIN32 */ 02680 02681 if (need_to_check) 02682 { 02683 #if defined (SOL_SOCKET) && defined (SO_ERROR) 02684 int sock_err = 0; 02685 int sock_err_len = sizeof (sock_err); 02686 int sockopt_ret = ACE_OS::getsockopt (h, SOL_SOCKET, SO_ERROR, 02687 (char *)&sock_err, &sock_err_len); 02688 if (sockopt_ret < 0) 02689 { 02690 h = ACE_INVALID_HANDLE; 02691 } 02692 02693 if (sock_err != 0 || known_failure) 02694 { 02695 h = ACE_INVALID_HANDLE; 02696 errno = sock_err; 02697 } 02698 #else 02699 char dummy; 02700 02701 // The following recv() won't block provided that the 02702 // ACE_NONBLOCK flag has not been turned off . 02703 n = ACE::recv (h, &dummy, 1, MSG_PEEK); 02704 02705 // If no data was read/peeked at, check to see if it's because 02706 // of a non-connected socket (and therefore an error) or there's 02707 // just no data yet. 02708 if (n <= 0) 02709 { 02710 if (n == 0) 02711 { 02712 errno = ECONNREFUSED; 02713 h = ACE_INVALID_HANDLE; 02714 } 02715 else if (errno != EWOULDBLOCK && errno != EAGAIN) 02716 h = ACE_INVALID_HANDLE; 02717 } 02718 #endif 02719 } 02720 02721 // 1. The HANDLE is ready for writing and doesn't need to be checked or 02722 // 2. recv() returned an indication of the state of the socket - if there is 02723 // either data present, or a recv is legit but there's no data yet, 02724 // the connection was successfully established. 02725 return h; 02726 } |
|
Wait up to timeout> amount of time to actively open a device. This method doesn't perform the Definition at line 17 of file Handle_Ops.cpp. References ACE_NONBLOCK, ACE_TCHAR, ACE_TRACE, ETIMEDOUT, EWOULDBLOCK, ACE_OS::open(), ACE_Time_Value::sec(), and ACE_Time_Value::usec(). Referenced by ACE_UPIPE_Connector::connect(), ACE_SPIPE_Connector::connect(), ACE_FILE_Connector::connect(), and ACE_DEV_Connector::connect().
00022 { 00023 ACE_TRACE ("ACE::handle_timed_open"); 00024 00025 if (timeout != 0) 00026 { 00027 #if !defined (ACE_WIN32) 00028 // On Win32, ACE_NONBLOCK gets recognized as O_WRONLY so we 00029 // don't use it there 00030 flags |= ACE_NONBLOCK; 00031 #endif /* ACE_WIN32 */ 00032 00033 // Open the named pipe or file using non-blocking mode... 00034 ACE_HANDLE handle = ACE_OS::open (name, 00035 flags, 00036 perms, 00037 sa); 00038 if (handle == ACE_INVALID_HANDLE 00039 && (errno == EWOULDBLOCK 00040 && (timeout->sec () > 0 || timeout->usec () > 0))) 00041 // This expression checks if we were polling. 00042 errno = ETIMEDOUT; 00043 00044 return handle; 00045 } 00046 else 00047 return ACE_OS::open (name, flags, perms, sa); 00048 } |
|
Timed wait for handle to get write ready.
Definition at line 252 of file ACE.inl. References handle_ready(). Referenced by enter_send_timedwait(), send_n_i(), sendv_n_i(), and t_snd_n_i().
00254 { 00255 return ACE::handle_ready (handle, 00256 timeout, 00257 0, 00258 1, 00259 0); 00260 } |
|
Computes the hash value of {str} using the "Hash PJW" routine.
Definition at line 347 of file ACE.cpp.
00348 { 00349 u_long hash = 0; 00350 00351 for (size_t i = 0; i < len; i++) 00352 { 00353 // @@ UNICODE: Does this function do the correct thing with wchar's? 00354 00355 const wchar_t temp = str[i]; 00356 hash = (hash << 4) + (temp * 13); 00357 00358 u_long g = hash & 0xf0000000; 00359 00360 if (g) 00361 { 00362 hash ^= (g >> 24); 00363 hash ^= g; 00364 } 00365 } 00366 00367 return hash; 00368 } |
|
Computes the hash value of {str} using the "Hash PJW" routine.
Definition at line 371 of file ACE.cpp. References hash_pjw().
00372 { 00373 return ACE::hash_pjw (str, ACE_OS::strlen (str)); 00374 } |
|
Computes the hash value of {str} using the "Hash PJW" routine.
Definition at line 318 of file ACE.cpp.
00319 { 00320 u_long hash = 0; 00321 00322 for (size_t i = 0; i < len; i++) 00323 { 00324 const char temp = str[i]; 00325 hash = (hash << 4) + (temp * 13); 00326 00327 u_long g = hash & 0xf0000000; 00328 00329 if (g) 00330 { 00331 hash ^= (g >> 24); 00332 hash ^= g; 00333 } 00334 } 00335 00336 return hash; 00337 } |
|
Computes the hash value of {str} using the "Hash PJW" routine.
Definition at line 340 of file ACE.cpp. Referenced by ACE_Filecache::create(), ACE_Filecache::fetch(), ACE_Filecache::finish(), ACE_UNIX_Addr::hash(), ACE_String_Base< CHAR >::hash(), ACE_SString::hash(), hash_pjw(), ACE_Hash< wchar_t * >::operator()(), ACE_Hash< const wchar_t * >::operator()(), ACE_Hash< char * >::operator()(), ACE_Hash< const char * >::operator()(), and ACE_Filecache::remove().
00341 { 00342 return ACE::hash_pjw (str, ACE_OS::strlen (str)); 00343 } |
|
Convert a hex character to its byte representation.
Definition at line 325 of file ACE.inl. References ACE_LIB_TEXT, and ACE_TCHAR.
00326 { 00327 if (isdigit (c)) 00328 return (u_char) (c - ACE_LIB_TEXT ('0')); 00329 else if (islower (c)) 00330 return (u_char) (10 + c - ACE_LIB_TEXT ('a')); 00331 else 00332 return (u_char) (10 + c - ACE_LIB_TEXT ('A')); 00333 } |
|
This class implements the functions for the initialization and shutting down ACE. These functions are called only once per ACE invokation.
Definition at line 15 of file Init_ACE.cpp. References ACE_Object_Manager::init(), and ACE_Object_Manager::instance().
00016 { 00017 // Don't use ACE_TRACE, because Object_Manager might not have been 00018 // instantiated yet. 00019 // ACE_TRACE ("ACE::init"); 00020 00021 ++ACE::init_fini_count_; 00022 00023 return ACE_Object_Manager::instance ()->init (); 00024 } |
|
Returns 1 if IPv6 is enabled on the current host; 0 if not. This is an execution-time check. If ACE has not been compiled with ACE_HAS_IPV6, it always returns 0. If ACE_HAS_IPV6 is enabled, this function tries to create a PF_INET6 socket, returning 1 if it succeeds, and 0 if it fails. Caches the result so it only gets checked once. Definition at line 1497 of file Sock_Connect.cpp. References ACE_GUARD_RETURN, ace_ipv6_enabled, ACE_OS::closesocket(), and ACE_OS::socket(). Referenced by ACE_INET_Addr::determine_type(), ACE_SOCK_SEQPACK_Acceptor::open(), ACE_SOCK_Dgram::open(), and ACE_SOCK_Acceptor::open().
01498 { 01499 #if defined (ACE_HAS_IPV6) 01500 if (ace_ipv6_enabled == -1) 01501 { 01502 // Perform Double-Checked Locking Optimization. 01503 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 01504 *ACE_Static_Object_Lock::instance (), 0)); 01505 01506 if (ace_ipv6_enabled == -1) 01507 { 01508 // Determine if the kernel has IPv6 support by attempting to 01509 // create a PF_INET6 socket and see if it fails. 01510 ACE_HANDLE s = ACE_OS::socket (PF_INET6, SOCK_DGRAM, 0); 01511 if (s == ACE_INVALID_HANDLE) 01512 { 01513 ace_ipv6_enabled = 0; 01514 } 01515 else 01516 { 01517 ace_ipv6_enabled = 1; 01518 ACE_OS::closesocket (s); 01519 } 01520 } 01521 } 01522 01523 return ace_ipv6_enabled; 01524 #else /* ACE_HAS_IPV6 */ 01525 return 0; 01526 #endif /* !ACE_HAS_IPV6 */ 01527 } |
|
Function that can burn up noticeable CPU time: brute-force determination of whether number n is prime. Returns 0 if it is prime, or the smallest factor if it is not prime. min_factor and max_factor can be used to partition the work among threads. For just one thread, typical values are 2 and n/2. Definition at line 3076 of file ACE.cpp.
03079 { 03080 if (n > 3) 03081 for (u_long factor = min_factor; 03082 factor <= max_factor; 03083 ++factor) 03084 if (n / factor * factor == n) 03085 return factor; 03086 03087 return 0; 03088 } |
|
Determins whether the given error code corresponds to to a WinSock error. If so returns true, false otherwise. For internal use only.
Definition at line 3243 of file ACE.cpp. Referenced by ACE_OS::strerror().
03244 { 03245 #if defined (ACE_WIN32) 03246 switch (error) 03247 { 03248 case WSAVERNOTSUPPORTED: 03249 case WSASYSNOTREADY: 03250 case WSAEINVAL: 03251 case WSAHOST_NOT_FOUND: 03252 case WSATRY_AGAIN: 03253 case WSANO_RECOVERY: 03254 case WSANO_DATA: 03255 /* 03256 case WSANO_ADDRESS: 03257 */ 03258 case WSANOTINITIALISED: 03259 case WSAENETDOWN: 03260 case WSAEINPROGRESS: 03261 case WSAEINTR: 03262 case WSAEAFNOSUPPORT: 03263 case WSAEMFILE: 03264 case WSAENOBUFS: 03265 case WSAEPROTONOSUPPORT: 03266 case WSAEPROTOTYPE: 03267 case WSAESOCKTNOSUPPORT: 03268 case WSAENOTSOCK: 03269 case WSAEWOULDBLOCK: 03270 case WSAEADDRINUSE: 03271 case WSAECONNABORTED: 03272 case WSAECONNRESET: 03273 case WSAENOTCONN: 03274 case WSAETIMEDOUT: 03275 case WSAECONNREFUSED: 03276 case WSAEHOSTDOWN: 03277 case WSAEHOSTUNREACH: 03278 case WSAEADDRNOTAVAIL: 03279 case WSAEISCONN: 03280 case WSAENETRESET: 03281 case WSAEMSGSIZE: 03282 case WSAENETUNREACH: 03283 case WSAEFAULT: 03284 case WSAEDISCON: 03285 case WSAEACCES: 03286 case WSAESHUTDOWN: 03287 case WSAEPROCLIM: 03288 case WSAEALREADY: 03289 case WSAEPFNOSUPPORT: 03290 case WSAENOPROTOOPT: 03291 case WSATYPE_NOT_FOUND: 03292 case WSAEOPNOTSUPP: 03293 return true; 03294 } 03295 #else 03296 ACE_UNUSED_ARG (error); 03297 #endif /* ACE_WIN32 */ 03298 return false; 03299 } |
|
Finds the file filename either using an absolute path or using a relative path in conjunction with ACE_LD_SEARCH_PATH (e.g., $LD_LIBRARY_PATH on UNIX or the directories scaned by Win32 API SearchPath on Win32). This function will add appropriate suffix (e.g., .dll on Win32 or .so on UNIX) according to the OS platform. In addition, this function will apply the appropriate prefix (e.g., "lib" on UNIX and "" on Win32) if the filename doesn't match directly. Definition at line 121 of file Lib_Find.cpp. References ACE_OS::access(), ACE_DIRECTORY_SEPARATOR_CHAR, ACE_DLL_PREFIX, ACE_DLL_SUFFIX, ACE_ERROR, ACE_LD_SEARCH_PATH, ACE_LD_SEARCH_PATH_SEPARATOR_STR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, ACE_TRACE, F_OK, ACE_OS::free(), ACE_OS::getenv(), LM_WARNING, ACE_OS::malloc(), MAXPATHLEN, ACE_OS::sprintf(), ACE_OS::strcasecmp(), ACE_OS::strcat(), ACE_OS::strcmp(), ACE_OS::strcpy(), ACE_OS::strdup(), ACE_OS::strlen(), ACE_OS::strrchr(), strrepl(), and strsplit_r(). Referenced by ldopen(), and ACE_DLL_Handle::open().
00124 { 00125 ACE_TRACE ("ACE::ldfind"); 00126 #if defined (ACE_OPENVMS) 00127 if (strlen(filename) >= maxpathnamelen) 00128 { 00129 errno = ENOMEM; 00130 return -1; 00131 } 00132 00133 dsc$descriptor nameDsc; 00134 nameDsc.dsc$b_class = DSC$K_CLASS_S; 00135 nameDsc.dsc$b_dtype = DSC$K_DTYPE_T; 00136 nameDsc.dsc$w_length = strlen(filename); 00137 nameDsc.dsc$a_pointer = (char*)filename; 00138 00139 char symbol[] = "NULL"; 00140 dsc$descriptor symbolDsc; 00141 symbolDsc.dsc$b_class = DSC$K_CLASS_S; 00142 symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T; 00143 symbolDsc.dsc$w_length = strlen(symbol); 00144 symbolDsc.dsc$a_pointer = symbol; 00145 00146 int symbolValue; 00147 int result; 00148 try 00149 { 00150 result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); 00151 } 00152 catch (chf$signal_array& sig) 00153 { 00154 result = sig.chf$l_sig_name; 00155 } 00156 00157 int severity = result & STS$M_SEVERITY; 00158 int conditionId = result & STS$M_COND_ID; 00159 if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || 00160 (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) 00161 { 00162 strcpy(pathname, filename); 00163 return 0; 00164 } 00165 00166 if (strlen(filename) + strlen(ACE_DLL_PREFIX) >= maxpathnamelen) 00167 { 00168 errno = ENOMEM; 00169 return -1; 00170 } 00171 00172 00173 strcpy(pathname, ACE_DLL_PREFIX); 00174 strcat(pathname, filename); 00175 nameDsc.dsc$w_length = strlen(pathname); 00176 nameDsc.dsc$a_pointer = pathname; 00177 try 00178 { 00179 result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0); 00180 } 00181 catch (chf$signal_array& sig) 00182 { 00183 result = sig.chf$l_sig_name; 00184 } 00185 00186 severity = result & STS$M_SEVERITY; 00187 conditionId = result & STS$M_COND_ID; 00188 if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO || 00189 (severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID))) 00190 { 00191 return 0; 00192 } 00193 errno = ENOENT; 00194 return -1; 00195 #endif /* ACE_OPENVMS */ 00196 00197 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && \ 00198 !defined (ACE_HAS_PHARLAP) 00199 ACE_TCHAR expanded_filename[MAXPATHLEN]; 00200 if (ACE_TEXT_ExpandEnvironmentStrings (filename, 00201 expanded_filename, 00202 sizeof expanded_filename 00203 / sizeof (ACE_TCHAR))) 00204 filename = expanded_filename; 00205 #endif /* ACE_WIN32 && !ACE_HAS_WINCE && !ACE_HAS_PHARLAP */ 00206 00207 ACE_TCHAR tempcopy[MAXPATHLEN + 1]; 00208 ACE_TCHAR searchpathname[MAXPATHLEN + 1]; 00209 #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) 00210 ACE_TCHAR decorator[] = ACE_LD_DECORATOR_STR; 00211 ACE_TCHAR searchfilename[MAXPATHLEN + sizeof(decorator) / sizeof (ACE_TCHAR)]; 00212 #else 00213 ACE_TCHAR searchfilename[MAXPATHLEN + 1]; 00214 #endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ 00215 00216 // Create a copy of filename to work with. 00217 if (ACE_OS::strlen (filename) + 1 00218 > (sizeof tempcopy / sizeof (ACE_TCHAR))) 00219 { 00220 errno = ENOMEM; 00221 return -1; 00222 } 00223 else 00224 ACE_OS::strcpy (tempcopy, filename); 00225 00226 // Insert canonical directory separators. 00227 ACE_TCHAR *separator_ptr; 00228 00229 #if (ACE_DIRECTORY_SEPARATOR_CHAR != '/') 00230 // Make all the directory separators "canonical" to simplify 00231 // subsequent code. 00232 ACE::strrepl (tempcopy, ACE_DIRECTORY_SEPARATOR_CHAR, '/'); 00233 #endif /* ACE_DIRECTORY_SEPARATOR_CHAR */ 00234 00235 // Separate filename from pathname. 00236 separator_ptr = ACE_OS::strrchr (tempcopy, '/'); 00237 00238 // This is a relative path. 00239 if (separator_ptr == 0) 00240 { 00241 searchpathname[0] = '\0'; 00242 ACE_OS::strcpy (searchfilename, tempcopy); 00243 } 00244 else // This is an absolute path. 00245 { 00246 ACE_OS::strcpy (searchfilename, separator_ptr + 1); 00247 separator_ptr[1] = '\0'; 00248 ACE_OS::strcpy (searchpathname, tempcopy); 00249 } 00250 00251 int got_suffix = 0; 00252 00253 // Check to see if this has an appropriate DLL suffix for the OS 00254 // platform. 00255 ACE_TCHAR *s = ACE_OS::strrchr (searchfilename, '.'); 00256 00257 const ACE_TCHAR *dll_suffix = ACE_DLL_SUFFIX; 00258 00259 if (s != 0) 00260 { 00261 // If we have a dot, we have a suffix 00262 got_suffix = 1; 00263 00264 // Check whether this matches the appropriate platform-specific 00265 // suffix. 00266 #if defined (ACE_WIN32) 00267 // Use <ACE_OS::strcasecmp> on any platform with 00268 // case-insensitive filenames. 00269 if (ACE_OS::strcasecmp (s, dll_suffix) != 0) 00270 #else 00271 if (ACE_OS::strcmp (s, dll_suffix) != 0) 00272 #endif /* ACE_WIN32 */ 00273 { 00274 ACE_ERROR ((LM_WARNING, 00275 ACE_LIB_TEXT ("Warning: improper suffix for a ") 00276 ACE_LIB_TEXT ("shared library on this platform: %s\n"), 00277 s)); 00278 } 00279 } 00280 00281 // Make sure we've got enough space in searchfilename. 00282 if (ACE_OS::strlen (searchfilename) 00283 + ACE_OS::strlen (ACE_DLL_PREFIX) 00284 + got_suffix ? 0 : ACE_OS::strlen (dll_suffix) >= (sizeof searchfilename / 00285 sizeof (ACE_TCHAR))) 00286 { 00287 errno = ENOMEM; 00288 return -1; 00289 } 00290 00291 #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) 00292 size_t len_searchfilename = ACE_OS::strlen (searchfilename); 00293 if (! got_suffix) 00294 ACE_OS::strcpy (searchfilename + len_searchfilename, 00295 decorator); 00296 00297 for (int tag = 1; tag >= 0; tag --) 00298 { 00299 if (tag == 0) 00300 searchfilename [len_searchfilename] = 0; 00301 00302 #endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ 00303 // Use absolute pathname if there is one. 00304 if (ACE_OS::strlen (searchpathname) > 0) 00305 { 00306 if (ACE_OS::strlen (searchfilename) 00307 + ACE_OS::strlen (searchpathname) >= maxpathnamelen) 00308 { 00309 errno = ENOMEM; 00310 return -1; 00311 } 00312 else 00313 { 00314 #if (ACE_DIRECTORY_SEPARATOR_CHAR != '/') 00315 // Revert to native path name separators. 00316 ACE::strrepl (searchpathname, 00317 '/', 00318 ACE_DIRECTORY_SEPARATOR_CHAR); 00319 #endif /* ACE_DIRECTORY_SEPARATOR_CHAR */ 00320 // First, try matching the filename *without* adding a 00321 // prefix. 00322 ACE_OS::sprintf (pathname, 00323 ACE_LIB_TEXT ("%s%s%s"), 00324 searchpathname, 00325 searchfilename, 00326 got_suffix ? ACE_LIB_TEXT ("") : dll_suffix); 00327 if (ACE_OS::access (pathname, F_OK) == 0) 00328 return 0; 00329 00330 // Second, try matching the filename *with* adding a prefix. 00331 ACE_OS::sprintf (pathname, 00332 ACE_LIB_TEXT ("%s%s%s%s"), 00333 searchpathname, 00334 ACE_DLL_PREFIX, 00335 searchfilename, 00336 got_suffix ? ACE_LIB_TEXT ("") : dll_suffix); 00337 if (ACE_OS::access (pathname, F_OK) == 0) 00338 return 0; 00339 } 00340 } 00341 00342 // Use relative filenames via LD_LIBRARY_PATH or PATH (depending on 00343 // OS platform). 00344 else 00345 { 00346 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) 00347 ACE_TCHAR *file_component = 0; 00348 DWORD pathlen = 00349 ACE_TEXT_SearchPath (0, 00350 searchfilename, 00351 dll_suffix, 00352 static_cast<DWORD> (maxpathnamelen), 00353 pathname, 00354 &file_component); 00355 if (pathlen >= maxpathnamelen) 00356 { 00357 errno = ENOMEM; 00358 return -1; 00359 } 00360 else if (pathlen > 0) 00361 return 0; 00362 00363 // In case not found we should try again with the ACE_DLL_PREFIX 00364 // prefixed 00365 ACE_OS::strcpy (searchfilename, ACE_DLL_PREFIX); 00366 ACE_OS::strcat (searchfilename, tempcopy); 00367 pathlen = 00368 ACE_TEXT_SearchPath (0, 00369 searchfilename, 00370 dll_suffix, 00371 static_cast<DWORD> (maxpathnamelen), 00372 pathname, 00373 &file_component); 00374 if (pathlen >= maxpathnamelen) 00375 { 00376 errno = ENOMEM; 00377 return -1; 00378 } 00379 else if (pathlen > 0) 00380 return 0; 00381 #else 00382 ACE_TCHAR *ld_path; 00383 # if defined ACE_DEFAULT_LD_SEARCH_PATH 00384 ld_path = ACE_DEFAULT_LD_SEARCH_PATH; 00385 # else 00386 # if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) 00387 ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH); 00388 # else 00389 // Wide-char, non-Windows only offers char * getenv. So capture 00390 // it, translate to wide-char, and continue. 00391 ACE_Ascii_To_Wide wide_ldpath 00392 (ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH))); 00393 ld_path = wide_ldpath.wchar_rep (); 00394 # endif /* ACE_WIN32 || !ACE_USES_WCHAR */ 00395 # endif /* ACE_DEFAULT_LD_SEARCH_PATH */ 00396 00397 #if defined (ACE_HAS_WINCE) 00398 ACE_TCHAR *ld_path_temp = 0; 00399 if (ld_path != 0) 00400 { 00401 ld_path_temp = (ACE_TCHAR *) 00402 ACE_OS::malloc ((ACE_OS::strlen (ld_path) + 2) 00403 * sizeof (ACE_TCHAR)); 00404 if (ld_path_temp != 0) 00405 { 00406 ACE_OS::strcpy (ld_path_temp, 00407 ACE_LD_SEARCH_PATH_SEPARATOR_STR); 00408 00409 ACE_OS::strcat (ld_path_temp, ld_path); 00410 ld_path = ld_path_temp; 00411 } 00412 else 00413 { 00414 ACE_OS::free ((void *) ld_path_temp); 00415 ld_path = ld_path_temp = 0; 00416 } 00417 } 00418 #endif /* ACE_HAS_WINCE */ 00419 00420 if (ld_path != 0 00421 && (ld_path = ACE_OS::strdup (ld_path)) != 0) 00422 { 00423 // strtok has the strange behavior of not separating the 00424 // string ":/foo:/bar" into THREE tokens. One would expect 00425 // that the first iteration the token would be an empty 00426 // string, the second iteration would be "/foo", and the 00427 // third iteration would be "/bar". However, this is not 00428 // the case; one only gets two iterations: "/foo" followed 00429 // by "/bar". 00430 00431 // This is especially a problem in parsing Unix paths 00432 // because it is permissible to specify 'the current 00433 // directory' as an empty entry. So, we introduce the 00434 // following special code to cope with this: 00435 00436 // Look at each dynamic lib directory in the search path. 00437 00438 ACE_TCHAR *nextholder = 0; 00439 const ACE_TCHAR *path_entry = 00440 ACE::strsplit_r (ld_path, 00441 ACE_LD_SEARCH_PATH_SEPARATOR_STR, 00442 nextholder); 00443 int result = 0; 00444 00445 for (;;) 00446 { 00447 // Check if at end of search path. 00448 if (path_entry == 0) 00449 { 00450 errno = ENOENT; 00451 result = -1; 00452 break; 00453 } 00454 else if (ACE_OS::strlen (path_entry) 00455 + 1 00456 + ACE_OS::strlen (searchfilename) 00457 >= maxpathnamelen) 00458 { 00459 errno = ENOMEM; 00460 result = -1; 00461 break; 00462 } 00463 // This works around the issue where a path might have 00464 // an empty component indicating 'current directory'. 00465 // We need to do it here rather than anywhere else so 00466 // that the loop condition will still work. 00467 else if (path_entry[0] == '\0') 00468 path_entry = ACE_LIB_TEXT ("."); 00469 00470 // First, try matching the filename *without* adding a 00471 // prefix. 00472 ACE_OS::sprintf (pathname, 00473 ACE_LIB_TEXT ("%s%c%s%s"), 00474 path_entry, 00475 ACE_DIRECTORY_SEPARATOR_CHAR, 00476 searchfilename, 00477 got_suffix ? ACE_LIB_TEXT ("") : dll_suffix); 00478 if (ACE_OS::access (pathname, F_OK) == 0) 00479 break; 00480 00481 // Second, try matching the filename *with* adding a 00482 // prefix. 00483 ACE_OS::sprintf (pathname, 00484 ACE_LIB_TEXT ("%s%c%s%s%s"), 00485 path_entry, 00486 ACE_DIRECTORY_SEPARATOR_CHAR, 00487 ACE_DLL_PREFIX, 00488 searchfilename, 00489 got_suffix ? ACE_LIB_TEXT ("") : dll_suffix); 00490 if (ACE_OS::access (pathname, F_OK) == 0) 00491 break; 00492 00493 // Fetch the next item in the path 00494 path_entry = 00495 ACE::strsplit_r (0, 00496 ACE_LD_SEARCH_PATH_SEPARATOR_STR, 00497 nextholder); 00498 } 00499 00500 #if defined (ACE_HAS_WINCE) 00501 if (ld_path_temp != 0) 00502 ACE_OS::free (ld_path_temp); 00503 #endif /* ACE_HAS_WINCE */ 00504 ACE_OS::free ((void *) ld_path); 00505 #if defined (ACE_HAS_WINCE) && defined (ACE_LD_DECORATOR_STR) && \ 00506 !defined (ACE_DISABLE_DEBUG_DLL_CHECK) 00507 if (result == 0 || tag == 0) 00508 #endif /* ACE_HAS_WINCE && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ 00509 return result; 00510 } 00511 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */ 00512 } 00513 #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) 00514 } 00515 #endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */ 00516 00517 errno = ENOENT; 00518 return -1; 00519 } |
|
Transforms entry_point into a form that can be located in a dynamic library using . For example, with Win32/Borland extern "C" functions which use the default calling convention have a '_' prepended. Always returns a buffer that has been dynamically allocated using . Definition at line 537 of file Lib_Find.cpp. References ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_OS::strcat(), ACE_OS::strcpy(), and ACE_OS::strlen().
00538 { 00539 ACE_TRACE ("ACE::ldname"); 00540 00541 #if defined(ACE_NEEDS_DL_UNDERSCORE) 00542 size_t size = 00543 1 // leading '_' 00544 + ACE_OS::strlen (entry_point) 00545 + 1; 00546 00547 ACE_TCHAR *new_name; 00548 ACE_NEW_RETURN (new_name, 00549 ACE_TCHAR[size], 00550 0); 00551 00552 ACE_OS::strcpy (new_name, ACE_LIB_TEXT ("_")); 00553 ACE_OS::strcat (new_name, entry_point); 00554 00555 return new_name; 00556 #else /* ACE_NEEDS_DL_UNDERSCORE */ 00557 size_t size = 00558 ACE_OS::strlen (entry_point) 00559 + 1; 00560 00561 ACE_TCHAR *new_name; 00562 ACE_NEW_RETURN (new_name, 00563 ACE_TCHAR[size], 00564 0); 00565 00566 ACE_OS::strcpy (new_name, entry_point); 00567 return new_name; 00568 #endif /* ACE_NEEDS_DL_UNDERSCORE */ 00569 } |
|
Uses Definition at line 522 of file Lib_Find.cpp. References ACE_TCHAR, ACE_TRACE, ACE_OS::fopen(), ldfind(), and MAXPATHLEN.
00524 { 00525 ACE_TRACE ("ACE::ldopen"); 00526 00527 ACE_TCHAR buf[MAXPATHLEN + 1]; 00528 if (ACE::ldfind (filename, 00529 buf, 00530 sizeof (buf) /sizeof (ACE_TCHAR)) == -1) 00531 return 0; 00532 else 00533 return ACE_OS::fopen (buf, type); 00534 } |
|
Computes the base 2 logarithm of {num}.
Definition at line 296 of file ACE.inl. Referenced by ACE_Log_Record::priority(), and ACE_Log_Record::priority_name().
00297 { 00298 u_long log = 0; 00299 00300 for (; num > 1; ++log) 00301 num >>= 1; 00302 00303 return log; 00304 } |
|
e.g., the "5" in ACE 5.1.12.
Definition at line 107 of file ACE.cpp. References ACE_MAJOR_VERSION.
00108 { 00109 return ACE_MAJOR_VERSION; 00110 } |
|
Map troublesome win32 errno values to values that standard C strerr function understands. Thank you Microsoft. Definition at line 3003 of file ACE.cpp. Referenced by ACE_Log_Msg::log().
03004 { 03005 switch (error) 03006 { 03007 #if defined (ACE_WIN32) 03008 case WSAEWOULDBLOCK: 03009 return EAGAIN; // Same as UNIX errno EWOULDBLOCK. 03010 #endif /* ACE_WIN32 */ 03011 } 03012 03013 return error; 03014 } |
|
Returns the maximum number of open handles currently permitted in this process. This maximum may be extended using Definition at line 2914 of file ACE.cpp. References ACE_NOTSUP_RETURN, ACE_TRACE, ACE_OS::getrlimit(), and ACE_OS::sysconf(). Referenced by ACE_POSIX_AIOCB_Proactor::check_max_aio_num(), daemonize(), and set_handle_limit().
02915 { 02916 ACE_TRACE ("ACE::max_handles"); 02917 #if defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT) 02918 rlimit rl; 02919 int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); 02920 # if !defined (RLIM_INFINITY) 02921 if (r == 0) 02922 return rl.rlim_cur; 02923 #else 02924 if (r == 0 && rl.rlim_cur != RLIM_INFINITY) 02925 return rl.rlim_cur; 02926 // If == RLIM_INFINITY, fall through to the ACE_LACKS_RLIMIT sections 02927 # endif /* RLIM_INFINITY */ 02928 #endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */ 02929 02930 #if defined (_SC_OPEN_MAX) 02931 return ACE_OS::sysconf (_SC_OPEN_MAX); 02932 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) 02933 return maxFiles; 02934 #elif defined (FD_SETSIZE) 02935 return FD_SETSIZE; 02936 #else 02937 ACE_NOTSUP_RETURN (-1); 02938 #endif /* _SC_OPEN_MAX */ 02939 } |
|
Calculates the minimum enclosing frame size for the given values.
Definition at line 3033 of file ACE.cpp. References gcd().
03034 { 03035 // if one of the periods is zero, treat it as though it as 03036 // uninitialized and return the other period as the frame size 03037 if (0 == period1) 03038 { 03039 return period2; 03040 } 03041 if (0 == period2) 03042 { 03043 return period1; 03044 } 03045 03046 // if neither is zero, find the greatest common divisor of the two periods 03047 u_long greatest_common_divisor = ACE::gcd (period1, period2); 03048 03049 // explicitly consider cases to reduce risk of possible overflow errors 03050 if (greatest_common_divisor == 1) 03051 { 03052 // periods are relative primes: just multiply them together 03053 return period1 * period2; 03054 } 03055 else if (greatest_common_divisor == period1) 03056 { 03057 // the first period divides the second: return the second 03058 return period2; 03059 } 03060 else if (greatest_common_divisor == period2) 03061 { 03062 // the second period divides the first: return the first 03063 return period1; 03064 } 03065 else 03066 { 03067 // the current frame size and the entry's effective period 03068 // have a non-trivial greatest common divisor: return the 03069 // product of factors divided by those in their gcd. 03070 return (period1 * period2) / greatest_common_divisor; 03071 } 03072 } |
|
e.g., the "1" in ACE 5.1.12.
Definition at line 113 of file ACE.cpp. References ACE_MINOR_VERSION.
00114 { 00115 return ACE_MINOR_VERSION; 00116 } |
|
Hex conversion utility.
Definition at line 307 of file ACE.inl. References ACE_LIB_TEXT, and ACE_TCHAR.
00308 { 00309 // Hexadecimal characters. 00310 #if defined (ACE_VXWORKS) && !defined (__DCPLUSPLUS__) 00311 // temporary solution to prevent Windriver GNU toolchains from spewing 00312 // loads of warnings when inlining. 00313 // problem (incorrect warning leftover from older GNU) has been reported as 00314 // TSR to Windriver. 00315 const ACE_TCHAR hex_chars[] = ACE_LIB_TEXT ("0123456789abcdef"); 00316 #else 00317 static const ACE_TCHAR hex_chars[] = ACE_LIB_TEXT ("0123456789abcdef"); 00318 #endif 00319 00320 // @@ UNICODE does this work? 00321 return hex_chars[n & 0x0f]; 00322 } |
|
Opening the temp file. File is automagically unlinked when it is closed. This is useful for have temp files. Definition at line 641 of file Lib_Find.cpp. References ACE_TCHAR, ACE_OS::open(), and ACE_OS::unlink().
00642 { 00643 #if defined (ACE_WIN32) 00644 ACE_UNUSED_ARG (perm); 00645 ACE_HANDLE handle = ACE_OS::open (name, 00646 mode, 00647 FILE_SHARE_READ 00648 | FILE_SHARE_WRITE 00649 | FILE_SHARE_DELETE); 00650 #else 00651 // Open it. 00652 ACE_HANDLE handle = ACE_OS::open (name, mode, perm); 00653 #endif /* ACE_WIN32 */ 00654 00655 if (handle == ACE_INVALID_HANDLE) 00656 return ACE_INVALID_HANDLE; 00657 00658 // Unlink it so that the file will be removed automatically when the 00659 // process goes away. 00660 if (ACE_OS::unlink (name) == -1) 00661 return ACE_INVALID_HANDLE; 00662 else 00663 // Return the handle. 00664 return handle; 00665 } |
|
Check if error indicates the process being out of handles (file descriptors). Definition at line 65 of file ACE.cpp. References EADDRNOTAVAIL, ENFILE, ENOBUFS, ENOSYS, ENOTSUP, and EOPNOTSUPP. Referenced by ACE_Handle_Gobbler::consume_handles().
00066 { 00067 // EMFILE is common to all platforms. 00068 if (error == EMFILE || 00069 #if defined (ACE_WIN32) 00070 // On Win32, we need to check for ENOBUFS also. 00071 error == ENOBUFS || 00072 #elif defined (HPUX) 00073 // On HPUX, we need to check for EADDRNOTAVAIL also. 00074 error == EADDRNOTAVAIL || 00075 #elif defined (linux) 00076 // On linux, we need to check for ENOENT also. 00077 error == ENOENT || 00078 // For RedHat5.2, need to check for EINVAL too. 00079 error == EINVAL || 00080 // Without threads check for EOPNOTSUPP 00081 error == EOPNOTSUPP || 00082 #elif defined (sun) 00083 // On sun, we need to check for ENOSR also. 00084 error == ENOSR || 00085 // Without threads check for ENOTSUP 00086 error == ENOTSUP || 00087 #elif defined (__FreeBSD__) 00088 // On FreeBSD we need to check for EOPNOTSUPP (LinuxThreads) or 00089 // ENOSYS (libc_r threads) also. 00090 error == EOPNOTSUPP || 00091 error == ENOSYS || 00092 #elif defined (__OpenBSD__) 00093 // OpenBSD appears to return EBADF. 00094 error == EBADF || 00095 #elif defined (__sgi) // irix 00096 error == ENOTSUP || 00097 #elif defined (DIGITAL_UNIX) // osf1 00098 error == ENOTSUP || 00099 #endif /* ACE_WIN32 */ 00100 error == ENFILE) 00101 return 1; 00102 else 00103 return 0; 00104 } |
|
Checks if process with {pid} is still alive. Returns 1 if it is still alive, 0 if it isn't alive, and -1 if something weird happened. Definition at line 253 of file ACE.cpp. References ACE_OS::kill(), and pid_t.
00254 { 00255 #if !defined(ACE_WIN32) 00256 int retval = ACE_OS::kill (pid, 0); 00257 00258 if (retval == 0) 00259 return 1; 00260 else if (errno == ESRCH) 00261 return 0; 00262 else 00263 return -1; 00264 #else 00265 // Create a handle for the given process id. 00266 ACE_HANDLE process_handle = 00267 ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); 00268 if (process_handle == ACE_INVALID_HANDLE 00269 || process_handle == 0) 00270 return 0; 00271 else 00272 { 00273 DWORD status; 00274 int result = 1; 00275 if (::GetExitCodeProcess (process_handle, 00276 &status) == 0 00277 || status != STILL_ACTIVE) 00278 result = 0; 00279 00280 ::CloseHandle (process_handle); 00281 return result; 00282 } 00283 #endif /* !ACE_WIN32 */ 00284 } |
|
Definition at line 17 of file ACE.inl. References ACE_OS::read_n(). Referenced by ACE_SPIPE_Stream::recv_n(), ACE_Pipe::recv_n(), ACE_FILE_IO::recv_n(), and ACE_DEV_IO::recv_n().
00021 { 00022 return ACE_OS::read_n (handle, 00023 buf, 00024 len, 00025 bytes_transferred); 00026 } |
|
Definition at line 2165 of file ACE.cpp. References iovec::iov_len, ACE_OS::readv(), and ssize_t.
02169 { 02170 size_t temp; 02171 size_t &bytes_transferred = bt == 0 ? temp : *bt; 02172 bytes_transferred = 0; 02173 02174 for (int s = 0; 02175 s < iovcnt; 02176 ) 02177 { 02178 ssize_t n = ACE_OS::readv (handle, 02179 iov + s, 02180 iovcnt - s); 02181 02182 if (n == -1 || n == 0) 02183 return n; 02184 02185 for (bytes_transferred += n; 02186 s < iovcnt 02187 && n >= static_cast<ssize_t> (iov[s].iov_len); 02188 s++) 02189 n -= iov[s].iov_len; 02190 02191 if (n != 0) 02192 { 02193 char *base = reinterpret_cast<char *> (iov[s].iov_base); 02194 iov[s].iov_base = base + n; 02195 iov[s].iov_len = iov[s].iov_len - n; 02196 } 02197 } 02198 02199 return bytes_transferred; 02200 } |
|
This makes sure that handle is set into non-blocking mode. val keeps track of whether were in non-blocking mode or not. Definition at line 2330 of file ACE.cpp. References ACE_BIT_DISABLED, ACE_NONBLOCK, get_flags(), and set_flags(). Referenced by enter_recv_timedwait(), enter_send_timedwait(), recv_n_i(), recvv_n_i(), send_n_i(), sendv_n_i(), t_rcv_n_i(), and t_snd_n_i().
02332 { 02333 // We need to record whether we are already *in* nonblocking mode, 02334 // so that we can correctly reset the state when we're done. 02335 val = ACE::get_flags (handle); 02336 02337 if (ACE_BIT_DISABLED (val, ACE_NONBLOCK)) 02338 // Set the handle into non-blocking mode if it's not already in 02339 // it. 02340 ACE::set_flags (handle, ACE_NONBLOCK); 02341 } |
|
Receive into a variable number of pieces. Accepts a variable, caller-specified, number of pointer/length pairs. Arguments following n are char *, size_t pairs.
Definition at line 959 of file ACE.cpp. References ACE_NEW_RETURN, iovec::iov_base, iovec::iov_len, ACE_OS::recvv(), and ssize_t.
00960 { 00961 va_list argp; 00962 int total_tuples = static_cast<int> (n / 2); 00963 iovec *iovp; 00964 #if defined (ACE_HAS_ALLOCA) 00965 iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); 00966 #else 00967 ACE_NEW_RETURN (iovp, 00968 iovec[total_tuples], 00969 -1); 00970 #endif /* !defined (ACE_HAS_ALLOCA) */ 00971 00972 va_start (argp, n); 00973 00974 for (int i = 0; i < total_tuples; i++) 00975 { 00976 iovp[i].iov_base = va_arg (argp, char *); 00977 iovp[i].iov_len = va_arg (argp, int); 00978 } 00979 00980 ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples); 00981 #if !defined (ACE_HAS_ALLOCA) 00982 delete [] iovp; 00983 #endif /* !defined (ACE_HAS_ALLOCA) */ 00984 va_end (argp); 00985 return result; 00986 } |
|
Definition at line 507 of file ACE.cpp. References enter_recv_timedwait(), ACE_OS::gettimeofday(), recv_i(), restore_non_blocking_mode(), ssize_t, and timespec_t.
00511 { 00512 if (timeout == 0) 00513 return ACE::recv_i (handle, buf, n); 00514 else 00515 { 00516 #if defined (ACE_HAS_READ_TIMEDWAIT) 00517 ACE_Time_Value copy = *timeout; 00518 copy += ACE_OS::gettimeofday (); 00519 timespec_t ts = copy; 00520 return ::read_timedwait (handle, buf, n, &ts); 00521 #else 00522 int val = 0; 00523 if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) 00524 return -1; 00525 else 00526 { 00527 ssize_t bytes_transferred = ACE::recv_i (handle, buf, n); 00528 ACE::restore_non_blocking_mode (handle, val); 00529 return bytes_transferred; 00530 } 00531 #endif /* ACE_HAS_READ_TIMEDWAIT */ 00532 } 00533 } |
|
Definition at line 448 of file ACE.cpp. References enter_recv_timedwait(), ACE_OS::gettimeofday(), ACE_OS::recv(), restore_non_blocking_mode(), ssize_t, and timespec_t. Referenced by ACE_MEM_Acceptor::accept(), ACE_MEM_Connector::connect(), handle_timed_complete(), ACE_Select_Reactor_Notify::read_notify_pipe(), ACE_Dev_Poll_Reactor_Notify::read_notify_pipe(), ACE_TLI_Stream::recv(), ACE_SOCK_IO::recv(), ACE_ICMP_Socket::recv(), ACE_Reactive_MEM_IO::recv_buf(), ACE_SOCK_Stream::recv_urg(), and ACE_SOCK_SEQPACK_Association::recv_urg().
00453 { 00454 if (timeout == 0) 00455 return ACE_OS::recv (handle, (char *) buf, len, flags); 00456 else 00457 { 00458 #if defined (ACE_HAS_RECV_TIMEDWAIT) 00459 ACE_Time_Value copy = *timeout; 00460 copy += ACE_OS::gettimeofday (); 00461 timespec_t ts = copy; 00462 return ::recv_timedwait (handle, buf, len, flags, &ts); 00463 #else 00464 int val = 0; 00465 if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) 00466 return -1; 00467 else 00468 { 00469 ssize_t bytes_transferred = 00470 ACE_OS::recv (handle, (char *) buf, len, flags); 00471 ACE::restore_non_blocking_mode (handle, val); 00472 return bytes_transferred; 00473 } 00474 #endif /* ACE_HAS_RECV_TIMEDWAIT */ 00475 } 00476 } |
|
Definition at line 231 of file ACE.inl. References ACE_OS::read(), and ACE_OS::recv(). Referenced by recv(), and recv_n_i().
00232 { 00233 #if defined (ACE_WIN32) || defined (ACE_OPENVMS) || defined (ACE_TANDEM_T1248_PTHREADS) 00234 return ACE_OS::recv (handle, (char *) buf, len); 00235 #else 00236 return ACE_OS::read (handle, (char *) buf, len); 00237 #endif /* ACE_WIN32 */ 00238 } |
|
Definition at line 1158 of file ACE.cpp. References ACE_IOV_MAX, ACE_Message_Block::cont(), iovec::iov_base, iovec::iov_len, ACE_Message_Block::length(), ACE_Message_Block::next(), ACE_Message_Block::rd_ptr(), recvv_n(), and ssize_t.
01162 { 01163 size_t temp; 01164 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01165 bytes_transferred = 0; 01166 01167 iovec iov[ACE_IOV_MAX]; 01168 int iovcnt = 0; 01169 01170 while (message_block != 0) 01171 { 01172 // Our current message block chain. 01173 const ACE_Message_Block *current_message_block = message_block; 01174 01175 while (current_message_block != 0) 01176 { 01177 size_t current_message_block_length = 01178 current_message_block->length (); 01179 char *this_rd_ptr = current_message_block->rd_ptr (); 01180 01181 // Check if this block has any space for incoming data. 01182 while (current_message_block_length > 0) 01183 { 01184 u_long this_chunk_length; 01185 if (current_message_block_length > ULONG_MAX) 01186 this_chunk_length = ULONG_MAX; 01187 else 01188 this_chunk_length = 01189 static_cast<u_long> (current_message_block_length); 01190 // Collect the data in the iovec. 01191 iov[iovcnt].iov_base = this_rd_ptr; 01192 iov[iovcnt].iov_len = this_chunk_length; 01193 current_message_block_length -= this_chunk_length; 01194 this_rd_ptr += this_chunk_length; 01195 01196 // Increment iovec counter. 01197 ++iovcnt; 01198 01199 // The buffer is full make a OS call. @@ TODO find a way to 01200 // find ACE_IOV_MAX for platforms that do not define it rather 01201 // than simply setting ACE_IOV_MAX to some arbitrary value such 01202 // as 16. 01203 if (iovcnt == ACE_IOV_MAX) 01204 { 01205 size_t current_transfer = 0; 01206 01207 ssize_t result = ACE::recvv_n (handle, 01208 iov, 01209 iovcnt, 01210 timeout, 01211 ¤t_transfer); 01212 01213 // Add to total bytes transferred. 01214 bytes_transferred += current_transfer; 01215 01216 // Errors. 01217 if (result == -1 || result == 0) 01218 return result; 01219 01220 // Reset iovec counter. 01221 iovcnt = 0; 01222 } 01223 } 01224 01225 // Select the next message block in the chain. 01226 current_message_block = current_message_block->cont (); 01227 } 01228 01229 // Selection of the next message block chain. 01230 message_block = message_block->next (); 01231 } 01232 01233 // Check for remaining buffers to be sent. This will happen when 01234 // ACE_IOV_MAX is not a multiple of the number of message blocks. 01235 if (iovcnt != 0) 01236 { 01237 size_t current_transfer = 0; 01238 01239 ssize_t result = ACE::recvv_n (handle, 01240 iov, 01241 iovcnt, 01242 timeout, 01243 ¤t_transfer); 01244 01245 // Add to total bytes transferred. 01246 bytes_transferred += current_transfer; 01247 01248 // Errors. 01249 if (result == -1 || result == 0) 01250 return result; 01251 } 01252 01253 // Return total bytes transferred. 01254 return bytes_transferred; 01255 } |
|
Definition at line 91 of file ACE.inl. References recv_n_i().
00096 { 00097 if (timeout == 0) 00098 return ACE::recv_n_i (handle, 00099 buf, 00100 len, 00101 bytes_transferred); 00102 else 00103 return ACE::recv_n_i (handle, 00104 buf, 00105 len, 00106 timeout, 00107 bytes_transferred); 00108 } |
|
Definition at line 41 of file ACE.inl. References recv_n_i(). Referenced by ACE_TLI_Stream::recv_n(), ACE_SOCK_Stream::recv_n(), ACE_SOCK_SEQPACK_Association::recv_n(), ACE_Pipe::recv_n(), ACE_FIFO_Recv::recv_n(), and ACE_DEV_IO::recv_n().
00047 { 00048 if (timeout == 0) 00049 return ACE::recv_n_i (handle, 00050 buf, 00051 len, 00052 flags, 00053 bytes_transferred); 00054 else 00055 return ACE::recv_n_i (handle, 00056 buf, 00057 len, 00058 flags, 00059 timeout, 00060 bytes_transferred); 00061 } |
|
Definition at line 888 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), record_and_set_non_blocking_mode(), recv_i(), restore_non_blocking_mode(), and ssize_t.
00893 { 00894 size_t temp; 00895 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00896 ssize_t n; 00897 ssize_t result = 0; 00898 int error = 0; 00899 00900 int val = 0; 00901 ACE::record_and_set_non_blocking_mode (handle, val); 00902 00903 for (bytes_transferred = 0; 00904 bytes_transferred < len; 00905 bytes_transferred += n) 00906 { 00907 // Try to transfer as much of the remaining data as possible. 00908 // Since the socket is in non-blocking mode, this call will not 00909 // block. 00910 n = ACE::recv_i (handle, 00911 static_cast <char *> (buf) + bytes_transferred, 00912 len - bytes_transferred); 00913 00914 // Check for errors. 00915 if (n == 0 || 00916 n == -1) 00917 { 00918 // Check for possible blocking. 00919 if (n == -1 && 00920 errno == EWOULDBLOCK) 00921 { 00922 // Wait upto <timeout> for the blocking to subside. 00923 int rtn = ACE::handle_read_ready (handle, 00924 timeout); 00925 00926 // Did select() succeed? 00927 if (rtn != -1) 00928 { 00929 // Blocking subsided in <timeout> period. Continue 00930 // data transfer. 00931 n = 0; 00932 continue; 00933 } 00934 } 00935 00936 // Wait in select() timed out or other data transfer or 00937 // select() failures. 00938 error = 1; 00939 result = n; 00940 break; 00941 } 00942 } 00943 00944 ACE::restore_non_blocking_mode (handle, val); 00945 00946 if (error) 00947 return result; 00948 else 00949 return static_cast<ssize_t> (bytes_transferred); 00950 } |
|
Definition at line 838 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), recv_i(), and ssize_t.
00842 { 00843 size_t temp; 00844 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00845 ssize_t n; 00846 00847 for (bytes_transferred = 0; 00848 bytes_transferred < len; 00849 bytes_transferred += n) 00850 { 00851 // Try to transfer as much of the remaining data as possible. 00852 n = ACE::recv_i (handle, 00853 static_cast <char *> (buf) + bytes_transferred, 00854 len - bytes_transferred); 00855 // Check EOF. 00856 if (n == 0) 00857 { 00858 return 0; 00859 } 00860 // Check for other errors. 00861 if (n == -1) 00862 { 00863 // Check for possible blocking. 00864 if (errno == EWOULDBLOCK) 00865 { 00866 // Wait for the blocking to subside. 00867 int result = ACE::handle_read_ready (handle, 00868 0); 00869 00870 // Did select() succeed? 00871 if (result != -1) 00872 { 00873 // Blocking subsided. Continue data transfer. 00874 n = 0; 00875 continue; 00876 } 00877 } 00878 00879 // Other data transfer or select() failures. 00880 return -1; 00881 } 00882 } 00883 00884 return static_cast<ssize_t> (bytes_transferred); 00885 } |
|
Definition at line 649 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), record_and_set_non_blocking_mode(), ACE_OS::recv(), restore_non_blocking_mode(), and ssize_t.
00655 { 00656 size_t temp; 00657 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00658 ssize_t n; 00659 ssize_t result = 0; 00660 int error = 0; 00661 00662 int val = 0; 00663 ACE::record_and_set_non_blocking_mode (handle, val); 00664 00665 for (bytes_transferred = 0; 00666 bytes_transferred < len; 00667 bytes_transferred += n) 00668 { 00669 // Try to transfer as much of the remaining data as possible. 00670 // Since the socket is in non-blocking mode, this call will not 00671 // block. 00672 n = ACE_OS::recv (handle, 00673 static_cast <char *> (buf) + bytes_transferred, 00674 len - bytes_transferred, 00675 flags); 00676 00677 // Check for errors. 00678 if (n == 0 || 00679 n == -1) 00680 { 00681 // Check for possible blocking. 00682 if (n == -1 && 00683 errno == EWOULDBLOCK) 00684 { 00685 // Wait upto <timeout> for the blocking to subside. 00686 int rtn = ACE::handle_read_ready (handle, 00687 timeout); 00688 00689 // Did select() succeed? 00690 if (rtn != -1) 00691 { 00692 // Blocking subsided in <timeout> period. Continue 00693 // data transfer. 00694 n = 0; 00695 continue; 00696 } 00697 } 00698 00699 // Wait in select() timed out or other data transfer or 00700 // select() failures. 00701 error = 1; 00702 result = n; 00703 break; 00704 } 00705 } 00706 00707 ACE::restore_non_blocking_mode (handle, val); 00708 00709 if (error) 00710 return result; 00711 else 00712 return static_cast<ssize_t> (bytes_transferred); 00713 } |
|
Definition at line 598 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), ACE_OS::recv(), and ssize_t. Referenced by recv_n().
00603 { 00604 size_t temp; 00605 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00606 ssize_t n; 00607 00608 for (bytes_transferred = 0; 00609 bytes_transferred < len; 00610 bytes_transferred += n) 00611 { 00612 // Try to transfer as much of the remaining data as possible. 00613 n = ACE_OS::recv (handle, 00614 static_cast <char *> (buf) + bytes_transferred, 00615 len - bytes_transferred, 00616 flags); 00617 // Check EOF. 00618 if (n == 0) 00619 return 0; 00620 00621 // Check for other errors. 00622 if (n == -1) 00623 { 00624 // Check for possible blocking. 00625 if (errno == EWOULDBLOCK) 00626 { 00627 // Wait for the blocking to subside. 00628 int result = ACE::handle_read_ready (handle, 00629 0); 00630 00631 // Did select() succeed? 00632 if (result != -1) 00633 { 00634 // Blocking subsided. Continue data transfer. 00635 n = 0; 00636 continue; 00637 } 00638 } 00639 00640 // Other data transfer or select() failures. 00641 return -1; 00642 } 00643 } 00644 00645 return static_cast<ssize_t> (bytes_transferred); 00646 } |
|
Definition at line 565 of file ACE.cpp. References enter_recv_timedwait(), ACE_OS::gettimeofday(), ACE_OS::recvfrom(), restore_non_blocking_mode(), ssize_t, and timespec_t.
00572 { 00573 if (timeout == 0) 00574 return ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); 00575 else 00576 { 00577 #if defined (ACE_HAS_RECVFROM_TIMEDWAIT) 00578 ACE_Time_Value copy = *timeout; 00579 copy += ACE_OS::gettimeofday (); 00580 timespec_t ts = copy; 00581 return ::recvfrom_timedwait (handle, buf, len, flags, addr, addrlen, &ts); 00582 #else 00583 int val = 0; 00584 if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) 00585 return -1; 00586 else 00587 { 00588 ssize_t bytes_transferred = 00589 ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); 00590 ACE::restore_non_blocking_mode (handle, val); 00591 return bytes_transferred; 00592 } 00593 #endif /* ACE_HAS_RECVFROM_TIMEDWAIT */ 00594 } 00595 } |
|
Definition at line 536 of file ACE.cpp. References enter_recv_timedwait(), ACE_OS::gettimeofday(), ACE_OS::recvmsg(), restore_non_blocking_mode(), ssize_t, and timespec_t.
00540 { 00541 if (timeout == 0) 00542 return ACE_OS::recvmsg (handle, msg, flags); 00543 else 00544 { 00545 #if defined (ACE_HAS_RECVMSG_TIMEDWAIT) 00546 ACE_Time_Value copy = *timeout; 00547 copy += ACE_OS::gettimeofday (); 00548 timespec_t ts = copy; 00549 return ::recvmsg_timedwait (handle, msg, flags, &ts); 00550 #else 00551 int val = 0; 00552 if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) 00553 return -1; 00554 else 00555 { 00556 ssize_t bytes_transferred = ACE_OS::recvmsg (handle, msg, flags); 00557 ACE::restore_non_blocking_mode (handle, val); 00558 return bytes_transferred; 00559 } 00560 #endif /* ACE_HAS_RECVMSG_TIMEDWAIT */ 00561 } 00562 } |
|
Definition at line 989 of file ACE.cpp. References enter_recv_timedwait(), ACE_OS::gettimeofday(), ACE_OS::recvv(), restore_non_blocking_mode(), ssize_t, and timespec_t. Referenced by ACE_Pipe::recv(), and ACE_SOCK_IO::recvv().
00993 { 00994 if (timeout == 0) 00995 return ACE_OS::recvv (handle, iov, iovcnt); 00996 else 00997 { 00998 #if defined (ACE_HAS_READV_TIMEDWAIT) 00999 ACE_Time_Value copy = *timeout; 01000 copy += ACE_OS::gettimeofday (); 01001 timespec_t ts = copy; 01002 return ::readv_timedwait (handle, iov, iovcnt, &ts); 01003 #else 01004 int val = 0; 01005 if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) 01006 return -1; 01007 else 01008 { 01009 ssize_t bytes_transferred = ACE_OS::recvv (handle, iov, iovcnt); 01010 ACE::restore_non_blocking_mode (handle, val); 01011 return bytes_transferred; 01012 } 01013 #endif /* ACE_HAS_READV_TIMEDWAIT */ 01014 } 01015 } |
|
Definition at line 111 of file ACE.inl. References recvv_n_i(). Referenced by recv_n(), ACE_SOCK_Stream::recvv_n(), and ACE_SOCK_SEQPACK_Association::recvv_n().
00116 { 00117 if (timeout == 0) 00118 return ACE::recvv_n_i (handle, 00119 iov, 00120 iovcnt, 00121 bytes_transferred); 00122 else 00123 return ACE::recvv_n_i (handle, 00124 iov, 00125 iovcnt, 00126 timeout, 00127 bytes_transferred); 00128 } |
|
Definition at line 1080 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), iovec::iov_len, record_and_set_non_blocking_mode(), ACE_OS::recvv(), restore_non_blocking_mode(), and ssize_t.
01085 { 01086 size_t temp; 01087 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01088 bytes_transferred = 0; 01089 ssize_t result = 0; 01090 int error = 0; 01091 01092 int val = 0; 01093 ACE::record_and_set_non_blocking_mode (handle, val); 01094 01095 for (int s = 0; 01096 s < iovcnt; 01097 ) 01098 { 01099 // Try to transfer as much of the remaining data as possible. 01100 // Since the socket is in non-blocking mode, this call will not 01101 // block. 01102 ssize_t n = ACE_OS::recvv (handle, 01103 iov + s, 01104 iovcnt - s); 01105 01106 // Check for errors. 01107 if (n == 0 || 01108 n == -1) 01109 { 01110 // Check for possible blocking. 01111 if (n == -1 && 01112 errno == EWOULDBLOCK) 01113 { 01114 // Wait upto <timeout> for the blocking to subside. 01115 int rtn = ACE::handle_read_ready (handle, 01116 timeout); 01117 01118 // Did select() succeed? 01119 if (rtn != -1) 01120 { 01121 // Blocking subsided in <timeout> period. Continue 01122 // data transfer. 01123 n = 0; 01124 continue; 01125 } 01126 } 01127 01128 // Wait in select() timed out or other data transfer or 01129 // select() failures. 01130 error = 1; 01131 result = n; 01132 break; 01133 } 01134 01135 for (bytes_transferred += n; 01136 s < iovcnt 01137 && n >= static_cast<ssize_t> (iov[s].iov_len); 01138 s++) 01139 n -= iov[s].iov_len; 01140 01141 if (n != 0) 01142 { 01143 char *base = reinterpret_cast<char *> (iov[s].iov_base); 01144 iov[s].iov_base = base + n; 01145 iov[s].iov_len = iov[s].iov_len - n; 01146 } 01147 } 01148 01149 ACE::restore_non_blocking_mode (handle, val); 01150 01151 if (error) 01152 return result; 01153 else 01154 return bytes_transferred; 01155 } |
|
Definition at line 1018 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), iovec::iov_len, ACE_OS::recvv(), and ssize_t. Referenced by recvv_n().
01022 { 01023 size_t temp; 01024 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01025 bytes_transferred = 0; 01026 01027 for (int s = 0; 01028 s < iovcnt; 01029 ) 01030 { 01031 // Try to transfer as much of the remaining data as possible. 01032 ssize_t n = ACE_OS::recvv (handle, 01033 iov + s, 01034 iovcnt - s); 01035 // Check EOF. 01036 if (n == 0) 01037 return 0; 01038 01039 // Check for other errors. 01040 if (n == -1) 01041 { 01042 // Check for possible blocking. 01043 if (errno == EWOULDBLOCK) 01044 { 01045 // Wait for the blocking to subside. 01046 int result = ACE::handle_read_ready (handle, 01047 0); 01048 01049 // Did select() succeed? 01050 if (result != -1) 01051 { 01052 // Blocking subsided. Continue data transfer. 01053 n = 0; 01054 continue; 01055 } 01056 } 01057 01058 // Other data transfer or select() failures. 01059 return -1; 01060 } 01061 01062 for (bytes_transferred += n; 01063 s < iovcnt 01064 && n >= static_cast<ssize_t> (iov[s].iov_len); 01065 s++) 01066 n -= iov[s].iov_len; 01067 01068 if (n != 0) 01069 { 01070 char *base = static_cast<char *> (iov[s].iov_base); 01071 iov[s].iov_base = base + n; 01072 iov[s].iov_len = iov[s].iov_len - n; 01073 } 01074 } 01075 01076 return bytes_transferred; 01077 } |
|
Cleanup after a timed operation, restore the appropriate non-blocking status of handle. Definition at line 2344 of file ACE.cpp. References ACE_BIT_DISABLED, ACE_NONBLOCK, and clr_flags(). Referenced by recv(), recv_n_i(), recvfrom(), recvmsg(), recvv(), recvv_n_i(), send(), send_n_i(), sendmsg(), sendto(), sendv(), sendv_n_i(), t_rcv(), t_rcv_n_i(), t_snd(), and t_snd_n_i().
02346 { 02347 if (ACE_BIT_DISABLED (val, 02348 ACE_NONBLOCK)) 02349 { 02350 // Save/restore errno. 02351 ACE_Errno_Guard error (errno); 02352 // Only disable ACE_NONBLOCK if we weren't in non-blocking mode 02353 // originally. 02354 ACE::clr_flags (handle, ACE_NONBLOCK); 02355 } 02356 } |
|
Rounds the request to a multiple of the allocation granularity.
Definition at line 2562 of file ACE.cpp. References ACE_TRACE, and ACE_OS::allocation_granularity().
02563 { 02564 ACE_TRACE ("ACE::round_to_allocation_granularity"); 02565 02566 if (ACE::allocation_granularity_ == 0) 02567 ACE::allocation_granularity_ = ACE_OS::allocation_granularity (); 02568 02569 return (len + (ACE::allocation_granularity_ - 1)) & ~(ACE::allocation_granularity_ - 1); 02570 } |
|
Rounds the request to a multiple of the page size.
Definition at line 2551 of file ACE.cpp. References ACE_TRACE, and ACE_OS::getpagesize(). Referenced by ACE_Shared_Memory_Pool::init_acquire(), ACE_Shared_Memory_Pool::round_up(), ACE_Sbrk_Memory_Pool::round_up(), ACE_MMAP_Memory_Pool::round_up(), and ACE_Local_Memory_Pool::round_up().
02552 { 02553 ACE_TRACE ("ACE::round_to_pagesize"); 02554 02555 if (ACE::pagesize_ == 0) 02556 ACE::pagesize_ = ACE_OS::getpagesize (); 02557 02558 return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1); 02559 } |
|
Wrapper facade for the most common use of Definition at line 205 of file ACE.cpp. References ACE_Handle_Set::fdset(), ACE_OS::select(), and ACE_Handle_Set::sync().
00208 { 00209 int result = ACE_OS::select (width, 00210 readfds.fdset (), 00211 0, 00212 0, 00213 timeout); 00214 00215 #if !defined (ACE_WIN32) 00216 if (result > 0) 00217 readfds.sync ((ACE_HANDLE) width); 00218 #endif /* ACE_WIN32 */ 00219 return result; 00220 } |
|
Wrapper facade for
Definition at line 178 of file ACE.cpp. References ACE_Handle_Set::fdset(), ACE_OS::select(), and ACE_Handle_Set::sync().
00183 { 00184 int result = ACE_OS::select (width, 00185 readfds ? readfds->fdset () : 0, 00186 writefds ? writefds->fdset () : 0, 00187 exceptfds ? exceptfds->fdset () : 0, 00188 timeout); 00189 if (result > 0) 00190 { 00191 # if !defined (ACE_WIN32) 00192 // This isn't needed for Windows... it's a no-op anyway. 00193 if (readfds) 00194 readfds->sync ((ACE_HANDLE) width); 00195 if (writefds) 00196 writefds->sync ((ACE_HANDLE) width); 00197 if (exceptfds) 00198 exceptfds->sync ((ACE_HANDLE) width); 00199 #endif /* ACE_WIN32 */ 00200 } 00201 return result; 00202 } |
|
Varargs variant.
Definition at line 1765 of file ACE.cpp. References ACE_NEW_RETURN, iovec::iov_base, iovec::iov_len, ACE_OS::sendv(), and ssize_t.
01766 { 01767 va_list argp; 01768 int total_tuples = static_cast<int> (n / 2); 01769 iovec *iovp; 01770 #if defined (ACE_HAS_ALLOCA) 01771 iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); 01772 #else 01773 ACE_NEW_RETURN (iovp, 01774 iovec[total_tuples], 01775 -1); 01776 #endif /* !defined (ACE_HAS_ALLOCA) */ 01777 01778 va_start (argp, n); 01779 01780 for (int i = 0; i < total_tuples; i++) 01781 { 01782 iovp[i].iov_base = va_arg (argp, char *); 01783 iovp[i].iov_len = va_arg (argp, int); 01784 } 01785 01786 ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples); 01787 #if !defined (ACE_HAS_ALLOCA) 01788 delete [] iovp; 01789 #endif /* !defined (ACE_HAS_ALLOCA) */ 01790 va_end (argp); 01791 return result; 01792 } |
|
Definition at line 1315 of file ACE.cpp. References enter_send_timedwait(), ACE_OS::gettimeofday(), restore_non_blocking_mode(), send_i(), ssize_t, and timespec_t.
01319 { 01320 if (timeout == 0) 01321 return ACE::send_i (handle, buf, n); 01322 else 01323 { 01324 #if defined (ACE_HAS_WRITE_TIMEDWAIT) 01325 ACE_Time_Value copy = *timeout; 01326 copy += ACE_OS::gettimeofday (); 01327 timespec_t ts = copy; 01328 return ::write_timedwait (handle, buf, n, &ts); 01329 #else 01330 int val = 0; 01331 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01332 return -1; 01333 else 01334 { 01335 ssize_t bytes_transferred = ACE::send_i (handle, buf, n); 01336 ACE::restore_non_blocking_mode (handle, val); 01337 return bytes_transferred; 01338 } 01339 #endif /* ACE_HAS_WRITE_TIMEDWAIT */ 01340 } 01341 } |
|
Definition at line 1258 of file ACE.cpp. References enter_send_timedwait(), ACE_OS::gettimeofday(), restore_non_blocking_mode(), ACE_OS::send(), ssize_t, and timespec_t. Referenced by ACE_MEM_Acceptor::accept(), ACE_MEM_Connector::connect(), ACE_Select_Reactor_Notify::dispatch_notify(), ACE_Select_Reactor_Notify::notify(), ACE_AIOCB_Notify_Pipe_Manager::notify(), ACE_Dev_Poll_Reactor_Notify::notify(), ACE_TLI_Stream::send(), ACE_SOCK_IO::send(), ACE_Reactive_MEM_IO::send_buf(), ACE_SOCK_Stream::send_urg(), and ACE_SOCK_SEQPACK_Association::send_urg().
01263 { 01264 if (timeout == 0) 01265 return ACE_OS::send (handle, (const char *) buf, n, flags); 01266 else 01267 { 01268 #if defined (ACE_HAS_SEND_TIMEDWAIT) 01269 ACE_Time_Value copy = *timeout; 01270 copy += ACE_OS::gettimeofday(); 01271 timespec_t ts = copy; 01272 return ::send_timedwait (handle, buf, n, flags, &ts); 01273 #else 01274 int val = 0; 01275 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01276 return -1; 01277 else 01278 { 01279 ssize_t bytes_transferred = ACE_OS::send (handle, (const char *) buf, n, flags); 01280 ACE::restore_non_blocking_mode (handle, val); 01281 return bytes_transferred; 01282 } 01283 #endif /* ACE_HAS_SEND_TIMEDWAIT */ 01284 } 01285 } |
|
Definition at line 221 of file ACE.inl. References ACE_OS::send(), and ACE_OS::write(). Referenced by send(), and send_n_i().
00222 { 00223 #if defined (ACE_WIN32) || defined (HPUX) 00224 return ACE_OS::send (handle, (const char *) buf, len); 00225 #else 00226 return ACE_OS::write (handle, (const char *) buf, len); 00227 #endif /* ACE_WIN32 */ 00228 } |
|
Send all the message_blocks chained through their Definition at line 2065 of file ACE.cpp. References ACE_IOV_MAX, ACE_Message_Block::cont(), iovec::iov_base, iovec::iov_len, ACE_Message_Block::length(), ACE_Message_Block::next(), ACE_Message_Block::rd_ptr(), sendv_n(), and ssize_t.
02069 { 02070 size_t temp; 02071 size_t &bytes_transferred = bt == 0 ? temp : *bt; 02072 bytes_transferred = 0; 02073 02074 iovec iov[ACE_IOV_MAX]; 02075 int iovcnt = 0; 02076 02077 while (message_block != 0) 02078 { 02079 // Our current message block chain. 02080 const ACE_Message_Block *current_message_block = message_block; 02081 02082 while (current_message_block != 0) 02083 { 02084 char *this_block_ptr = current_message_block->rd_ptr (); 02085 size_t current_message_block_length = 02086 current_message_block->length (); 02087 02088 // Check if this block has any data to be sent. 02089 while (current_message_block_length > 0) 02090 { 02091 u_long this_chunk_length; 02092 if (current_message_block_length > ULONG_MAX) 02093 this_chunk_length = ULONG_MAX; 02094 else 02095 this_chunk_length = 02096 static_cast<u_long> (current_message_block_length); 02097 // Collect the data in the iovec. 02098 iov[iovcnt].iov_base = this_block_ptr; 02099 iov[iovcnt].iov_len = this_chunk_length; 02100 current_message_block_length -= this_chunk_length; 02101 this_block_ptr += this_chunk_length; 02102 02103 // Increment iovec counter. 02104 ++iovcnt; 02105 02106 // The buffer is full make a OS call. @@ TODO find a way to 02107 // find ACE_IOV_MAX for platforms that do not define it rather 02108 // than simply setting ACE_IOV_MAX to some arbitrary value such 02109 // as 16. 02110 if (iovcnt == ACE_IOV_MAX) 02111 { 02112 size_t current_transfer = 0; 02113 02114 ssize_t result = ACE::sendv_n (handle, 02115 iov, 02116 iovcnt, 02117 timeout, 02118 ¤t_transfer); 02119 02120 // Add to total bytes transferred. 02121 bytes_transferred += current_transfer; 02122 02123 // Errors. 02124 if (result == -1 || result == 0) 02125 return result; 02126 02127 // Reset iovec counter. 02128 iovcnt = 0; 02129 } 02130 } 02131 02132 // Select the next message block in the chain. 02133 current_message_block = current_message_block->cont (); 02134 } 02135 02136 // Selection of the next message block chain. 02137 message_block = message_block->next (); 02138 } 02139 02140 // Check for remaining buffers to be sent. This will happen when 02141 // ACE_IOV_MAX is not a multiple of the number of message blocks. 02142 if (iovcnt != 0) 02143 { 02144 size_t current_transfer = 0; 02145 02146 ssize_t result = ACE::sendv_n (handle, 02147 iov, 02148 iovcnt, 02149 timeout, 02150 ¤t_transfer); 02151 02152 // Add to total bytes transferred. 02153 bytes_transferred += current_transfer; 02154 02155 // Errors. 02156 if (result == -1 || result == 0) 02157 return result; 02158 } 02159 02160 // Return total bytes transferred. 02161 return bytes_transferred; 02162 } |
|
Definition at line 181 of file ACE.inl. References send_n_i().
00186 { 00187 if (timeout == 0) 00188 return ACE::send_n_i (handle, 00189 buf, 00190 len, 00191 bytes_transferred); 00192 else 00193 return ACE::send_n_i (handle, 00194 buf, 00195 len, 00196 timeout, 00197 bytes_transferred); 00198 } |
|
Definition at line 131 of file ACE.inl. References send_n_i(). Referenced by ACE_TLI_Stream::send_n(), ACE_SOCK_Stream::send_n(), ACE_SOCK_SEQPACK_Association::send_n(), ACE_Pipe::send_n(), and ACE_FIFO_Send::send_n().
00137 { 00138 if (timeout == 0) 00139 return ACE::send_n_i (handle, 00140 buf, 00141 len, 00142 flags, 00143 bytes_transferred); 00144 else 00145 return ACE::send_n_i (handle, 00146 buf, 00147 len, 00148 flags, 00149 timeout, 00150 bytes_transferred); 00151 } |
|
Definition at line 1695 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), record_and_set_non_blocking_mode(), restore_non_blocking_mode(), send_i(), and ssize_t.
01700 { 01701 size_t temp; 01702 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01703 ssize_t n; 01704 ssize_t result = 0; 01705 int error = 0; 01706 01707 int val = 0; 01708 ACE::record_and_set_non_blocking_mode (handle, val); 01709 01710 for (bytes_transferred = 0; 01711 bytes_transferred < len; 01712 bytes_transferred += n) 01713 { 01714 // Try to transfer as much of the remaining data as possible. 01715 // Since the socket is in non-blocking mode, this call will not 01716 // block. 01717 n = ACE::send_i (handle, 01718 (char *) buf + bytes_transferred, 01719 len - bytes_transferred); 01720 01721 // Check for errors. 01722 if (n == 0 || 01723 n == -1) 01724 { 01725 // Check for possible blocking. 01726 if (n == -1 && 01727 errno == EWOULDBLOCK || errno == ENOBUFS) 01728 { 01729 // Wait upto <timeout> for the blocking to subside. 01730 int rtn = ACE::handle_write_ready (handle, 01731 timeout); 01732 01733 // Did select() succeed? 01734 if (rtn != -1) 01735 { 01736 // Blocking subsided in <timeout> period. Continue 01737 // data transfer. 01738 n = 0; 01739 continue; 01740 } 01741 } 01742 01743 // Wait in select() timed out or other data transfer or 01744 // select() failures. 01745 error = 1; 01746 result = n; 01747 break; 01748 } 01749 } 01750 01751 ACE::restore_non_blocking_mode (handle, val); 01752 01753 if (error) 01754 return result; 01755 else 01756 return bytes_transferred; 01757 } |
|
Definition at line 1646 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), send_i(), and ssize_t.
01650 { 01651 size_t temp; 01652 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01653 ssize_t n; 01654 01655 for (bytes_transferred = 0; 01656 bytes_transferred < len; 01657 bytes_transferred += n) 01658 { 01659 // Try to transfer as much of the remaining data as possible. 01660 n = ACE::send_i (handle, 01661 (char *) buf + bytes_transferred, 01662 len - bytes_transferred); 01663 // Check EOF. 01664 if (n == 0) 01665 return 0; 01666 01667 // Check for other errors. 01668 if (n == -1) 01669 { 01670 // Check for possible blocking. 01671 if (errno == EWOULDBLOCK || errno == ENOBUFS) 01672 { 01673 // Wait for the blocking to subside. 01674 int result = ACE::handle_write_ready (handle, 01675 0); 01676 01677 // Did select() succeed? 01678 if (result != -1) 01679 { 01680 // Blocking subsided. Continue data transfer. 01681 n = 0; 01682 continue; 01683 } 01684 } 01685 01686 // Other data transfer or select() failures. 01687 return -1; 01688 } 01689 } 01690 01691 return bytes_transferred; 01692 } |
|
Definition at line 1457 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), record_and_set_non_blocking_mode(), restore_non_blocking_mode(), ACE_OS::send(), and ssize_t.
01463 { 01464 size_t temp; 01465 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01466 ssize_t n; 01467 ssize_t result = 0; 01468 int error = 0; 01469 01470 int val = 0; 01471 ACE::record_and_set_non_blocking_mode (handle, val); 01472 01473 for (bytes_transferred = 0; 01474 bytes_transferred < len; 01475 bytes_transferred += n) 01476 { 01477 // Try to transfer as much of the remaining data as possible. 01478 // Since the socket is in non-blocking mode, this call will not 01479 // block. 01480 n = ACE_OS::send (handle, 01481 (char *) buf + bytes_transferred, 01482 len - bytes_transferred, 01483 flags); 01484 01485 // Check for errors. 01486 if (n == 0 || 01487 n == -1) 01488 { 01489 // Check for possible blocking. 01490 if (n == -1 && 01491 errno == EWOULDBLOCK || errno == ENOBUFS) 01492 { 01493 // Wait upto <timeout> for the blocking to subside. 01494 int rtn = ACE::handle_write_ready (handle, 01495 timeout); 01496 01497 // Did select() succeed? 01498 if (rtn != -1) 01499 { 01500 // Blocking subsided in <timeout> period. Continue 01501 // data transfer. 01502 n = 0; 01503 continue; 01504 } 01505 } 01506 01507 // Wait in select() timed out or other data transfer or 01508 // select() failures. 01509 error = 1; 01510 result = n; 01511 break; 01512 } 01513 } 01514 01515 ACE::restore_non_blocking_mode (handle, val); 01516 01517 if (error) 01518 return result; 01519 else 01520 return bytes_transferred; 01521 } |
|
Definition at line 1406 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), ACE_OS::send(), and ssize_t. Referenced by send_n().
01411 { 01412 size_t temp; 01413 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01414 ssize_t n; 01415 01416 for (bytes_transferred = 0; 01417 bytes_transferred < len; 01418 bytes_transferred += n) 01419 { 01420 // Try to transfer as much of the remaining data as possible. 01421 n = ACE_OS::send (handle, 01422 (char *) buf + bytes_transferred, 01423 len - bytes_transferred, 01424 flags); 01425 // Check EOF. 01426 if (n == 0) 01427 return 0; 01428 01429 // Check for other errors. 01430 if (n == -1) 01431 { 01432 // Check for possible blocking. 01433 if (errno == EWOULDBLOCK || errno == ENOBUFS) 01434 { 01435 // Wait for the blocking to subside. 01436 int result = ACE::handle_write_ready (handle, 01437 0); 01438 01439 // Did select() succeed? 01440 if (result != -1) 01441 { 01442 // Blocking subsided. Continue data transfer. 01443 n = 0; 01444 continue; 01445 } 01446 } 01447 01448 // Other data transfer or select() failures. 01449 return -1; 01450 } 01451 } 01452 01453 return bytes_transferred; 01454 } |
|
Definition at line 1344 of file ACE.cpp. References enter_send_timedwait(), ACE_OS::gettimeofday(), restore_non_blocking_mode(), ACE_OS::sendmsg(), ssize_t, and timespec_t.
01348 { 01349 if (timeout == 0) 01350 return ACE_OS::sendmsg (handle, msg, flags); 01351 else 01352 { 01353 #if defined (ACE_HAS_SENDMSG_TIMEDWAIT) 01354 ACE_Time_Value copy = *timeout; 01355 copy += ACE_OS::gettimeofday (); 01356 timespec_t ts = copy; 01357 return ::sendmsg_timedwait (handle, msg, flags, &ts); 01358 #else 01359 int val = 0; 01360 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01361 return -1; 01362 else 01363 { 01364 ssize_t bytes_transferred = ACE_OS::sendmsg (handle, msg, flags); 01365 ACE::restore_non_blocking_mode (handle, val); 01366 return bytes_transferred; 01367 } 01368 #endif /* ACE_HAS_SENDMSG_TIMEDWAIT */ 01369 } 01370 } |
|
Definition at line 1373 of file ACE.cpp. References enter_send_timedwait(), ACE_OS::gettimeofday(), restore_non_blocking_mode(), ACE_OS::sendto(), ssize_t, and timespec_t.
01380 { 01381 if (timeout == 0) 01382 return ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); 01383 else 01384 { 01385 #if defined (ACE_HAS_SENDTO_TIMEDWAIT) 01386 ACE_Time_Value copy = *timeout; 01387 copy += ACE_OS::gettimeofday (); 01388 timespec_t ts = copy; 01389 return ::sendto_timedwait (handle, buf, len, flags, addr, addrlen, ts); 01390 #else 01391 int val = 0; 01392 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01393 return -1; 01394 else 01395 { 01396 ssize_t bytes_transferred = 01397 ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); 01398 ACE::restore_non_blocking_mode (handle, val); 01399 return bytes_transferred; 01400 } 01401 #endif /* ACE_HAS_SENDTO_TIMEDWAIT */ 01402 } 01403 } |
|
Definition at line 1795 of file ACE.cpp. References enter_send_timedwait(), ACE_OS::gettimeofday(), restore_non_blocking_mode(), ACE_OS::sendv(), ssize_t, and timespec_t. Referenced by ACE_Pipe::send(), and ACE_SOCK_IO::sendv().
01799 { 01800 if (timeout == 0) 01801 return ACE_OS::sendv (handle, iov, iovcnt); 01802 else 01803 { 01804 #if defined (ACE_HAS_WRITEV_TIMEDWAIT) 01805 ACE_Time_Value copy = *timeout; 01806 copy += ACE_OS::gettimeofday (); 01807 timespec_t ts = copy; 01808 return ::sendv_timedwait (handle, iov, iovcnt, &ts); 01809 #else 01810 int val = 0; 01811 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01812 return -1; 01813 else 01814 { 01815 ssize_t bytes_transferred = ACE_OS::sendv (handle, iov, iovcnt); 01816 ACE::restore_non_blocking_mode (handle, val); 01817 return bytes_transferred; 01818 } 01819 #endif /* ACE_HAS_WRITEV_TIMEDWAIT */ 01820 } 01821 } |
|
Definition at line 201 of file ACE.inl. References sendv_n_i(). Referenced by send_n(), ACE_SOCK_Stream::sendv_n(), ACE_SOCK_SEQPACK_Association::sendv_n(), and ACE_Pipe::sendv_n().
00206 { 00207 if (timeout == 0) 00208 return ACE::sendv_n_i (handle, 00209 iov, 00210 iovcnt, 00211 bytes_transferred); 00212 else 00213 return ACE::sendv_n_i (handle, 00214 iov, 00215 iovcnt, 00216 timeout, 00217 bytes_transferred); 00218 } |
|
Definition at line 1888 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), iovec::iov_len, record_and_set_non_blocking_mode(), restore_non_blocking_mode(), ACE_OS::sendv(), and ssize_t.
01893 { 01894 size_t temp; 01895 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01896 bytes_transferred = 0; 01897 ssize_t result = 0; 01898 int error = 0; 01899 01900 int val = 0; 01901 ACE::record_and_set_non_blocking_mode (handle, val); 01902 01903 iovec *iov = const_cast<iovec *> (i); 01904 01905 for (int s = 0; 01906 s < iovcnt; 01907 ) 01908 { 01909 // Try to transfer as much of the remaining data as possible. 01910 // Since the socket is in non-blocking mode, this call will not 01911 // block. 01912 ssize_t n = ACE_OS::sendv (handle, 01913 iov + s, 01914 iovcnt - s); 01915 01916 // Check for errors. 01917 if (n == 0 || 01918 n == -1) 01919 { 01920 // Check for possible blocking. 01921 if (n == -1 && 01922 errno == EWOULDBLOCK || errno == ENOBUFS) 01923 { 01924 // Wait upto <timeout> for the blocking to subside. 01925 int rtn = ACE::handle_write_ready (handle, 01926 timeout); 01927 01928 // Did select() succeed? 01929 if (rtn != -1) 01930 { 01931 // Blocking subsided in <timeout> period. Continue 01932 // data transfer. 01933 n = 0; 01934 continue; 01935 } 01936 } 01937 01938 // Wait in select() timed out or other data transfer or 01939 // select() failures. 01940 error = 1; 01941 result = n; 01942 break; 01943 } 01944 01945 for (bytes_transferred += n; 01946 s < iovcnt 01947 && n >= static_cast<ssize_t> (iov[s].iov_len); 01948 s++) 01949 n -= iov[s].iov_len; 01950 01951 if (n != 0) 01952 { 01953 char *base = reinterpret_cast<char *> (iov[s].iov_base); 01954 iov[s].iov_base = base + n; 01955 iov[s].iov_len = iov[s].iov_len - n; 01956 } 01957 } 01958 01959 ACE::restore_non_blocking_mode (handle, val); 01960 01961 if (error) 01962 return result; 01963 else 01964 return bytes_transferred; 01965 } |
|
Definition at line 1824 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), iovec::iov_len, ACE_OS::sendv(), and ssize_t. Referenced by sendv_n().
01828 { 01829 size_t temp; 01830 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01831 bytes_transferred = 0; 01832 01833 iovec *iov = const_cast<iovec *> (i); 01834 01835 for (int s = 0; 01836 s < iovcnt; 01837 ) 01838 { 01839 // Try to transfer as much of the remaining data as possible. 01840 ssize_t n = ACE_OS::sendv (handle, 01841 iov + s, 01842 iovcnt - s); 01843 // Check EOF. 01844 if (n == 0) 01845 return 0; 01846 01847 // Check for other errors. 01848 if (n == -1) 01849 { 01850 // Check for possible blocking. 01851 if (errno == EWOULDBLOCK || errno == ENOBUFS) 01852 { 01853 // Wait for the blocking to subside. 01854 int result = ACE::handle_write_ready (handle, 01855 0); 01856 01857 // Did select() succeed? 01858 if (result != -1) 01859 { 01860 // Blocking subsided. Continue data transfer. 01861 n = 0; 01862 continue; 01863 } 01864 } 01865 01866 // Other data transfer or select() failures. 01867 return -1; 01868 } 01869 01870 for (bytes_transferred += n; 01871 s < iovcnt 01872 && n >= static_cast<ssize_t> (iov[s].iov_len); 01873 s++) 01874 n -= iov[s].iov_len; 01875 01876 if (n != 0) 01877 { 01878 char *base = reinterpret_cast<char *> (iov[s].iov_base); 01879 iov[s].iov_base = base + n; 01880 iov[s].iov_len = iov[s].iov_len - n; 01881 } 01882 } 01883 01884 return bytes_transferred; 01885 } |
|
Set flags associated with handle.
Definition at line 27 of file Flag_Manip.cpp. References ACE_NONBLOCK, ACE_NOTSUP_RETURN, ACE_SET_BITS, ACE_TRACE, F_GETFL, ACE_OS::fcntl(), and ACE_OS::ioctl(). Referenced by ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager(), ACE_WIN32_Asynch_Connect::connect_i(), ACE_POSIX_Asynch_Connect::connect_i(), ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), ACE_Select_Reactor_Notify::open(), ACE_Dev_Poll_Reactor_Notify::open(), record_and_set_non_blocking_mode(), ACE_SOCK_SEQPACK_Acceptor::shared_accept_start(), and ACE_SOCK_Acceptor::shared_accept_start().
00028 { 00029 ACE_TRACE ("ACE::set_flags"); 00030 #if defined (ACE_LACKS_FCNTL) 00031 switch (flags) 00032 { 00033 case ACE_NONBLOCK: 00034 // nonblocking argument (1) 00035 // blocking: (0) 00036 { 00037 int nonblock = 1; 00038 return ACE_OS::ioctl (handle, FIONBIO, &nonblock); 00039 } 00040 default: 00041 ACE_NOTSUP_RETURN (-1); 00042 } 00043 #else 00044 int val = ACE_OS::fcntl (handle, F_GETFL, 0); 00045 00046 if (val == -1) 00047 return -1; 00048 00049 // Turn on flags. 00050 ACE_SET_BITS (val, flags); 00051 00052 if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) 00053 return -1; 00054 else 00055 return 0; 00056 #endif /* ACE_LACKS_FCNTL */ 00057 } |
|
Reset the limit on the number of open handles. If new_limit == -1 set the limit to the maximum allowable. Otherwise, set the limit value to new_limit. If increase_limit_only is non-0 then only allow increases to the limit. Definition at line 2947 of file ACE.cpp. References ACE_NOTSUP_RETURN, ACE_TRACE, ACE_OS::getrlimit(), max_handles(), ACE_OS::memset(), and ACE_OS::setrlimit(). Referenced by ACE_POSIX_AIOCB_Proactor::check_max_aio_num(), ACE_Select_Reactor_Handler_Repository::open(), and ACE_Dev_Poll_Reactor_Handler_Repository::open().
02949 { 02950 ACE_TRACE ("ACE::set_handle_limit"); 02951 int cur_limit = ACE::max_handles (); 02952 int max_limit = cur_limit; 02953 02954 if (cur_limit == -1) 02955 return -1; 02956 02957 #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) 02958 struct rlimit rl; 02959 02960 ACE_OS::memset ((void *) &rl, 0, sizeof rl); 02961 int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); 02962 if (r == 0) 02963 max_limit = rl.rlim_max; 02964 #endif /* ACE_LACKS_RLIMIT */ 02965 02966 if (new_limit == -1) 02967 new_limit = max_limit; 02968 02969 if (new_limit < 0) 02970 { 02971 errno = EINVAL; 02972 return -1; 02973 } 02974 else if (new_limit > cur_limit) 02975 { 02976 // Increase the limit. 02977 #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) 02978 rl.rlim_cur = new_limit; 02979 return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); 02980 #else 02981 // Must return EINVAL errno. 02982 ACE_NOTSUP_RETURN (-1); 02983 #endif /* ACE_LACKS_RLIMIT */ 02984 } 02985 else if (increase_limit_only == 0) 02986 { 02987 // Decrease the limit. 02988 #if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) 02989 rl.rlim_cur = new_limit; 02990 return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); 02991 #else 02992 // We give a chance to platforms without RLIMIT to work. 02993 // Instead of ACE_NOTSUP_RETURN (0), just return 0 because 02994 // new_limit is <= cur_limit, so it's a no-op. 02995 return 0; 02996 #endif /* ACE_LACKS_RLIMIT */ 02997 } 02998 02999 return 0; 03000 } |
|
Returns a string containing the error message corresponding to a WinSock error. This works around an omission in the Win32 API. For internal use only.
Definition at line 3091 of file ACE.cpp. References ACE_LIB_TEXT, ACE_NOTSUP_RETURN, ACE_TCHAR, and ACE_OS::sprintf(). Referenced by ACE_Log_Msg::log(), and ACE_OS::strerror().
03092 { 03093 #if defined (ACE_WIN32) 03094 static ACE_TCHAR unknown_msg[64]; 03095 03096 switch (error) 03097 { 03098 case WSAVERNOTSUPPORTED: 03099 return ACE_LIB_TEXT ("version of WinSock not supported"); 03100 /* NOTREACHED */ 03101 case WSASYSNOTREADY: 03102 return ACE_LIB_TEXT ("WinSock not present or not responding"); 03103 /* NOTREACHED */ 03104 case WSAEINVAL: 03105 return ACE_LIB_TEXT ("app version not supported by DLL"); 03106 /* NOTREACHED */ 03107 case WSAHOST_NOT_FOUND: 03108 return ACE_LIB_TEXT ("Authoritive: Host not found"); 03109 /* NOTREACHED */ 03110 case WSATRY_AGAIN: 03111 return ACE_LIB_TEXT ("Non-authoritive: host not found or server failure"); 03112 /* NOTREACHED */ 03113 case WSANO_RECOVERY: 03114 return ACE_LIB_TEXT ("Non-recoverable: refused or not implemented"); 03115 /* NOTREACHED */ 03116 case WSANO_DATA: 03117 return ACE_LIB_TEXT ("Valid name, no data record for type"); 03118 /* NOTREACHED */ 03119 /* 03120 case WSANO_ADDRESS: 03121 return "Valid name, no MX record"; 03122 */ 03123 case WSANOTINITIALISED: 03124 return ACE_LIB_TEXT ("WSA Startup not initialized"); 03125 /* NOTREACHED */ 03126 case WSAENETDOWN: 03127 return ACE_LIB_TEXT ("Network subsystem failed"); 03128 /* NOTREACHED */ 03129 case WSAEINPROGRESS: 03130 return ACE_LIB_TEXT ("Blocking operation in progress"); 03131 /* NOTREACHED */ 03132 case WSAEINTR: 03133 return ACE_LIB_TEXT ("Blocking call cancelled"); 03134 /* NOTREACHED */ 03135 case WSAEAFNOSUPPORT: 03136 return ACE_LIB_TEXT ("address family not supported"); 03137 /* NOTREACHED */ 03138 case WSAEMFILE: 03139 return ACE_LIB_TEXT ("no file handles available"); 03140 /* NOTREACHED */ 03141 case WSAENOBUFS: 03142 return ACE_LIB_TEXT ("no buffer space available"); 03143 /* NOTREACHED */ 03144 case WSAEPROTONOSUPPORT: 03145 return ACE_LIB_TEXT ("specified protocol not supported"); 03146 /* NOTREACHED */ 03147 case WSAEPROTOTYPE: 03148 return ACE_LIB_TEXT ("protocol wrong type for this socket"); 03149 /* NOTREACHED */ 03150 case WSAESOCKTNOSUPPORT: 03151 return ACE_LIB_TEXT ("socket type not supported for address family"); 03152 /* NOTREACHED */ 03153 case WSAENOTSOCK: 03154 return ACE_LIB_TEXT ("handle is not a socket"); 03155 /* NOTREACHED */ 03156 case WSAEWOULDBLOCK: 03157 return ACE_LIB_TEXT ("resource temporarily unavailable"); 03158 /* NOTREACHED */ 03159 case WSAEADDRINUSE: 03160 return ACE_LIB_TEXT ("address already in use"); 03161 /* NOTREACHED */ 03162 case WSAECONNABORTED: 03163 return ACE_LIB_TEXT ("connection aborted"); 03164 /* NOTREACHED */ 03165 case WSAECONNRESET: 03166 return ACE_LIB_TEXT ("connection reset"); 03167 /* NOTREACHED */ 03168 case WSAENOTCONN: 03169 return ACE_LIB_TEXT ("not connected"); 03170 /* NOTREACHED */ 03171 case WSAETIMEDOUT: 03172 return ACE_LIB_TEXT ("connection timed out"); 03173 /* NOTREACHED */ 03174 case WSAECONNREFUSED: 03175 return ACE_LIB_TEXT ("connection refused"); 03176 /* NOTREACHED */ 03177 case WSAEHOSTDOWN: 03178 return ACE_LIB_TEXT ("host down"); 03179 /* NOTREACHED */ 03180 case WSAEHOSTUNREACH: 03181 return ACE_LIB_TEXT ("host unreachable"); 03182 /* NOTREACHED */ 03183 case WSAEADDRNOTAVAIL: 03184 return ACE_LIB_TEXT ("address not available"); 03185 /* NOTREACHED */ 03186 case WSAEISCONN: 03187 return ACE_LIB_TEXT ("socket is already connected"); 03188 /* NOTREACHED */ 03189 case WSAENETRESET: 03190 return ACE_LIB_TEXT ("network dropped connection on reset"); 03191 /* NOTREACHED */ 03192 case WSAEMSGSIZE: 03193 return ACE_LIB_TEXT ("message too long"); 03194 /* NOTREACHED */ 03195 case WSAENETUNREACH: 03196 return ACE_LIB_TEXT ("network is unreachable"); 03197 /* NOTREACHED */ 03198 case WSAEFAULT: 03199 return ACE_LIB_TEXT ("bad address"); 03200 /* NOTREACHED */ 03201 case WSAEDISCON: 03202 return ACE_LIB_TEXT ("graceful shutdown in progress"); 03203 /* NOTREACHED */ 03204 case WSAEACCES: 03205 return ACE_LIB_TEXT ("permission denied"); 03206 /* NOTREACHED */ 03207 case WSAESHUTDOWN: 03208 return ACE_LIB_TEXT ("cannot send after socket shutdown"); 03209 /* NOTREACHED */ 03210 case WSAEPROCLIM: 03211 return ACE_LIB_TEXT ("too many processes"); 03212 /* NOTREACHED */ 03213 case WSAEALREADY: 03214 return ACE_LIB_TEXT ("operation already in progress"); 03215 /* NOTREACHED */ 03216 case WSAEPFNOSUPPORT: 03217 return ACE_LIB_TEXT ("protocol family not supported"); 03218 /* NOTREACHED */ 03219 case WSAENOPROTOOPT: 03220 return ACE_LIB_TEXT ("bad protocol option"); 03221 /* NOTREACHED */ 03222 case WSATYPE_NOT_FOUND: 03223 return ACE_LIB_TEXT ("class type not found"); 03224 /* NOTREACHED */ 03225 case WSAEOPNOTSUPP: 03226 return ACE_LIB_TEXT ("operation not supported"); 03227 /* NOTREACHED */ 03228 case WSAEDESTADDRREQ: 03229 return ACE_LIB_TEXT ("destination address required"); 03230 /* NOTREACHED */ 03231 default: 03232 ACE_OS::sprintf (unknown_msg, ACE_LIB_TEXT ("unknown error: %d"), error); 03233 return unknown_msg; 03234 /* NOTREACHED */ 03235 } 03236 #else 03237 ACE_UNUSED_ARG (error); 03238 ACE_NOTSUP_RETURN (0); 03239 #endif /* ACE_WIN32 */ 03240 } |
|
Definition at line 281 of file ACE.inl.
00282 {
00283 delete [] s;
00284 }
|
|
Delete the memory allocated by
Definition at line 274 of file ACE.inl. Referenced by ACE_Process_Options::command_line_argv(), ACE_Service_Type_Impl::name(), ACE_Framework_Component::~ACE_Framework_Component(), and ACE_Process_Options::~ACE_Process_Options().
00275 {
00276 delete [] s;
00277 }
|
|
Definition at line 3401 of file ACE.cpp. References ACE_TEXT_WIDE.
03402 { 03403 while (*s++ != ACE_TEXT_WIDE ('\0')) 03404 continue; 03405 03406 return s; 03407 } |
|
Returns a pointer to the "end" of the string, i.e., the character past the ''. Definition at line 3391 of file ACE.cpp.
03392 { 03393 while (*s++ != '\0') 03394 continue; 03395 03396 return s; 03397 } |
|
Return a dynamically allocated duplicate of str, substituting the environment variable if Definition at line 379 of file ACE.cpp. References ACE_TCHAR, ACE_TRACE, and ACE_OS::strenvdup().
00380 { 00381 ACE_TRACE ("ACE::strenvdup"); 00382 00383 return ACE_OS::strenvdup (str); 00384 } |
|
Definition at line 3324 of file ACE.cpp. References ACE_ALLOCATOR_RETURN, and ACE_OS::strsncpy().
03325 { 03326 const wchar_t *t = str; 03327 size_t len; 03328 03329 // Figure out how long this string is (remember, it might not be 03330 // NUL-terminated). 03331 03332 for (len = 0; 03333 len < n && *t++ != '\0'; 03334 len++) 03335 continue; 03336 03337 wchar_t *s; 03338 ACE_ALLOCATOR_RETURN (s, 03339 static_cast<wchar_t *> ( 03340 ACE_OS::malloc ((len + 1) * sizeof (wchar_t))), 03341 0); 03342 return ACE_OS::strsncpy (s, str, len + 1); 03343 } |
|
Create a fresh new copy of str, up to n chars long. Uses Definition at line 3302 of file ACE.cpp. References ACE_ALLOCATOR_RETURN, and ACE_OS::strsncpy().
03303 { 03304 const char *t = str; 03305 size_t len; 03306 03307 // Figure out how long this string is (remember, it might not be 03308 // NUL-terminated). 03309 03310 for (len = 0; 03311 len < n && *t++ != '\0'; 03312 len++) 03313 continue; 03314 03315 char *s; 03316 ACE_ALLOCATOR_RETURN (s, 03317 (char *) ACE_OS::malloc (len + 1), 03318 0); 03319 return ACE_OS::strsncpy (s, str, len + 1); 03320 } |
|
Definition at line 3427 of file ACE.cpp. References ACE_NEW_RETURN, and ACE_OS::strcpy().
03428 { 03429 if (s == 0) 03430 return 0; 03431 wchar_t *t = 0; 03432 ACE_NEW_RETURN (t, 03433 wchar_t[ACE_OS::strlen (s) + 1], 03434 0); 03435 if (t == 0) 03436 return 0; 03437 else 03438 return ACE_OS::strcpy (t, s); 03439 } |
|
This method is just like Definition at line 3411 of file ACE.cpp. References ACE_NEW_RETURN, and ACE_OS::strcpy(). Referenced by ACE_Logging_Strategy::ACE_Logging_Strategy(), ACE_Process_Options::command_line_argv(), ACE_NT_Service::host(), ACE_Function_Node::make_func_name(), ACE_MEM_Acceptor::mmap_prefix(), ACE_Service_Type_Impl::name(), ACE_Service_Type::name(), ACE_NT_Service::name(), ACE_DLL_Handle::open(), ACE_DLL::open_i(), and ACE_Logging_Strategy::parse_args().
03412 { 03413 if (s == 0) 03414 return 0; 03415 char *t = 0; 03416 ACE_NEW_RETURN (t, 03417 char [::strlen (s) + 1], 03418 0); 03419 if (t == 0) 03420 return 0; 03421 else 03422 return ACE_OS::strcpy (t, s); 03423 } |
|
Definition at line 3369 of file ACE.cpp. References ACE_NEW_RETURN, ACE_TEXT_WIDE, and ACE_OS::strsncpy().
03370 { 03371 const wchar_t *t = str; 03372 size_t len; 03373 03374 // Figure out how long this string is (remember, it might not be 03375 // NUL-terminated). 03376 03377 for (len = 0; 03378 len < n && *t++ != ACE_TEXT_WIDE ('\0'); 03379 len++) 03380 continue; 03381 03382 wchar_t *s; 03383 ACE_NEW_RETURN (s, 03384 wchar_t[len + 1], 03385 0); 03386 return ACE_OS::strsncpy (s, str, len + 1); 03387 } |
|
Create a fresh new copy of str, up to n chars long. Uses Definition at line 3347 of file ACE.cpp. References ACE_NEW_RETURN, and ACE_OS::strsncpy().
03348 { 03349 const char *t = str; 03350 size_t len; 03351 03352 // Figure out how long this string is (remember, it might not be 03353 // NUL-terminated). 03354 03355 for (len = 0; 03356 len < n && *t++ != L'\0'; 03357 len++) 03358 continue; 03359 03360 char *s; 03361 ACE_NEW_RETURN (s, 03362 char[len + 1], 03363 0); 03364 return ACE_OS::strsncpy (s, str, len + 1); 03365 } |
|
As strrepl, but for wide characters.
Definition at line 756 of file Lib_Find.cpp. References ACE_TRACE.
00757 { 00758 ACE_TRACE ("ACE::strrepl"); 00759 00760 size_t replaced = 0; 00761 00762 for (size_t i = 0; s[i] != '\0'; i++) 00763 if (s[i] == search) 00764 { 00765 s[i] = replace; 00766 replaced++; 00767 } 00768 00769 return replaced; 00770 } |
|
Replace all instances of search in s with replace. Returns the number of replacements made. Definition at line 668 of file Lib_Find.cpp. References ACE_TRACE. Referenced by ldfind().
00669 { 00670 ACE_TRACE ("ACE::strrepl"); 00671 00672 size_t replaced = 0; 00673 00674 for (size_t i = 0; s[i] != '\0'; i++) 00675 if (s[i] == search) 00676 { 00677 s[i] = replace; 00678 replaced++; 00679 } 00680 00681 return replaced; 00682 } |
|
As strsplit_r, but for wide characters.
Definition at line 723 of file Lib_Find.cpp. References ACE_OS::strlen(), and ACE_OS::strstr().
00726 { 00727 wchar_t *result = 0; 00728 00729 if (str != 0) 00730 next_start = str; 00731 00732 if (next_start != 0) 00733 { 00734 wchar_t *tok_loc = ACE_OS::strstr (next_start, token); 00735 00736 if (tok_loc != 0) 00737 { 00738 // Return the beginning of the string. 00739 result = next_start; 00740 00741 // Insure it's terminated. 00742 *tok_loc = '\0'; 00743 next_start = tok_loc + ACE_OS::strlen (token); 00744 } 00745 else 00746 { 00747 result = next_start; 00748 next_start = (wchar_t *) 0; 00749 } 00750 } 00751 00752 return result; 00753 } |
|
Splits string into pieces separated by the string . is an opaque cookie handed back by the call to store its state for the next invocation, thus making it re-entrant. This operates very similar to Perl's function except that it returns pieces one at a time instead of into an array. Definition at line 689 of file Lib_Find.cpp. References ACE_OS::strlen(), and ACE_OS::strstr(). Referenced by ldfind().
00692 { 00693 char *result = 0; 00694 00695 if (str != 0) 00696 next_start = str; 00697 00698 if (next_start != 0) 00699 { 00700 char *tok_loc = ACE_OS::strstr (next_start, token); 00701 00702 if (tok_loc != 0) 00703 { 00704 // Return the beginning of the string. 00705 result = next_start; 00706 00707 // Insure it's terminated. 00708 *tok_loc = '\0'; 00709 next_start = tok_loc + ACE_OS::strlen (token); 00710 } 00711 else 00712 { 00713 result = next_start; 00714 next_start = (char *) 0; 00715 } 00716 } 00717 00718 return result; 00719 } |
|
Definition at line 481 of file ACE.cpp. References enter_recv_timedwait(), restore_non_blocking_mode(), ssize_t, and ACE_OS::t_rcv(). Referenced by ACE_TLI_Stream::recv().
00486 { 00487 if (timeout == 0) 00488 return ACE_OS::t_rcv (handle, (char *) buf, len, flags); 00489 else 00490 { 00491 int val = 0; 00492 if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) 00493 return -1; 00494 else 00495 { 00496 ssize_t bytes_transferred = 00497 ACE_OS::t_rcv (handle, (char *) buf, len, flags); 00498 ACE::restore_non_blocking_mode (handle, val); 00499 return bytes_transferred; 00500 } 00501 } 00502 } |
|
Definition at line 66 of file ACE.inl. References t_rcv_n_i(). Referenced by ACE_TLI_Stream::recv_n().
00072 { 00073 if (timeout == 0) 00074 return ACE::t_rcv_n_i (handle, 00075 buf, 00076 len, 00077 flags, 00078 bytes_transferred); 00079 else 00080 return ACE::t_rcv_n_i (handle, 00081 buf, 00082 len, 00083 flags, 00084 timeout, 00085 bytes_transferred); 00086 } |
|
Definition at line 769 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), record_and_set_non_blocking_mode(), restore_non_blocking_mode(), ssize_t, and ACE_OS::t_rcv().
00775 { 00776 size_t temp; 00777 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00778 ssize_t n; 00779 ssize_t result = 0; 00780 int error = 0; 00781 00782 int val = 0; 00783 ACE::record_and_set_non_blocking_mode (handle, val); 00784 00785 for (bytes_transferred = 0; 00786 bytes_transferred < len; 00787 bytes_transferred += n) 00788 { 00789 // Try to transfer as much of the remaining data as possible. 00790 // Since the socket is in non-blocking mode, this call will not 00791 // block. 00792 n = ACE_OS::t_rcv (handle, 00793 (char *) buf + bytes_transferred, 00794 len - bytes_transferred, 00795 flags); 00796 00797 // Check for errors. 00798 if (n == 0 || 00799 n == -1) 00800 { 00801 // Check for possible blocking. 00802 if (n == -1 && 00803 errno == EWOULDBLOCK) 00804 { 00805 // Wait upto <timeout> for the blocking to subside. 00806 int rtn = ACE::handle_read_ready (handle, 00807 timeout); 00808 00809 // Did select() succeed? 00810 if (rtn != -1) 00811 { 00812 // Blocking subsided in <timeout> period. Continue 00813 // data transfer. 00814 n = 0; 00815 continue; 00816 } 00817 } 00818 00819 // Wait in select() timed out or other data transfer or 00820 // select() failures. 00821 error = 1; 00822 result = n; 00823 break; 00824 } 00825 } 00826 00827 ACE::restore_non_blocking_mode (handle, val); 00828 00829 if (error) 00830 return result; 00831 else 00832 return bytes_transferred; 00833 } |
|
Definition at line 718 of file ACE.cpp. References EWOULDBLOCK, handle_read_ready(), ssize_t, and ACE_OS::t_rcv(). Referenced by t_rcv_n().
00723 { 00724 size_t temp; 00725 size_t &bytes_transferred = bt == 0 ? temp : *bt; 00726 ssize_t n; 00727 00728 for (bytes_transferred = 0; 00729 bytes_transferred < len; 00730 bytes_transferred += n) 00731 { 00732 // Try to transfer as much of the remaining data as possible. 00733 n = ACE_OS::t_rcv (handle, 00734 (char *) buf + bytes_transferred, 00735 len - bytes_transferred, 00736 flags); 00737 // Check EOF. 00738 if (n == 0) 00739 return 0; 00740 00741 // Check for other errors. 00742 if (n == -1) 00743 { 00744 // Check for possible blocking. 00745 if (errno == EWOULDBLOCK) 00746 { 00747 // Wait for the blocking to subside. 00748 int result = ACE::handle_read_ready (handle, 00749 0); 00750 00751 // Did select() succeed? 00752 if (result != -1) 00753 { 00754 // Blocking subsided. Continue data transfer. 00755 n = 0; 00756 continue; 00757 } 00758 } 00759 00760 // Other data transfer or select() failures. 00761 return -1; 00762 } 00763 } 00764 00765 return bytes_transferred; 00766 } |
|
Definition at line 1290 of file ACE.cpp. References enter_send_timedwait(), restore_non_blocking_mode(), ssize_t, and ACE_OS::t_snd(). Referenced by ACE_TLI_Stream::send().
01295 { 01296 if (timeout == 0) 01297 return ACE_OS::t_snd (handle, (const char *) buf, n, flags); 01298 else 01299 { 01300 int val = 0; 01301 if (ACE::enter_send_timedwait (handle, timeout, val) == -1) 01302 return -1; 01303 else 01304 { 01305 ssize_t bytes_transferred = ACE_OS::t_snd (handle, (const char *) buf, n, flags); 01306 ACE::restore_non_blocking_mode (handle, val); 01307 return bytes_transferred; 01308 } 01309 } 01310 } |
|
Definition at line 156 of file ACE.inl. References t_snd_n_i(). Referenced by ACE_TLI_Stream::send_n().
00162 { 00163 if (timeout == 0) 00164 return ACE::t_snd_n_i (handle, 00165 buf, 00166 len, 00167 flags, 00168 bytes_transferred); 00169 else 00170 return ACE::t_snd_n_i (handle, 00171 buf, 00172 len, 00173 flags, 00174 timeout, 00175 bytes_transferred); 00176 } |
|
Definition at line 1577 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), record_and_set_non_blocking_mode(), restore_non_blocking_mode(), ssize_t, and ACE_OS::t_snd().
01583 { 01584 size_t temp; 01585 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01586 ssize_t n; 01587 ssize_t result = 0; 01588 int error = 0; 01589 01590 int val = 0; 01591 ACE::record_and_set_non_blocking_mode (handle, val); 01592 01593 for (bytes_transferred = 0; 01594 bytes_transferred < len; 01595 bytes_transferred += n) 01596 { 01597 // Try to transfer as much of the remaining data as possible. 01598 // Since the socket is in non-blocking mode, this call will not 01599 // block. 01600 n = ACE_OS::t_snd (handle, 01601 (char *) buf + bytes_transferred, 01602 len - bytes_transferred, 01603 flags); 01604 01605 // Check for errors. 01606 if (n == 0 || 01607 n == -1) 01608 { 01609 // Check for possible blocking. 01610 if (n == -1 && 01611 errno == EWOULDBLOCK || errno == ENOBUFS) 01612 { 01613 // Wait upto <timeout> for the blocking to subside. 01614 int rtn = ACE::handle_write_ready (handle, 01615 timeout); 01616 01617 // Did select() succeed? 01618 if (rtn != -1) 01619 { 01620 // Blocking subsided in <timeout> period. Continue 01621 // data transfer. 01622 n = 0; 01623 continue; 01624 } 01625 } 01626 01627 // Wait in select() timed out or other data transfer or 01628 // select() failures. 01629 error = 1; 01630 result = n; 01631 break; 01632 } 01633 } 01634 01635 ACE::restore_non_blocking_mode (handle, val); 01636 01637 if (error) 01638 return result; 01639 else 01640 return bytes_transferred; 01641 } |
|
Definition at line 1526 of file ACE.cpp. References ENOBUFS, EWOULDBLOCK, handle_write_ready(), ssize_t, and ACE_OS::t_snd(). Referenced by t_snd_n().
01531 { 01532 size_t temp; 01533 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01534 ssize_t n; 01535 01536 for (bytes_transferred = 0; 01537 bytes_transferred < len; 01538 bytes_transferred += n) 01539 { 01540 // Try to transfer as much of the remaining data as possible. 01541 n = ACE_OS::t_snd (handle, 01542 (char *) buf + bytes_transferred, 01543 len - bytes_transferred, 01544 flags); 01545 // Check EOF. 01546 if (n == 0) 01547 return 0; 01548 01549 // Check for other errors. 01550 if (n == -1) 01551 { 01552 // Check for possible blocking. 01553 if (errno == EWOULDBLOCK || errno == ENOBUFS) 01554 { 01555 // Wait for the blocking to subside. 01556 int result = ACE::handle_write_ready (handle, 01557 0); 01558 01559 // Did select() succeed? 01560 if (result != -1) 01561 { 01562 // Blocking subsided. Continue data transfer. 01563 n = 0; 01564 continue; 01565 } 01566 } 01567 01568 // Other data transfer or select() failures. 01569 return -1; 01570 } 01571 } 01572 01573 return bytes_transferred; 01574 } |
|
Terminate the process abruptly with id pid. On Win32 platforms this uses {TerminateProcess} and on POSIX platforms is uses {kill} with the -9 (SIGKILL) signal, which cannot be caught or ignored. Note that this call is potentially dangerous to use since the process being terminated may not have a chance to cleanup before it shuts down. Definition at line 223 of file ACE.cpp. References ACE_NOTSUP_RETURN, ACE_OS::close(), ACE_OS::kill(), and pid_t. Referenced by ACE_Process_Manager::terminate(), and ACE_Process::terminate().
00224 { 00225 #if defined (ACE_HAS_PHARLAP) 00226 ACE_UNUSED_ARG (pid); 00227 ACE_NOTSUP_RETURN (-1); 00228 #elif defined (ACE_WIN32) 00229 // Create a handle for the given process id. 00230 ACE_HANDLE process_handle = 00231 ::OpenProcess (PROCESS_TERMINATE, 00232 FALSE, // New handle is not inheritable. 00233 pid); 00234 00235 if (process_handle == ACE_INVALID_HANDLE 00236 || process_handle == 0) 00237 return -1; 00238 else 00239 { 00240 // Kill the process associated with process_handle. 00241 BOOL terminate_result = 00242 ::TerminateProcess (process_handle, 0); 00243 // Free up the kernel resources. 00244 ACE_OS::close (process_handle); 00245 return terminate_result ? 0 : -1; 00246 } 00247 #else 00248 return ACE_OS::kill (pid, 9); 00249 #endif /* ACE_HAS_PHARLAP */ 00250 } |
|
Returns the current timestamp in the form "hour:minute:second:microsecond." The month, day, and year are also stored in the beginning of the date_and_time array, which is a user-supplied array of size time_len> Definition at line 2458 of file ACE.cpp. References ACE_LIB_TEXT, ACE_TCHAR, ACE_OS::ctime_r(), ACE_OS::gettimeofday(), ACE_Time_Value::sec(), ACE_OS::sprintf(), ACE_OS::strsncpy(), and ACE_Time_Value::usec(). Referenced by ACE_Log_Msg_UNIX_Syslog::log(), and ACE_Log_Msg::log().
02461 { 02462 //ACE_TRACE ("ACE::timestamp"); 02463 02464 if (date_and_timelen < 35) 02465 { 02466 errno = EINVAL; 02467 return 0; 02468 } 02469 02470 #if defined (WIN32) 02471 // Emulate Unix. Win32 does NOT support all the UNIX versions 02472 // below, so DO we need this ifdef. 02473 static const ACE_TCHAR *day_of_week_name[] = 02474 { 02475 ACE_LIB_TEXT ("Sun"), 02476 ACE_LIB_TEXT ("Mon"), 02477 ACE_LIB_TEXT ("Tue"), 02478 ACE_LIB_TEXT ("Wed"), 02479 ACE_LIB_TEXT ("Thu"), 02480 ACE_LIB_TEXT ("Fri"), 02481 ACE_LIB_TEXT ("Sat") 02482 }; 02483 02484 static const ACE_TCHAR *month_name[] = 02485 { 02486 ACE_LIB_TEXT ("Jan"), 02487 ACE_LIB_TEXT ("Feb"), 02488 ACE_LIB_TEXT ("Mar"), 02489 ACE_LIB_TEXT ("Apr"), 02490 ACE_LIB_TEXT ("May"), 02491 ACE_LIB_TEXT ("Jun"), 02492 ACE_LIB_TEXT ("Jul"), 02493 ACE_LIB_TEXT ("Aug"), 02494 ACE_LIB_TEXT ("Sep"), 02495 ACE_LIB_TEXT ("Oct"), 02496 ACE_LIB_TEXT ("Nov"), 02497 ACE_LIB_TEXT ("Dec") 02498 }; 02499 02500 SYSTEMTIME local; 02501 ::GetLocalTime (&local); 02502 02503 ACE_OS::sprintf (date_and_time, 02504 ACE_LIB_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"), 02505 day_of_week_name[local.wDayOfWeek], 02506 month_name[local.wMonth - 1], 02507 (int) local.wDay, 02508 (int) local.wYear, 02509 (int) local.wHour, 02510 (int) local.wMinute, 02511 (int) local.wSecond, 02512 (int) (local.wMilliseconds * 1000)); 02513 return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; 02514 #else /* UNIX */ 02515 ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page. 02516 ACE_Time_Value cur_time = ACE_OS::gettimeofday (); 02517 time_t secs = cur_time.sec (); 02518 02519 ACE_OS::ctime_r (&secs, 02520 timebuf, 02521 sizeof timebuf); 02522 // date_and_timelen > sizeof timebuf! 02523 ACE_OS::strsncpy (date_and_time, 02524 timebuf, 02525 date_and_timelen); 02526 ACE_TCHAR yeartmp[5]; 02527 ACE_OS::strsncpy (yeartmp, 02528 &date_and_time[20], 02529 5); 02530 ACE_TCHAR timetmp[9]; 02531 ACE_OS::strsncpy (timetmp, 02532 &date_and_time[11], 02533 9); 02534 ACE_OS::sprintf (&date_and_time[11], 02535 # if defined (ACE_USES_WCHAR) 02536 ACE_LIB_TEXT ("%ls %ls.%06ld"), 02537 # else 02538 ACE_LIB_TEXT ("%s %s.%06ld"), 02539 # endif /* ACE_USES_WCHAR */ 02540 yeartmp, 02541 timetmp, 02542 cur_time.usec ()); 02543 date_and_time[33] = '\0'; 02544 return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; 02545 #endif /* WIN32 */ 02546 } |
|
This method uses process id and object pointer to come up with a machine wide unique name. The process ID will provide uniqueness between processes on the same machine. The "this" pointer of the {object} will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of {object}. Definition at line 288 of file ACE.inl. References ACE_TCHAR, and ACE_OS::unique_name(). Referenced by ACE_Semaphore::ACE_Semaphore(), ACE_RW_Process_Mutex::unique_name(), and ACE_Process_Mutex::unique_name().
00291 { 00292 ACE_OS::unique_name (object, name, length); 00293 } |
|
Simple wildcard matching function supporting '*' and '?' return true if string s matches pattern. Definition at line 3450 of file ACE.cpp. References equal_char().
03451 { 03452 if (str == pat) 03453 return true; 03454 if (pat == 0 || str == 0) 03455 return false; 03456 03457 bool star = false; 03458 const char* s = str; 03459 const char* p = pat; 03460 while (*s != '\0') 03461 { 03462 if (*p == '*') 03463 { 03464 star = true; 03465 pat = p; 03466 while (*++pat == '*'); 03467 03468 if (*pat == '\0') 03469 return true; 03470 p = pat; 03471 } 03472 else if (*p == '?') 03473 { 03474 ++s; 03475 ++p; 03476 } 03477 else if (! equal_char(*s, *p, case_sensitive)) 03478 { 03479 if (!star) 03480 return false; 03481 s = ++str; 03482 p = pat; 03483 } 03484 else 03485 { 03486 ++s; 03487 ++p; 03488 } 03489 } 03490 if (*p == '*') 03491 while (*++p == '*'); 03492 03493 return *p == '\0'; 03494 } |
|
Write all the message_blocks chained through their Definition at line 1968 of file ACE.cpp. References ACE_IOV_MAX, ACE_Message_Block::cont(), iovec::iov_base, iovec::iov_len, ACE_Message_Block::length(), ACE_Message_Block::next(), ACE_Message_Block::rd_ptr(), ssize_t, and writev_n().
01971 { 01972 size_t temp; 01973 size_t &bytes_transferred = bt == 0 ? temp : *bt; 01974 bytes_transferred = 0; 01975 01976 iovec iov[ACE_IOV_MAX]; 01977 int iovcnt = 0; 01978 01979 while (message_block != 0) 01980 { 01981 // Our current message block chain. 01982 const ACE_Message_Block *current_message_block = message_block; 01983 01984 while (current_message_block != 0) 01985 { 01986 size_t current_message_block_length = 01987 current_message_block->length (); 01988 char *this_block_ptr = current_message_block->rd_ptr (); 01989 01990 // Check if this block has any data to be sent. 01991 while (current_message_block_length > 0) 01992 { 01993 u_long this_chunk_length; 01994 if (current_message_block_length > ULONG_MAX) 01995 this_chunk_length = ULONG_MAX; 01996 else 01997 this_chunk_length = 01998 static_cast<u_long> (current_message_block_length); 01999 // Collect the data in the iovec. 02000 iov[iovcnt].iov_base = this_block_ptr; 02001 iov[iovcnt].iov_len = this_chunk_length; 02002 current_message_block_length -= this_chunk_length; 02003 this_block_ptr += this_chunk_length; 02004 02005 // Increment iovec counter. 02006 ++iovcnt; 02007 02008 // The buffer is full make a OS call. @@ TODO find a way to 02009 // find ACE_IOV_MAX for platforms that do not define it rather 02010 // than simply setting ACE_IOV_MAX to some arbitrary value such 02011 // as 16. 02012 if (iovcnt == ACE_IOV_MAX) 02013 { 02014 size_t current_transfer = 0; 02015 02016 ssize_t result = ACE::writev_n (handle, 02017 iov, 02018 iovcnt, 02019 ¤t_transfer); 02020 02021 // Add to total bytes transferred. 02022 bytes_transferred += current_transfer; 02023 02024 // Errors. 02025 if (result == -1 || result == 0) 02026 return result; 02027 02028 // Reset iovec counter. 02029 iovcnt = 0; 02030 } 02031 } 02032 02033 // Select the next message block in the chain. 02034 current_message_block = current_message_block->cont (); 02035 } 02036 02037 // Selection of the next message block chain. 02038 message_block = message_block->next (); 02039 } 02040 02041 // Check for remaining buffers to be sent. This will happen when 02042 // ACE_IOV_MAX is not a multiple of the number of message blocks. 02043 if (iovcnt != 0) 02044 { 02045 size_t current_transfer = 0; 02046 02047 ssize_t result = ACE::writev_n (handle, 02048 iov, 02049 iovcnt, 02050 ¤t_transfer); 02051 02052 // Add to total bytes transferred. 02053 bytes_transferred += current_transfer; 02054 02055 // Errors. 02056 if (result == -1 || result == 0) 02057 return result; 02058 } 02059 02060 // Return total bytes transferred. 02061 return bytes_transferred; 02062 } |
|
Definition at line 29 of file ACE.inl. References ACE_OS::write_n(). Referenced by ACE_SPIPE_Stream::send_n(), ACE_Pipe::send_n(), ACE_FILE_IO::send_n(), and ACE_DEV_IO::send_n().
00033 { 00034 return ACE_OS::write_n (handle, 00035 buf, 00036 len, 00037 bytes_transferred); 00038 } |
|
Definition at line 2203 of file ACE.cpp. References iovec::iov_len, ssize_t, and ACE_OS::writev(). Referenced by ACE_SPIPE_Stream::sendv_n(), ACE_Pipe::sendv_n(), ACE_FILE_IO::sendv_n(), and write_n().
02207 { 02208 size_t temp; 02209 size_t &bytes_transferred = bt == 0 ? temp : *bt; 02210 bytes_transferred = 0; 02211 02212 iovec *iov = const_cast<iovec *> (i); 02213 02214 for (int s = 0; 02215 s < iovcnt; 02216 ) 02217 { 02218 ssize_t n = ACE_OS::writev (handle, 02219 iov + s, 02220 iovcnt - s); 02221 if (n == -1 || n == 0) 02222 return n; 02223 02224 for (bytes_transferred += n; 02225 s < iovcnt 02226 && n >= static_cast<ssize_t> (iov[s].iov_len); 02227 s++) 02228 n -= iov[s].iov_len; 02229 02230 if (n != 0) 02231 { 02232 char *base = reinterpret_cast<char *> (iov[s].iov_base); 02233 iov[s].iov_base = base + n; 02234 iov[s].iov_len = iov[s].iov_len - n; 02235 } 02236 } 02237 02238 return bytes_transferred; 02239 } |
|
|
|
|
|
Counter to match <init()>/<fini()> calls. <init()> must increment it; <fini()> must decrement it. <fini()> then does nothing until it reaches 0. Definition at line 12 of file Init_ACE.cpp. |
|
|