Skip to content

Commit

Permalink
filepush: work around bug in OE Zeus glibc. Fix recordings that hang …
Browse files Browse the repository at this point in the history
…enigma.

On MIPS receivers the default signal blocking mask for a thread appears
to be undefined (and it's really random). If we don't set it explicitly,
it will sometimes let SIGUSR1 work and on other times it won't.

So set the signal blocking mask in the recording thread explicitly now,
and that seems to work.

On ARM receivers this issue never showed.

Also moved installing the signal handler from the thread to the enigma
parent process, because signal handlers are global for the process.
  • Loading branch information
eriksl committed Jan 10, 2021
1 parent 84c159f commit 7173169
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions lib/dvb/filepush.cpp
Expand Up @@ -329,16 +329,18 @@ void eFilePushThreadRecorder::thread()
ssize_t bytes;
int rv;
struct pollfd pfd;

setIoPrio(IOPRIO_CLASS_RT, 7);
sigset_t sigmask;

eDebug("[eFilePushThreadRecorder] THREAD START");

/* we set the signal to not restart syscalls, so we can detect our signal. */
struct sigaction act;
act.sa_handler = signal_handler; // no, SIG_IGN doesn't do it. we want to receive the -EINTR
act.sa_flags = 0;
sigaction(SIGUSR1, &act, 0);
setIoPrio(IOPRIO_CLASS_RT, 7);

/* Only allow SIGUSR1 to be delivered to our thread, don't let any
* other signals (like SIGHCHLD) interrupt our system calls.
* NOTE: signal block masks are per thread, so set it in the thread itself. */
sigfillset(&sigmask);
sigdelset(&sigmask, SIGUSR1);
pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);

hasStarted();

Expand Down Expand Up @@ -451,6 +453,19 @@ void eFilePushThreadRecorder::start(int fd)
m_fd_source = fd;
m_stop = 0;
m_stopped = false;

/* Use a signal to interrupt blocking systems calls (like read()).
* We don't want to get enigma killed by the signal (default action),
* so install a handler. Don't use SIG_IGN (ignore signal) because
* then the system calls won't be interrupted by the signal.
* NOTE: signal options and handlers (except for a block mask) are
* global for the process, so install the handler here and not
* in the thread. */
struct sigaction act;
act.sa_handler = signal_handler;
act.sa_flags = 0;
sigaction(SIGUSR1, &act, nullptr);

run();
}

Expand Down

0 comments on commit 7173169

Please sign in to comment.