mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:18:11 +00:00
Port the WindowServer and LibGUI to communicate through local sockets.
This is really cool! :^) Apps currently refuse to start if the WindowServer isn't listening on the socket in /wsportal. This makes sense, but I guess it would also be nice to have some sort of "wait for server on startup" mode. This has performance issues, and I'll work on those, but this stuff seems to actually work and I'm very happy with that.
This commit is contained in:
parent
00319c248c
commit
bf58241c11
15 changed files with 190 additions and 51 deletions
|
@ -1784,6 +1784,13 @@ int Process::sys$ioctl(int fd, unsigned request, unsigned arg)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (descriptor->is_socket() && request == 413) {
|
||||
auto* pid = (pid_t*)arg;
|
||||
if (!validate_write_typed(pid))
|
||||
return -EFAULT;
|
||||
*pid = descriptor->socket()->origin_pid();
|
||||
return 0;
|
||||
}
|
||||
if (!descriptor->is_character_device())
|
||||
return -ENOTTY;
|
||||
return descriptor->character_device()->ioctl(*this, request, arg);
|
||||
|
@ -2347,10 +2354,23 @@ int Process::sys$connect(int sockfd, const sockaddr* address, socklen_t address_
|
|||
return -ENOTSOCK;
|
||||
auto& socket = *descriptor->socket();
|
||||
int error;
|
||||
auto server = socket.connect(address, address_size, error);
|
||||
if (!server)
|
||||
if (!socket.connect(address, address_size, error))
|
||||
return error;
|
||||
auto server_descriptor = FileDescriptor::create(move(server), SocketRole::Connected);
|
||||
m_fds[fd].set(move(server_descriptor));
|
||||
return fd;
|
||||
descriptor->set_socket_role(SocketRole::Connected);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Process::wait_for_connect(Socket& socket, int& error)
|
||||
{
|
||||
if (socket.is_connected())
|
||||
return true;
|
||||
m_blocked_connecting_socket = socket;
|
||||
block(BlockedConnect);
|
||||
Scheduler::yield();
|
||||
m_blocked_connecting_socket = nullptr;
|
||||
if (!socket.is_connected()) {
|
||||
error = -ECONNREFUSED;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue