Do signal masking before thread creation

This commit is contained in:
Iwan Timmer 2019-02-17 22:03:14 +01:00
parent 292a26d6ad
commit d7ac8654e5
3 changed files with 11 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of Moonlight Embedded. * This file is part of Moonlight Embedded.
* *
* Copyright (C) 2015 Iwan Timmer * Copyright (C) 2015-2019 Iwan Timmer
* *
* Moonlight is free software; you can redistribute it and/or modify * Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -87,7 +87,7 @@ void loop_remove_fd(int fd) {
} }
} }
void loop_main() { void loop_init() {
main_thread_id = pthread_self(); main_thread_id = pthread_self();
sigset_t sigset; sigset_t sigset;
sigemptyset(&sigset); sigemptyset(&sigset);
@ -98,8 +98,9 @@ void loop_main() {
sigprocmask(SIG_BLOCK, &sigset, NULL); sigprocmask(SIG_BLOCK, &sigset, NULL);
sigFd = signalfd(-1, &sigset, 0); sigFd = signalfd(-1, &sigset, 0);
loop_add_fd(sigFd, loop_sig_handler, POLLIN | POLLERR | POLLHUP); loop_add_fd(sigFd, loop_sig_handler, POLLIN | POLLERR | POLLHUP);
}
//static bool evdev_poll(bool (*handler) (struct input_event*, struct input_device*)) { void loop_main() {
while (poll(fds, numFds, -1)) { while (poll(fds, numFds, -1)) {
for (int i=0;i<numFds;i++) { for (int i=0;i<numFds;i++) {
if (fds[i].revents > 0) { if (fds[i].revents > 0) {

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of Moonlight Embedded. * This file is part of Moonlight Embedded.
* *
* Copyright (C) 2015 Iwan Timmer * Copyright (C) 2015-2019 Iwan Timmer
* *
* Moonlight is free software; you can redistribute it and/or modify * Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,4 +25,5 @@ typedef int(*FdHandler)(int fd);
void loop_add_fd(int fd, FdHandler handler, int events); void loop_add_fd(int fd, FdHandler handler, int events);
void loop_remove_fd(int fd); void loop_remove_fd(int fd);
void loop_init();
void loop_main(); void loop_main();

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of Moonlight Embedded. * This file is part of Moonlight Embedded.
* *
* Copyright (C) 2015-2017 Iwan Timmer * Copyright (C) 2015-2019 Iwan Timmer
* *
* Moonlight is free software; you can redistribute it and/or modify * Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -121,6 +121,9 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
connection_debug = true; connection_debug = true;
} }
if (IS_EMBEDDED(system))
loop_init();
platform_start(system); platform_start(system);
LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0); LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);