mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-02-14 20:20:34 +01:00
Keep SIGALRM restart flag after Popen
Commit94ab7455added SA_RESTART to the SIGALRM handler. However, the Popen code tears down and recreates the SIGALRM handler via OsSignal(), and this flag is dropped at this time. Clean the code to use just a single codepath for creating this signal handler, always applying SA_RESTART. [ajax: Fixed commit id] Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Daniel Drake <drake@endlessm.com> (cherry picked from commit1f915e8b52)
This commit is contained in:
parent
f92c0b9f94
commit
0134dc1b56
1 changed files with 38 additions and 11 deletions
49
os/utils.c
49
os/utils.c
|
|
@ -1208,14 +1208,15 @@ SmartScheduleTimer(int sig)
|
|||
SmartScheduleTime += SmartScheduleInterval;
|
||||
}
|
||||
|
||||
void
|
||||
SmartScheduleInit(void)
|
||||
static int
|
||||
SmartScheduleEnable(void)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
||||
struct sigaction act;
|
||||
|
||||
if (SmartScheduleDisable)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
memset((char *) &act, 0, sizeof(struct sigaction));
|
||||
|
||||
|
|
@ -1224,11 +1225,40 @@ SmartScheduleInit(void)
|
|||
act.sa_handler = SmartScheduleTimer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaddset(&act.sa_mask, SIGALRM);
|
||||
if (sigaction(SIGALRM, &act, 0) < 0) {
|
||||
ret = sigaction(SIGALRM, &act, 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
SmartSchedulePause(void)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef SMART_SCHEDULE_POSSIBLE
|
||||
struct sigaction act;
|
||||
|
||||
if (SmartScheduleDisable)
|
||||
return 0;
|
||||
|
||||
memset((char *) &act, 0, sizeof(struct sigaction));
|
||||
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset(&act.sa_mask);
|
||||
ret = sigaction(SIGALRM, &act, 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
SmartScheduleInit(void)
|
||||
{
|
||||
if (SmartScheduleDisable)
|
||||
return;
|
||||
|
||||
if (SmartScheduleEnable() < 0) {
|
||||
perror("sigaction for smart scheduler");
|
||||
SmartScheduleDisable = TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SIG_BLOCK
|
||||
|
|
@ -1403,8 +1433,6 @@ static struct pid {
|
|||
int pid;
|
||||
} *pidlist;
|
||||
|
||||
OsSigHandlerPtr old_alarm = NULL; /* XXX horrible awful hack */
|
||||
|
||||
void *
|
||||
Popen(const char *command, const char *type)
|
||||
{
|
||||
|
|
@ -1427,8 +1455,7 @@ Popen(const char *command, const char *type)
|
|||
}
|
||||
|
||||
/* Ignore the smart scheduler while this is going on */
|
||||
old_alarm = OsSignal(SIGALRM, SIG_IGN);
|
||||
if (old_alarm == SIG_ERR) {
|
||||
if (SmartSchedulePause() < 0) {
|
||||
close(pdes[0]);
|
||||
close(pdes[1]);
|
||||
free(cur);
|
||||
|
|
@ -1441,7 +1468,7 @@ Popen(const char *command, const char *type)
|
|||
close(pdes[0]);
|
||||
close(pdes[1]);
|
||||
free(cur);
|
||||
if (OsSignal(SIGALRM, old_alarm) == SIG_ERR)
|
||||
if (SmartScheduleEnable() < 0)
|
||||
perror("signal");
|
||||
return NULL;
|
||||
case 0: /* child */
|
||||
|
|
@ -1616,7 +1643,7 @@ Pclose(void *iop)
|
|||
/* allow EINTR again */
|
||||
OsReleaseSignals();
|
||||
|
||||
if (old_alarm && OsSignal(SIGALRM, old_alarm) == SIG_ERR) {
|
||||
if (SmartScheduleEnable() < 0) {
|
||||
perror("signal");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue