| 75 | } |
| 76 | |
| 77 | bool MulticastManager::join(const NetworkInterfaceAddress& nia, |
| 78 | ACE_Reactor* reactor, |
| 79 | ACE_Event_Handler* event_handler, |
| 80 | const NetworkAddress& multicast_group_address, |
| 81 | ACE_SOCK_Dgram_Mcast& multicast_socket |
| 82 | #ifdef ACE_HAS_IPV6 |
| 83 | , const NetworkAddress& ipv6_multicast_group_address, |
| 84 | ACE_SOCK_Dgram_Mcast& ipv6_multicast_socket |
| 85 | #endif |
| 86 | ) |
| 87 | { |
| 88 | bool joined = false; |
| 89 | |
| 90 | if (joined_interfaces_.count(nia.name) == 0 && nia.is_ipv4()) { |
| 91 | if (0 == multicast_socket.join(multicast_group_address.to_addr(), 1, nia.name.empty() ? 0 : ACE_TEXT_CHAR_TO_TCHAR(nia.name.c_str()))) { |
| 92 | joined_interfaces_.insert(nia.name); |
| 93 | if (log_level >= LogLevel::Info) { |
| 94 | ACE_DEBUG((LM_INFO, |
| 95 | "(%P|%t) INFO: MulticastManager::join: joined group %C on %C/%C (%@ joined count %B)\n", |
| 96 | LogAddr(multicast_group_address).c_str(), |
| 97 | nia.name.empty() ? "all interfaces" : nia.name.c_str(), |
| 98 | LogAddr(nia.address, LogAddr::Ip).c_str(), |
| 99 | this, |
| 100 | joined_interface_count())); |
| 101 | } |
| 102 | joined = true; |
| 103 | |
| 104 | if (reactor) { |
| 105 | if (reactor->register_handler(multicast_socket.get_handle(), |
| 106 | event_handler, |
| 107 | ACE_Event_Handler::READ_MASK) != 0) { |
| 108 | if (log_level >= LogLevel::Error) { |
| 109 | ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: MulticastManager::join: failed to register multicast input handler\n")); |
| 110 | } |
| 111 | } |
| 112 | } else if (log_level >= LogLevel::Error) { |
| 113 | ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: MulticastManager::join: reactor is NULL\n")); |
| 114 | } |
| 115 | } else { |
| 116 | if (log_level >= LogLevel::Warning) { |
| 117 | ACE_ERROR((LM_WARNING, |
| 118 | "(%P|%t) WARNING: MulticastManager::join: failed to join group %C on %C/%C (%@ joined count %B): %m\n", |
| 119 | LogAddr(multicast_group_address).c_str(), |
| 120 | nia.name.empty() ? "all interfaces" : nia.name.c_str(), |
| 121 | LogAddr(nia.address, LogAddr::Ip).c_str(), |
| 122 | this, |
| 123 | joined_interface_count())); |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | #ifdef ACE_HAS_IPV6 |
| 129 | if (ipv6_joined_interfaces_.count(nia.name) == 0 && nia.is_ipv6()) { |
| 130 | // Windows 7 has an issue with different threads concurrently calling join for ipv6 |
| 131 | static ACE_Thread_Mutex ipv6_static_lock; |
| 132 | ACE_GUARD_RETURN(ACE_Thread_Mutex, g3, ipv6_static_lock, false); |
| 133 | |
| 134 | if (0 == ipv6_multicast_socket.join(ipv6_multicast_group_address.to_addr(), 1, nia.name.empty() ? 0 : ACE_TEXT_CHAR_TO_TCHAR(nia.name.c_str()))) { |
nothing calls this directly
no test coverage detected