mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 02:22:51 +00:00
IPv4: Use the UDP-to-socket map to handle incoming UDP packets.
This commit is contained in:
parent
209a16bb7f
commit
3ad9561b80
Notes:
sideshowbarker
2024-07-19 15:04:07 +09:00
Author: https://github.com/awesomekling
Commit: 3ad9561b80
2 changed files with 22 additions and 11 deletions
|
@ -50,8 +50,14 @@ IPv4Socket::IPv4Socket(int type, int protocol)
|
|||
|
||||
IPv4Socket::~IPv4Socket()
|
||||
{
|
||||
LOCKER(all_sockets().lock());
|
||||
all_sockets().resource().remove(this);
|
||||
{
|
||||
LOCKER(all_sockets().lock());
|
||||
all_sockets().resource().remove(this);
|
||||
}
|
||||
if (type() == SOCK_DGRAM) {
|
||||
LOCKER(sockets_by_udp_port().lock());
|
||||
sockets_by_udp_port().resource().remove(m_source_port);
|
||||
}
|
||||
}
|
||||
|
||||
bool IPv4Socket::get_address(sockaddr* address, socklen_t* address_size)
|
||||
|
@ -128,6 +134,7 @@ void IPv4Socket::allocate_source_port_if_needed()
|
|||
auto it = sockets_by_udp_port().resource().find(port);
|
||||
if (it == sockets_by_udp_port().resource().end()) {
|
||||
m_source_port = port;
|
||||
sockets_by_udp_port().resource().set(port, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue