check euid when creating update thread

This commit is contained in:
Vincent Wei
2023-07-21 11:52:52 +08:00
parent 1611a56754
commit 5f8a88c0a2
2 changed files with 16 additions and 11 deletions

View File

@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <string.h>
// #define _DEBUG
#define _DEBUG
#include "common.h"
@@ -2630,19 +2630,27 @@ error:
static int create_async_updater(_THIS)
{
if (sem_init(&this->hidden->sync_sem, 0, 0))
if (sem_init(&this->hidden->sync_sem, 0, 0)) {
_ERR_PRINTF("NEWGAL>DRM: failed to create sync. semaphore: %m\n");
return -1;
}
pthread_attr_t attr;
pthread_attr_init(&attr);
struct sched_param sp = { 90 };
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setschedparam(&attr, &sp);
#ifdef __LINUX__
if (geteuid() == 0) {
struct sched_param sp = { 99 };
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setschedparam(&attr, &sp);
}
#endif
if (pthread_create(&this->hidden->update_thd, &attr,
task_do_update, this))
task_do_update, this)) {
_ERR_PRINTF("NEWGAL>DRM: failed to create update thread: %m\n");
return -1;
}
sem_wait(&this->hidden->sync_sem);
pthread_attr_destroy(&attr);
@@ -3821,9 +3829,6 @@ static BOOL DRM_SyncUpdate(_THIS)
this->hidden->driver_ops->flush_driver(this->hidden->driver);
}
_DBG_PRINTF("called: %d, %d, %d, %d\n", bound.left, bound.top,
bound.right, bound.bottom);
{
drmModeClip clip = { bound.left, bound.top,
bound.right, bound.bottom };

View File

@@ -750,7 +750,7 @@ static int create_async_updater(_THIS)
pthread_attr_init(&attr);
#ifdef __LINUX__
if (geteuid() == 0) {
struct sched_param sp = { 90 };
struct sched_param sp = { 99 };
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setschedparam(&attr, &sp);