mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
Net: Put a bunch of socket debug logging behind FOO_DEBUG
Also remove an unused Socket::listen() implementation.
This commit is contained in:
parent
ec65b8db2e
commit
e08991319a
Notes:
sideshowbarker
2024-07-19 11:39:04 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e08991319a2
3 changed files with 10 additions and 11 deletions
|
@ -37,7 +37,9 @@ NonnullRefPtr<IPv4Socket> IPv4Socket::create(int type, int protocol)
|
|||
IPv4Socket::IPv4Socket(int type, int protocol)
|
||||
: Socket(AF_INET, type, protocol)
|
||||
{
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
kprintf("%s(%u) IPv4Socket{%p} created with type=%u, protocol=%d\n", current->process().name().characters(), current->pid(), this, type, protocol);
|
||||
#endif
|
||||
LOCKER(all_sockets().lock());
|
||||
all_sockets().resource().set(this);
|
||||
}
|
||||
|
@ -95,7 +97,9 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
|
|||
m_local_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
|
||||
m_local_port = requested_local_port;
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbgprintf("IPv4Socket::bind %s{%p} to %s:%u\n", class_name(), this, m_local_address.to_string().characters(), m_local_port);
|
||||
#endif
|
||||
|
||||
return protocol_bind();
|
||||
}
|
||||
|
@ -109,7 +113,9 @@ KResult IPv4Socket::listen(int backlog)
|
|||
set_backlog(backlog);
|
||||
m_role = Role::Listener;
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
kprintf("IPv4Socket{%p} listening with backlog=%d\n", this, backlog);
|
||||
#endif
|
||||
|
||||
return protocol_listen();
|
||||
}
|
||||
|
@ -253,7 +259,9 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
|
|||
auto& ipv4_packet = *(const IPv4Packet*)(packet.data.value().data());
|
||||
|
||||
if (addr) {
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbgprintf("Incoming packet is from: %s:%u\n", packet.peer_address.to_string().characters(), packet.peer_port);
|
||||
#endif
|
||||
auto& ia = *(sockaddr_in*)addr;
|
||||
memcpy(&ia.sin_addr, &packet.peer_address, sizeof(IPv4Address));
|
||||
ia.sin_port = htons(packet.peer_port);
|
||||
|
|
|
@ -158,7 +158,9 @@ KResult LocalSocket::listen(int backlog)
|
|||
return KResult(-EOPNOTSUPP);
|
||||
set_backlog(backlog);
|
||||
m_connect_side_role = m_role = Role::Listener;
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("LocalSocket{%p} listening with backlog=%d\n", this, backlog);
|
||||
#endif
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,17 +43,6 @@ void Socket::set_setup_state(SetupState new_setup_state)
|
|||
m_setup_state = new_setup_state;
|
||||
}
|
||||
|
||||
KResult Socket::listen(int backlog)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (m_type != SOCK_STREAM)
|
||||
return KResult(-EOPNOTSUPP);
|
||||
m_backlog = backlog;
|
||||
m_role = Role::Listener;
|
||||
kprintf("Socket{%p} listening with backlog=%d\n", this, m_backlog);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
RefPtr<Socket> Socket::accept()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
|
|
Loading…
Add table
Reference in a new issue