diff options
author | asynts <asynts@gmail.com> | 2021-01-14 22:37:57 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-22 22:14:30 +0100 |
commit | c6ebca5b4555c4a0480c11dcb9de245d7328d4de (patch) | |
tree | cee60bd279cba2b6cd1b77950fcc3d4beb1b4db1 /Kernel/Net | |
parent | dd727d1fecf4451643e4f17f15dfcfeab3eedc61 (diff) | |
download | serenity-c6ebca5b4555c4a0480c11dcb9de245d7328d4de.zip |
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 23 | ||||
-rw-r--r-- | Kernel/Net/Socket.cpp | 14 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 21 |
3 files changed, 18 insertions, 40 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 6f50ebe4ae..4ad67b810c 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <AK/Debug.h> #include <AK/Singleton.h> #include <AK/StringBuilder.h> #include <Kernel/FileSystem/FileDescription.h> @@ -75,9 +76,7 @@ LocalSocket::LocalSocket(int type) evaluate_block_conditions(); }); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} created with type=" << type; -#endif + dbgln<debug_local_socket>("LocalSocket({}) created with type={}", this, type); } LocalSocket::~LocalSocket() @@ -113,9 +112,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path))); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} bind(" << path << ")"; -#endif + dbgln<debug_local_socket>("LocalSocket({}) bind({})", this, path); mode_t mode = S_IFSOCK | (m_prebind_mode & 04777); UidAndGid owner { m_prebind_uid, m_prebind_gid }; @@ -159,9 +156,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka return EFAULT; safe_address[sizeof(safe_address) - 1] = '\0'; -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ")"; -#endif + dbgln<debug_local_socket>("LocalSocket({}) connect({})", this, safe_address); auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory()); if (description_or_error.is_error()) @@ -197,9 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka return EINTR; } -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ") status is " << to_string(setup_state()); -#endif + dbgln<debug_local_socket>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state())); if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) { set_connect_side_role(Role::None); @@ -218,9 +211,9 @@ KResult LocalSocket::listen(size_t backlog) auto previous_role = m_role; m_role = Role::Listener; set_connect_side_role(Role::Listener, previous_role != m_role); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} listening with backlog=" << backlog; -#endif + + dbgln<debug_local_socket>("LocalSocket({}) listening with backlog={}", this, backlog); + return KSuccess; } diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index f17934e656..2bd9d3f875 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <AK/Debug.h> #include <AK/StringBuilder.h> #include <AK/StringView.h> #include <Kernel/FileSystem/FileDescription.h> @@ -65,10 +66,7 @@ Socket::~Socket() void Socket::set_setup_state(SetupState new_setup_state) { -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} setup state moving from " << to_string(m_setup_state) << " to " << to_string(new_setup_state); -#endif - + dbgln<debug_socket>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state)); m_setup_state = new_setup_state; evaluate_block_conditions(); } @@ -78,9 +76,7 @@ RefPtr<Socket> Socket::accept() LOCKER(m_lock); if (m_pending.is_empty()) return nullptr; -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} de-queueing connection"; -#endif + dbgln<debug_socket>("Socket({}) de-queueing connection", this); auto client = m_pending.take_first(); ASSERT(!client->is_connected()); auto& process = *Process::current(); @@ -94,9 +90,7 @@ RefPtr<Socket> Socket::accept() KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer) { -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} queueing connection"; -#endif + dbgln<debug_socket>("Socket({}) queueing connection", this); LOCKER(m_lock); if (m_pending.size() >= m_backlog) return ECONNREFUSED; diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 08bda1251f..e10c9031f7 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <AK/Debug.h> #include <AK/Singleton.h> #include <AK/Time.h> #include <Kernel/Devices/RandomDevice.h> @@ -48,9 +49,7 @@ void TCPSocket::for_each(Function<void(const TCPSocket&)> callback) void TCPSocket::set_state(State new_state) { -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket{" << this << "} state moving from " << to_string(m_state) << " to " << to_string(new_state); -#endif + dbgln<debug_tcp_socket>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state)); auto was_disconnected = protocol_is_disconnected(); auto previous_role = m_role; @@ -157,9 +156,7 @@ TCPSocket::~TCPSocket() LOCKER(sockets_by_tuple().lock()); sockets_by_tuple().resource().remove(tuple()); -#ifdef TCP_SOCKET_DEBUG - dbg() << "~TCPSocket in state " << to_string(state()); -#endif + dbgln<debug_tcp_socket>("~TCPSocket in state {}", to_string(state())); } NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol) @@ -278,18 +275,14 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) if (packet.has_ack()) { u32 ack_number = packet.ack_number(); -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: receive_tcp_packet: " << ack_number; -#endif + dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet: {}", ack_number); int removed = 0; LOCKER(m_not_acked_lock); while (!m_not_acked.is_empty()) { auto& packet = m_not_acked.first(); -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: iterate: " << packet.ack_number; -#endif + dbgln<debug_tcp_socket>("TCPSocket: iterate: {}", packet.ack_number); if (packet.ack_number <= ack_number) { m_not_acked.take_first(); @@ -299,9 +292,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) } } -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: receive_tcp_packet acknowledged " << removed << " packets"; -#endif + dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed); } m_packets_in++; |