Unify unnecessarily scattered calls to sigprocmask

This commit is contained in:
Ashish Kumar Yadav 2020-07-29 18:45:08 +05:30
parent 6ef0de3d10
commit 74621edcab

View file

@ -116,10 +116,8 @@ void
setroot()
{
if (updatestatus()) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
XSync(dpy, False);
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
}
}
@ -157,7 +155,7 @@ setupsignals()
/* to handle update signals for individual blocks */
sa.sa_flags |= SA_NODEFER;
// sigemptyset(&sa.sa_mask);
sa.sa_mask = blocksigmask;
sa.sa_sigaction = sighandler;
for (Block *current = blocks; current->pathu; current++)
if (current->signal > 0)
@ -169,11 +167,8 @@ sighandler(int signal, siginfo_t *si, void *ucontext)
{
signal -= SIGRTMIN;
for (Block *current = blocks; current->pathu; current++)
if (current->signal == signal) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
if (current->signal == signal)
getcmd(current, si->si_value.sival_int);
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
}
setroot();
}
@ -183,23 +178,21 @@ statusloop()
int i;
/* first run */
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++)
if (current->interval >= 0) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
if (current->interval >= 0)
getcmd(current, NILL);
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
}
setroot();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
sleep(SLEEPINTERVAL);
i = SLEEPINTERVAL;
/* main loop */
while (statuscontinue) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++)
if (current->interval > 0 && i % current->interval == 0) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
if (current->interval > 0 && i % current->interval == 0)
getcmd(current, NILL);
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
}
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
setroot();
sleep(SLEEPINTERVAL);
i += SLEEPINTERVAL;