Skip to content

Commit

Permalink
NetworkWidget: Add Blocking column
Browse files Browse the repository at this point in the history
  • Loading branch information
sepalani committed May 13, 2020
1 parent 74b2410 commit 4bf7c3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Source/Core/Core/IOS/Network/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
return wii_fd;
}

bool WiiSockMan::IsSocketBlocking(s32 wii_fd) const
{
const auto it = WiiSockets.find(wii_fd);
return it != WiiSockets.end() && !it->second.nonBlock;
}

s32 WiiSockMan::NewSocket(s32 af, s32 type, s32 protocol)
{
if (af != 2 && af != 23) // AF_INET && AF_INET6
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/IOS/Network/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class WiiSockMan
// NON-BLOCKING FUNCTIONS
s32 NewSocket(s32 af, s32 type, s32 protocol);
s32 AddSocket(s32 fd, bool is_rw);
bool IsSocketBlocking(s32 wii_fd) const;
s32 GetHostSocket(s32 wii_fd) const;
s32 DeleteSocket(s32 s);
s32 GetLastNetError() const { return errno_last; }
Expand Down
14 changes: 12 additions & 2 deletions Source/Core/DolphinQt/Debugger/NetworkWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ QTableWidgetItem* GetSocketState(s32 host_fd)
return new QTableWidgetItem(QTableWidget::tr("Unbound"));
}

QTableWidgetItem* GetSocketBlocking(s32 wii_fd)
{
const auto& socket_manager = IOS::HLE::WiiSockMan::GetInstance();
if (socket_manager.GetHostSocket(wii_fd) < 0)
return new QTableWidgetItem();
const bool is_blocking = socket_manager.IsSocketBlocking(wii_fd);
return new QTableWidgetItem(is_blocking ? QTableWidget::tr("Yes") : QTableWidget::tr("No"));
}

static QString GetAddressAndPort(const sockaddr_in& addr)
{
char buffer[16];
Expand Down Expand Up @@ -214,7 +223,8 @@ void NetworkWidget::Update()
m_socket_table->setItem(wii_fd, 1, GetSocketDomain(host_fd));
m_socket_table->setItem(wii_fd, 2, GetSocketType(host_fd));
m_socket_table->setItem(wii_fd, 3, GetSocketState(host_fd));
m_socket_table->setItem(wii_fd, 4, GetSocketName(host_fd));
m_socket_table->setItem(wii_fd, 4, GetSocketBlocking(wii_fd));
m_socket_table->setItem(wii_fd, 5, GetSocketName(host_fd));
}
m_socket_table->resizeColumnsToContents();

Expand Down Expand Up @@ -253,7 +263,7 @@ QGroupBox* NetworkWidget::CreateSocketTableGroup()

m_socket_table = new QTableWidget();
// i18n: FD stands for file descriptor (and in this case refers to sockets, not regular files)
QStringList header{tr("FD"), tr("Domain"), tr("Type"), tr("State"), tr("Name")};
QStringList header{tr("FD"), tr("Domain"), tr("Type"), tr("State"), tr("Blocking"), tr("Name")};
m_socket_table->setColumnCount(header.size());

m_socket_table->setHorizontalHeaderLabels(header);
Expand Down

0 comments on commit 4bf7c3e

Please sign in to comment.