MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ release_socket()

void MayaFlux::Core::UDPBackend::release_socket ( uint16_t  local_port)
private

Decrement ref_count for a socket.

Closes if zero.

Definition at line 326 of file UDPBackend.cpp.

327{
328 std::unique_lock lock(m_sockets_mutex);
329 auto it = m_sockets.find(local_port);
330 if (it == m_sockets.end()) {
331 return;
332 }
333
334 it->second->ref_count--;
335 if (it->second->ref_count == 0) {
336 asio::error_code ec;
337
338 if (it->second->socket.close(ec)) {
340 "Error closing UDP socket on port {}: {}", local_port, ec.message());
341 }
342 m_sockets.erase(it);
343
345 "UDP socket on port {} released", local_port);
346 }
347}
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< uint16_t, std::unique_ptr< SocketState > > m_sockets
std::shared_mutex m_sockets_mutex
@ NetworkBackend
Network transport backend (UDP, TCP, SHM)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, m_sockets, m_sockets_mutex, MF_DEBUG, MF_WARN, and MayaFlux::Journal::NetworkBackend.

Referenced by close_endpoint(), and open_endpoint().

+ Here is the caller graph for this function: