core: begin using CFileDescriptor from hyprutils (#9122)
* config: make fd use CFileDescriptor make use of the new hyprutils CFileDescriptor instead of manual FD handling. * hyprctl: make fd use CFileDescriptor make use of the new hyprutils CFileDescriptor instead of manual FD handling. * ikeyboard: make fd use CFileDescriptor make use of the new CFileDescriptor instead of manual FD handling, also in sendKeymap remove dead code, it already early returns if keyboard isnt valid, and dont try to close the FD that ikeyboard owns. * core: make SHMFile functions use CFileDescriptor make SHMFile misc functions use CFileDescriptor and its associated usage in dmabuf and keyboard. * core: make explicit sync use CFileDescriptor begin using CFileDescriptor in explicit sync and its timelines and eglsync usage in opengl, there is still a bit left with manual handling that requires future aquamarine change aswell. * eventmgr: make fd and sockets use CFileDescriptor make use of the hyprutils CFileDescriptor instead of manual FD and socket handling and closing. * eventloopmgr: make timerfd use CFileDescriptor make the timerfd use CFileDescriptor instead of manual fd handling * opengl: make gbm fd use CFileDescriptor make the gbm rendernode fd use CFileDescriptor instead of manual fd handling * core: make selection source/offer use CFileDescriptor make data selection source and offers use CFileDescriptor and its associated use in xwm and protocols * protocols: convert protocols fd to CFileDescriptor make most fd handling use CFileDescriptor in protocols * shm: make SHMPool use CfileDescriptor make SHMPool use CFileDescriptor instead of manual fd handling. * opengl: duplicate fd with CFileDescriptor duplicate fenceFD with CFileDescriptor duplicate instead. * xwayland: make sockets and fds use CFileDescriptor instead of manual opening/closing make sockets and fds use CFileDescriptor * keybindmgr: make sockets and fds use CFileDescriptor make sockets and fds use CFileDescriptor instead of manual handling.
This commit is contained in:
parent
7d1c78f4a3
commit
32c0fa2f2f
50 changed files with 422 additions and 526 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "SecurityContext.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include <sys/socket.h>
|
||||
using namespace Hyprutils::OS;
|
||||
|
||||
static int onListenFdEvent(int fd, uint32_t mask, void* data) {
|
||||
auto sc = (CSecurityContext*)data;
|
||||
|
|
@ -14,8 +15,8 @@ static int onCloseFdEvent(int fd, uint32_t mask, void* data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
SP<CSecurityContextSandboxedClient> CSecurityContextSandboxedClient::create(int clientFD_) {
|
||||
auto p = SP<CSecurityContextSandboxedClient>(new CSecurityContextSandboxedClient(clientFD_));
|
||||
SP<CSecurityContextSandboxedClient> CSecurityContextSandboxedClient::create(CFileDescriptor clientFD_) {
|
||||
auto p = SP<CSecurityContextSandboxedClient>(new CSecurityContextSandboxedClient(std::move(clientFD_)));
|
||||
if (!p->client)
|
||||
return nullptr;
|
||||
return p;
|
||||
|
|
@ -27,8 +28,8 @@ static void onSecurityContextClientDestroy(wl_listener* l, void* d) {
|
|||
client->onDestroy();
|
||||
}
|
||||
|
||||
CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(int clientFD_) : clientFD(clientFD_) {
|
||||
client = wl_client_create(g_pCompositor->m_sWLDisplay, clientFD);
|
||||
CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(CFileDescriptor clientFD_) : clientFD(std::move(clientFD_)) {
|
||||
client = wl_client_create(g_pCompositor->m_sWLDisplay, clientFD.get());
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
|
|
@ -41,7 +42,6 @@ CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(int clientFD_)
|
|||
CSecurityContextSandboxedClient::~CSecurityContextSandboxedClient() {
|
||||
wl_list_remove(&destroyListener.listener.link);
|
||||
wl_list_init(&destroyListener.listener.link);
|
||||
close(clientFD);
|
||||
}
|
||||
|
||||
void CSecurityContextSandboxedClient::onDestroy() {
|
||||
|
|
@ -113,8 +113,8 @@ CSecurityContext::CSecurityContext(SP<CWpSecurityContextV1> resource_, int liste
|
|||
|
||||
LOGM(LOG, "security_context at 0x{:x} commits", (uintptr_t)this);
|
||||
|
||||
listenSource = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, listenFD, WL_EVENT_READABLE, ::onListenFdEvent, this);
|
||||
closeSource = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, closeFD, 0, ::onCloseFdEvent, this);
|
||||
listenSource = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, listenFD.get(), WL_EVENT_READABLE, ::onListenFdEvent, this);
|
||||
closeSource = wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, closeFD.get(), 0, ::onCloseFdEvent, this);
|
||||
|
||||
if (!listenSource || !closeSource) {
|
||||
r->noMemory();
|
||||
|
|
@ -144,16 +144,15 @@ void CSecurityContext::onListen(uint32_t mask) {
|
|||
if (!(mask & WL_EVENT_READABLE))
|
||||
return;
|
||||
|
||||
int clientFD = accept(listenFD, nullptr, nullptr);
|
||||
if UNLIKELY (clientFD < 0) {
|
||||
CFileDescriptor clientFD{accept(listenFD.get(), nullptr, nullptr)};
|
||||
if UNLIKELY (!clientFD.isValid()) {
|
||||
LOGM(ERR, "security_context at 0x{:x} couldn't accept", (uintptr_t)this);
|
||||
return;
|
||||
}
|
||||
|
||||
auto newClient = CSecurityContextSandboxedClient::create(clientFD);
|
||||
auto newClient = CSecurityContextSandboxedClient::create(std::move(clientFD));
|
||||
if UNLIKELY (!newClient) {
|
||||
LOGM(ERR, "security_context at 0x{:x} couldn't create a client", (uintptr_t)this);
|
||||
close(clientFD);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue