mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
IPv4: Take the socket lock more (fixes TCP connection to localhost)
This fixes an issue where making a TCP connection to localhost didn't work correctly since the loopback interface is currently synchronous. (Sending something to localhost would enqueue a packet on the same interface and then immediately wake the network task to process that packet.) This was preventing the TCP handshake from working correctly with localhost since we'd send out the SYN packet before moving to the SynSent state. The lock is now held long enough for this operation to be atomic.
This commit is contained in:
@@ -369,6 +369,8 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
||||
return;
|
||||
}
|
||||
|
||||
LOCKER(socket->lock());
|
||||
|
||||
ASSERT(socket->type() == SOCK_STREAM);
|
||||
ASSERT(socket->local_port() == tcp_packet.destination_port());
|
||||
|
||||
@@ -401,6 +403,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
||||
klog() << "handle_tcp: couldn't create client socket";
|
||||
return;
|
||||
}
|
||||
LOCKER(client->lock());
|
||||
#ifdef TCP_DEBUG
|
||||
klog() << "handle_tcp: created new client socket with tuple " << client->tuple().to_string().characters();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user