diff options
author | Fred Hornsey <hornseyf@objectcomputing.com> | 2019-10-31 23:54:56 -0500 |
---|---|---|
committer | Fred Hornsey <hornseyf@objectcomputing.com> | 2019-10-31 23:54:56 -0500 |
commit | 2a52aeb7cb43925057420642cbfc786309c25f02 (patch) | |
tree | 9b497acdc19e3eb824ce9d7eeb0fec5a64323b7b /ACE | |
parent | 4da653590b7958edd4ffc226aff777e087ffd571 (diff) | |
parent | d7cbc42882d28bbf0b130c2e3b4cf9ef353f3227 (diff) | |
download | ATCD-2a52aeb7cb43925057420642cbfc786309c25f02.tar.gz |
Merge remote-tracking branch 'upstream/master' into igtd/monotonic
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/NEWS | 3 | ||||
-rw-r--r-- | ACE/ace/OS_NS_sys_socket.cpp | 81 | ||||
-rw-r--r-- | ACE/ace/OS_NS_sys_socket.h | 16 | ||||
-rw-r--r-- | ACE/ace/OS_NS_sys_socket.inl | 41 | ||||
-rw-r--r-- | ACE/ace/SOCK_Dgram.cpp | 40 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.h | 6 | ||||
-rw-r--r-- | ACE/ace/os_include/sys/os_socket.h | 42 | ||||
-rwxr-xr-x | ACE/bin/fuzz.pl | 3 | ||||
-rw-r--r-- | ACE/include/makeinclude/rules.local.GNU | 1 | ||||
-rw-r--r-- | ACE/tests/SOCK_Dgram_Test.cpp | 7 |
10 files changed, 194 insertions, 46 deletions
@@ -3,6 +3,9 @@ USER VISIBLE CHANGES BETWEEN ACE-6.5.6 and ACE-6.5.7 . Fixed compile problem with glibc 2.30 and newer +. gnuace makefiles: Updated handling of generated files and + use requires/avoids to make postbuild steps conditional + . Removed references to the ACE_LACKS_MONOTONIC_TIME preprocessor macro because it was equivalent to ACE_LACKS_CLOCK_MONOTONIC. diff --git a/ACE/ace/OS_NS_sys_socket.cpp b/ACE/ace/OS_NS_sys_socket.cpp index dec4e2333d0..54364c6cb6b 100644 --- a/ACE/ace/OS_NS_sys_socket.cpp +++ b/ACE/ace/OS_NS_sys_socket.cpp @@ -271,4 +271,85 @@ ACE_OS::send_partial_i (ACE_HANDLE handle, #endif /* ACE_LACKS_SEND && ACE_WIN32 */ } +#if !defined ACE_LACKS_RECVMSG && defined ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 +int ACE_OS::recvmsg_win32_i (ACE_HANDLE handle, + msghdr *msg, + int flags, + unsigned long &bytes_received) +{ + static GUID wsaRcvMsgGuid = WSAID_WSARECVMSG; + LPFN_WSARECVMSG wsaRcvMsg = 0; + unsigned long ioctlN = 0; + SOCKET const sock = reinterpret_cast<SOCKET> (handle); + if (::WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, + &wsaRcvMsgGuid, sizeof wsaRcvMsgGuid, + &wsaRcvMsg, sizeof wsaRcvMsg, + &ioctlN, 0, 0)) + { + ACE_OS::set_errno_to_wsa_last_error (); + return -1; + } + + if (!wsaRcvMsg) + ACE_NOTSUP_RETURN (-1); + + WSAMSG wsaMsg = + { + msg->msg_name, + msg->msg_namelen, + reinterpret_cast<WSABUF *> (msg->msg_iov), + static_cast<unsigned long> (msg->msg_iovlen), + { + static_cast<unsigned long> (msg->msg_controllen), + static_cast<char *> (msg->msg_control), + }, + static_cast<unsigned long> (flags), + }; + + if (wsaRcvMsg (sock, &wsaMsg, &bytes_received, 0, 0)) + { + ACE_OS::set_errno_to_wsa_last_error (); + return -1; + } + + return 0; +} + +int ACE_OS::sendmsg_win32_i (ACE_HANDLE handle, + msghdr const *msg, + int flags, + unsigned long &bytes_sent) +{ +# if _WIN32_WINNT >= 0x0600 + WSAMSG wsaMsg = + { + msg->msg_name, + msg->msg_namelen, + reinterpret_cast<WSABUF *> (msg->msg_iov), + static_cast<unsigned long> (msg->msg_iovlen), + { + static_cast<unsigned long> (msg->msg_controllen), + static_cast<char *> (msg->msg_control), + }, + static_cast<unsigned long> (flags), + }; + + SOCKET const sock = reinterpret_cast<SOCKET> (handle); + if (::WSASendMsg (sock, &wsaMsg, wsaMsg.dwFlags, &bytes_sent, 0, 0)) + { + ACE_OS::set_errno_to_wsa_last_error (); + return -1; + } + + return 0; +# else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (msg); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (bytes_sent); + ACE_NOTSUP_RETURN (-1); +# endif +} +#endif + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/OS_NS_sys_socket.h b/ACE/ace/OS_NS_sys_socket.h index 1f972a9f24d..d7e7524a6ad 100644 --- a/ACE/ace/OS_NS_sys_socket.h +++ b/ACE/ace/OS_NS_sys_socket.h @@ -193,6 +193,14 @@ namespace ACE_OS struct msghdr *msg, int flags); +#if !defined ACE_LACKS_RECVMSG && defined ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 + extern ACE_Export + int recvmsg_win32_i (ACE_HANDLE handle, + msghdr *msg, + int flags, + unsigned long &bytes_received); +#endif + ACE_NAMESPACE_INLINE_FUNCTION ssize_t recvv (ACE_HANDLE handle, iovec *iov, @@ -217,6 +225,14 @@ namespace ACE_OS const struct msghdr *msg, int flags); +#if !defined ACE_LACKS_RECVMSG && defined ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 + extern ACE_Export + int sendmsg_win32_i (ACE_HANDLE handle, + msghdr const *msg, + int flags, + unsigned long &bytes_sent); +#endif + ACE_NAMESPACE_INLINE_FUNCTION ssize_t sendto (ACE_HANDLE handle, const char *buf, diff --git a/ACE/ace/OS_NS_sys_socket.inl b/ACE/ace/OS_NS_sys_socket.inl index 54aa02395c3..484e1f4ff00 100644 --- a/ACE/ace/OS_NS_sys_socket.inl +++ b/ACE/ace/OS_NS_sys_socket.inl @@ -472,16 +472,17 @@ ACE_OS::recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags) #if !defined (ACE_LACKS_RECVMSG) # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) DWORD bytes_received = 0; - - int result = ::WSARecvFrom ((SOCKET) handle, - (WSABUF *) msg->msg_iov, - msg->msg_iovlen, - &bytes_received, - (DWORD *) &flags, - msg->msg_name, - &msg->msg_namelen, - 0, - 0); + int const result = msg->msg_control + ? recvmsg_win32_i (handle, msg, flags, bytes_received) + : ::WSARecvFrom ((SOCKET) handle, + (WSABUF *) msg->msg_iov, + msg->msg_iovlen, + &bytes_received, + (DWORD *) &flags, + msg->msg_name, + &msg->msg_namelen, + 0, + 0); if (result != 0) { @@ -628,15 +629,17 @@ ACE_OS::sendmsg (ACE_HANDLE handle, #if !defined (ACE_LACKS_SENDMSG) # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) DWORD bytes_sent = 0; - int result = ::WSASendTo ((SOCKET) handle, - (WSABUF *) msg->msg_iov, - msg->msg_iovlen, - &bytes_sent, - flags, - msg->msg_name, - msg->msg_namelen, - 0, - 0); + int const result = msg->msg_control + ? sendmsg_win32_i (handle, msg, flags, bytes_sent) + : ::WSASendTo ((SOCKET) handle, + (WSABUF *) msg->msg_iov, + msg->msg_iovlen, + &bytes_sent, + flags, + msg->msg_name, + msg->msg_namelen, + 0, + 0); if (result != 0) { diff --git a/ACE/ace/SOCK_Dgram.cpp b/ACE/ace/SOCK_Dgram.cpp index 95b213b24d3..d70d8a84b78 100644 --- a/ACE/ace/SOCK_Dgram.cpp +++ b/ACE/ace/SOCK_Dgram.cpp @@ -296,6 +296,11 @@ ACE_SOCK_Dgram::send (const iovec iov[], send_msg.msg_accrightslen = 0; #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ +#ifdef ACE_WIN32 + send_msg.msg_control = 0; + send_msg.msg_controllen = 0; +#endif + return ACE_OS::sendmsg (this->get_handle (), &send_msg, flags); @@ -314,21 +319,22 @@ ACE_SOCK_Dgram::recv (iovec iov[], ACE_TRACE ("ACE_SOCK_Dgram::recv"); msghdr recv_msg; -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) || defined ACE_WIN32 +#define ACE_USE_MSG_CONTROL union control_buffer { cmsghdr control_msg_header; #if defined (IP_RECVDSTADDR) - u_char padding[CMSG_SPACE(sizeof (struct in_addr))]; + u_char padding[ACE_CMSG_SPACE (sizeof (in_addr))]; #elif defined (IP_PKTINFO) - u_char padding[CMSG_SPACE(sizeof (struct in_pktinfo))]; + u_char padding[ACE_CMSG_SPACE (sizeof (in_pktinfo))]; #endif #if defined (ACE_HAS_IPV6) - u_char padding6[CMSG_SPACE(sizeof (struct in6_pktinfo))]; + u_char padding6[ACE_CMSG_SPACE (sizeof (in6_pktinfo))]; #endif } cbuf; #else ACE_UNUSED_ARG (to_addr); -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ +#endif recv_msg.msg_iov = (iovec *) iov; recv_msg.msg_iovlen = n; @@ -339,13 +345,13 @@ ACE_SOCK_Dgram::recv (iovec iov[], #endif /* ACE_HAS_SOCKADDR_MSG_NAME */ recv_msg.msg_namelen = addr.get_size (); -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#ifdef ACE_USE_MSG_CONTROL recv_msg.msg_control = to_addr ? &cbuf : 0; recv_msg.msg_controllen = to_addr ? sizeof (cbuf) : 0; #elif !defined ACE_LACKS_SENDMSG recv_msg.msg_accrights = 0; recv_msg.msg_accrightslen = 0; -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ +#endif ssize_t status = ACE_OS::recvmsg (this->get_handle (), &recv_msg, @@ -353,24 +359,22 @@ ACE_SOCK_Dgram::recv (iovec iov[], addr.set_size (recv_msg.msg_namelen); addr.set_type (((sockaddr_in *) addr.get_addr())->sin_family); -#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) +#ifdef ACE_USE_MSG_CONTROL if (to_addr) { this->get_local_addr (*to_addr); if (to_addr->get_type() == AF_INET) { #if defined (IP_RECVDSTADDR) || defined (IP_PKTINFO) - for (cmsghdr *ptr = CMSG_FIRSTHDR (&recv_msg); ptr != 0; ptr = CMSG_NXTHDR (&recv_msg, ptr)) { + for (cmsghdr *ptr = ACE_CMSG_FIRSTHDR (&recv_msg); ptr; ptr = ACE_CMSG_NXTHDR (&recv_msg, ptr)) { #if defined (IP_RECVDSTADDR) - if (ptr->cmsg_level == IPPROTO_IP && - ptr->cmsg_type == IP_RECVDSTADDR) { - to_addr->set_address ((const char *)(CMSG_DATA (ptr)), + if (ptr->cmsg_level == IPPROTO_IP && ptr->cmsg_type == IP_RECVDSTADDR) { + to_addr->set_address ((const char *) (ACE_CMSG_DATA (ptr)), sizeof (struct in_addr), 0); break; } #else - if (ptr->cmsg_level == IPPROTO_IP && - ptr->cmsg_type == IP_PKTINFO) { - to_addr->set_address ((const char *)&(((struct in_pktinfo *)(CMSG_DATA (ptr)))->ipi_addr), + if (ptr->cmsg_level == IPPROTO_IP && ptr->cmsg_type == IP_PKTINFO) { + to_addr->set_address ((const char *) &(((in_pktinfo *) (ACE_CMSG_DATA (ptr)))->ipi_addr), sizeof (struct in_addr), 0); break; @@ -381,9 +385,9 @@ ACE_SOCK_Dgram::recv (iovec iov[], } #if defined (ACE_HAS_IPV6) && defined (IPV6_PKTINFO) else if (to_addr->get_type() == AF_INET6) { - for (cmsghdr *ptr = CMSG_FIRSTHDR (&recv_msg); ptr != 0; ptr = CMSG_NXTHDR (&recv_msg, ptr)) { + for (cmsghdr *ptr = ACE_CMSG_FIRSTHDR (&recv_msg); ptr; ptr = ACE_CMSG_NXTHDR (&recv_msg, ptr)) { if (ptr->cmsg_level == IPPROTO_IPV6 && ptr->cmsg_type == IPV6_PKTINFO) { - to_addr->set_address ((const char *)&(((struct in6_pktinfo *)(CMSG_DATA (ptr)))->ipi6_addr), + to_addr->set_address ((const char *) &(((in6_pktinfo *)(ACE_CMSG_DATA (ptr)))->ipi6_addr), sizeof (struct in6_addr), 0); @@ -393,7 +397,7 @@ ACE_SOCK_Dgram::recv (iovec iov[], } #endif } -#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ +#endif return status; } diff --git a/ACE/ace/Service_Gestalt.h b/ACE/ace/Service_Gestalt.h index aae3b398124..0a4d9b158a4 100644 --- a/ACE/ace/Service_Gestalt.h +++ b/ACE/ace/Service_Gestalt.h @@ -263,9 +263,9 @@ public: #if (ACE_USES_CLASSIC_SVC_CONF == 1) /// Dynamically link the shared object file and retrieve a pointer to /// the designated shared object in this file. Also account for the - /// possiblity to have static services registered when loading the DLL, by - /// ensuring that the dynamic sevice is registered before any of its - /// subordibnate static services. Thus avoiding any finalization order + /// possibility to have static services registered when loading the DLL, by + /// ensuring that the dynamic service is registered before any of its + /// subordinate static services. Thus avoiding any finalization order /// problems. int initialize (const ACE_Service_Type_Factory *, const ACE_TCHAR *parameters); diff --git a/ACE/ace/os_include/sys/os_socket.h b/ACE/ace/os_include/sys/os_socket.h index dbdba632729..cd287246422 100644 --- a/ACE/ace/os_include/sys/os_socket.h +++ b/ACE/ace/os_include/sys/os_socket.h @@ -77,7 +77,7 @@ extern "C" struct msghdr { /// Optional address - sockaddr * msg_name; + sockaddr *msg_name; /// Size of address int msg_namelen; @@ -92,9 +92,49 @@ extern "C" caddr_t msg_accrights; int msg_accrightslen; + + /// Control messages, set msg_control to 0 if not using: + void *msg_control; + int msg_controllen; }; + + typedef WSACMSGHDR cmsghdr; #endif /* ACE_WIN32 */ + // Using msghdr::msg_control and msghdr::msg_controllen portably: + // For a parameter of size n, reserve space for ACE_CMSG_SPACE(n) bytes. + // This can be extended to the sum of ACE_CMSG_SPACE(n_i) for multiple + // parameters. + // Pass that buffer's address and length as msg_control/msg_controllen when + // invoking sendmsg/recvmsg. The buffer's address must be aligned to hold an + // object of type cmsghdr at the beginning of the buffer. + // If the send or recv succeeds, examine the + // resulting cmsg structure using the following macros with signatures: + // cmsghdr *ACE_CMSG_FIRSTHDR(msghdr *m) + // cmsghdr *ACE_CMSG_NXTHDR(msghdr *m, cmsghdr *c) + // unsigned char *ACE_CMSG_DATA(cmsghdr *c) + +#ifdef ACE_WIN32 +# define ACE_CMSG_SPACE WSA_CMSG_SPACE +# define ACE_CMSG_FIRSTHDR(msg) \ + (((msg)->msg_controllen >= sizeof (WSACMSGHDR)) \ + ? (LPWSACMSGHDR) (msg)->msg_control : (LPWSACMSGHDR) 0) +# define ACE_CMSG_NXTHDR(msg, cmsg) \ + (((cmsg) == 0) ? ACE_CMSG_FIRSTHDR (msg) \ + : ((((PUCHAR) (cmsg) + WSA_CMSGHDR_ALIGN ((cmsg)->cmsg_len) \ + + sizeof (WSACMSGHDR)) > (PUCHAR) ((msg)->msg_control) \ + + (msg)->msg_controllen) \ + ? (LPWSACMSGHDR) 0 \ + : (LPWSACMSGHDR) ((PUCHAR) (cmsg) \ + + WSA_CMSGHDR_ALIGN ((cmsg)->cmsg_len)))) +# define ACE_CMSG_DATA WSA_CMSG_DATA +#else +# define ACE_CMSG_SPACE CMSG_SPACE +# define ACE_CMSG_FIRSTHDR CMSG_FIRSTHDR +# define ACE_CMSG_NXTHDR CMSG_NXTHDR +# define ACE_CMSG_DATA CMSG_DATA +#endif + #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) // Control message size to pass a file descriptor. # define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE) diff --git a/ACE/bin/fuzz.pl b/ACE/bin/fuzz.pl index a237f0ed59f..cbe752d84a6 100755 --- a/ACE/bin/fuzz.pl +++ b/ACE/bin/fuzz.pl @@ -2447,7 +2447,7 @@ if (!getopts ('cdx:hl:t:s:mv') || $opt_h) { check_for_bad_ace_trace check_for_changelog_errors check_for_ptr_arith_t - check_for_include + check_for_include (disabled by default) check_for_non_bool_operators check_for_long_file_names check_for_refcountservantbase @@ -2542,7 +2542,6 @@ check_for_absolute_ace_wrappers () if ($opt_l >= 3); check_for_bad_ace_trace () if ($opt_l >= 4); check_for_changelog_errors () if ($opt_l >= 4); check_for_ptr_arith_t () if ($opt_l >= 4); -check_for_include () if ($opt_l >= 5); check_for_non_bool_operators () if ($opt_l > 2); check_for_long_file_names () if ($opt_l >= 1); check_for_improper_main_declaration () if ($opt_l >= 1); diff --git a/ACE/include/makeinclude/rules.local.GNU b/ACE/include/makeinclude/rules.local.GNU index 6a71c3a00fd..025c4aceb35 100644 --- a/ACE/include/makeinclude/rules.local.GNU +++ b/ACE/include/makeinclude/rules.local.GNU @@ -49,6 +49,7 @@ ifeq ($(use_pwd_call),) endif endif +.PHONY: makefile_name.local ifneq ($(use_pwd_call),1) makefile_name.local: @echo diff --git a/ACE/tests/SOCK_Dgram_Test.cpp b/ACE/tests/SOCK_Dgram_Test.cpp index ff90f748fe5..f09889ebda4 100644 --- a/ACE/tests/SOCK_Dgram_Test.cpp +++ b/ACE/tests/SOCK_Dgram_Test.cpp @@ -128,7 +128,7 @@ client (void *arg) } #endif /* ACE_HAS_IPV6 */ - ACE_INET_Addr to_addr = local_addr; + ACE_INET_Addr to_addr(9999); #if defined(ACE_LACKS_RECVMSG) ssize_t rcv_cnt = cli_dgram.recv (buf, @@ -195,10 +195,11 @@ client (void *arg) ACE_TEXT ("(%P|%t) recv addr size %d; should be %d\n"), peer_addr.get_size (), server_addr.get_size ())); - if (local_addr != to_addr) { +#if defined ACE_RECVPKTINFO6 || defined ACE_RECVPKTINFO + if (local_addr != to_addr) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) local addr is not equal to server addr\n"))); - } +#endif } } |