1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:47:36 +00:00

GEventLoop: Rename s_event_fd => s_windowserver_fd.

This commit is contained in:
Andreas Kling 2019-05-14 17:12:09 +02:00
parent 5f7bb9d072
commit 2e0d8ee98f
2 changed files with 17 additions and 17 deletions

View file

@ -24,15 +24,15 @@
//#define GEVENTLOOP_DEBUG //#define GEVENTLOOP_DEBUG
//#define COALESCING_DEBUG //#define COALESCING_DEBUG
int GEventLoop::s_event_fd = -1; int GEventLoop::s_windowserver_fd = -1;
int GEventLoop::s_my_client_id = -1; int GEventLoop::s_my_client_id = -1;
pid_t GEventLoop::s_server_pid = -1; pid_t GEventLoop::s_server_pid = -1;
void GEventLoop::connect_to_server() void GEventLoop::connect_to_server()
{ {
ASSERT(s_event_fd == -1); ASSERT(s_windowserver_fd == -1);
s_event_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); s_windowserver_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (s_event_fd < 0) { if (s_windowserver_fd < 0) {
perror("socket"); perror("socket");
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
@ -44,7 +44,7 @@ void GEventLoop::connect_to_server()
int retries = 1000; int retries = 1000;
int rc = 0; int rc = 0;
while (retries) { while (retries) {
rc = connect(s_event_fd, (const sockaddr*)&address, sizeof(address)); rc = connect(s_windowserver_fd, (const sockaddr*)&address, sizeof(address));
if (rc == 0) if (rc == 0)
break; break;
#ifdef GEVENTLOOP_DEBUG #ifdef GEVENTLOOP_DEBUG
@ -325,7 +325,7 @@ bool GEventLoop::drain_messages_from_server()
bool is_first_pass = true; bool is_first_pass = true;
for (;;) { for (;;) {
WSAPI_ServerMessage message; WSAPI_ServerMessage message;
ssize_t nread = read(s_event_fd, &message, sizeof(WSAPI_ServerMessage)); ssize_t nread = read(s_windowserver_fd, &message, sizeof(WSAPI_ServerMessage));
if (nread < 0) { if (nread < 0) {
perror("read"); perror("read");
quit(1); quit(1);
@ -345,11 +345,11 @@ bool GEventLoop::drain_messages_from_server()
extra_data = ByteBuffer::create_uninitialized(message.extra_size); extra_data = ByteBuffer::create_uninitialized(message.extra_size);
fd_set rfds; fd_set rfds;
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(s_event_fd, &rfds); FD_SET(s_windowserver_fd, &rfds);
struct timeval timeout { 1, 0 }; struct timeval timeout { 1, 0 };
int rc = select(s_event_fd + 1, &rfds, nullptr, nullptr, &timeout); int rc = select(s_windowserver_fd + 1, &rfds, nullptr, nullptr, &timeout);
ASSERT(rc == 1); ASSERT(rc == 1);
int extra_nread = read(s_event_fd, extra_data.data(), extra_data.size()); int extra_nread = read(s_windowserver_fd, extra_data.data(), extra_data.size());
ASSERT(extra_nread == message.extra_size); ASSERT(extra_nread == message.extra_size);
} }
m_unprocessed_bundles.append({ move(message), move(extra_data) }); m_unprocessed_bundles.append({ move(message), move(extra_data) });
@ -373,7 +373,7 @@ bool GEventLoop::post_message_to_server(const WSAPI_ClientMessage& message, cons
++iov_count; ++iov_count;
} }
int nwritten = writev(s_event_fd, iov, iov_count); int nwritten = writev(s_windowserver_fd, iov, iov_count);
ASSERT(nwritten == sizeof(message) + extra_data.size()); ASSERT(nwritten == sizeof(message) + extra_data.size());
return true; return true;
@ -384,13 +384,13 @@ bool GEventLoop::wait_for_specific_event(WSAPI_ServerMessage::Type type, WSAPI_S
for (;;) { for (;;) {
fd_set rfds; fd_set rfds;
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(s_event_fd, &rfds); FD_SET(s_windowserver_fd, &rfds);
int rc = select(s_event_fd + 1, &rfds, nullptr, nullptr, nullptr); int rc = select(s_windowserver_fd + 1, &rfds, nullptr, nullptr, nullptr);
if (rc < 0) { if (rc < 0) {
perror("select"); perror("select");
} }
ASSERT(rc > 0); ASSERT(rc > 0);
ASSERT(FD_ISSET(s_event_fd, &rfds)); ASSERT(FD_ISSET(s_windowserver_fd, &rfds));
bool success = drain_messages_from_server(); bool success = drain_messages_from_server();
if (!success) if (!success)
return false; return false;

View file

@ -32,13 +32,13 @@ public:
private: private:
virtual void add_file_descriptors_for_select(fd_set& fds, int& max_fd_added) override virtual void add_file_descriptors_for_select(fd_set& fds, int& max_fd_added) override
{ {
FD_SET(s_event_fd, &fds); FD_SET(s_windowserver_fd, &fds);
max_fd_added = s_event_fd; max_fd_added = s_windowserver_fd;
} }
virtual void process_file_descriptors_after_select(const fd_set& fds) override virtual void process_file_descriptors_after_select(const fd_set& fds) override
{ {
if (FD_ISSET(s_event_fd, &fds)) if (FD_ISSET(s_windowserver_fd, &fds))
drain_messages_from_server(); drain_messages_from_server();
} }
@ -71,5 +71,5 @@ private:
Vector<IncomingWSMessageBundle> m_unprocessed_bundles; Vector<IncomingWSMessageBundle> m_unprocessed_bundles;
static pid_t s_server_pid; static pid_t s_server_pid;
static int s_my_client_id; static int s_my_client_id;
static int s_event_fd; static int s_windowserver_fd;
}; };