mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
WindowServer: Use blocking sockets for client connections.
This commit is contained in:
parent
5023464d95
commit
091448b8f3
1 changed files with 3 additions and 14 deletions
|
@ -26,7 +26,7 @@ WSEventLoop::WSEventLoop()
|
||||||
|
|
||||||
unlink("/tmp/wsportal");
|
unlink("/tmp/wsportal");
|
||||||
|
|
||||||
m_server_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
m_server_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||||
ASSERT(m_server_fd >= 0);
|
ASSERT(m_server_fd >= 0);
|
||||||
sockaddr_un address;
|
sockaddr_un address;
|
||||||
address.sun_family = AF_LOCAL;
|
address.sun_family = AF_LOCAL;
|
||||||
|
@ -300,7 +300,7 @@ void WSEventLoop::drain_client(WSClientConnection& client)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
WSAPI_ClientMessage message;
|
WSAPI_ClientMessage message;
|
||||||
// FIXME: Don't go one message at a time, that's so much context switching, oof.
|
// FIXME: Don't go one message at a time, that's so much context switching, oof.
|
||||||
ssize_t nread = read(client.fd(), &message, sizeof(WSAPI_ClientMessage));
|
ssize_t nread = recv(client.fd(), &message, sizeof(WSAPI_ClientMessage), MSG_DONTWAIT);
|
||||||
if (nread == 0 || (nread == -1 && errno == EAGAIN)) {
|
if (nread == 0 || (nread == -1 && errno == EAGAIN)) {
|
||||||
if (!messages_received)
|
if (!messages_received)
|
||||||
post_event(client, make<WSClientDisconnectedNotification>(client.client_id()));
|
post_event(client, make<WSClientDisconnectedNotification>(client.client_id()));
|
||||||
|
@ -316,19 +316,8 @@ void WSEventLoop::drain_client(WSClientConnection& client)
|
||||||
dbgprintf("message.extra_size is way too large\n");
|
dbgprintf("message.extra_size is way too large\n");
|
||||||
return client.did_misbehave();
|
return client.did_misbehave();
|
||||||
}
|
}
|
||||||
|
|
||||||
extra_data = ByteBuffer::create_uninitialized(message.extra_size);
|
extra_data = ByteBuffer::create_uninitialized(message.extra_size);
|
||||||
|
// FIXME: We should allow this to time out. Maybe use a socket timeout?
|
||||||
fd_set rfds;
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_SET(client.fd(), &rfds);
|
|
||||||
struct timeval timeout { 1, 0 };
|
|
||||||
int rc = select(client.fd() + 1, &rfds, nullptr, nullptr, &timeout);
|
|
||||||
if (rc != 1) {
|
|
||||||
dbgprintf("extra_data didn't show up in time\n");
|
|
||||||
return client.did_misbehave();
|
|
||||||
}
|
|
||||||
|
|
||||||
int extra_nread = read(client.fd(), extra_data.data(), extra_data.size());
|
int extra_nread = read(client.fd(), extra_data.data(), extra_data.size());
|
||||||
if (extra_nread != message.extra_size) {
|
if (extra_nread != message.extra_size) {
|
||||||
dbgprintf("extra_nread(%d) != extra_size(%d)\n", extra_nread, extra_data.size());
|
dbgprintf("extra_nread(%d) != extra_size(%d)\n", extra_nread, extra_data.size());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue