The main scheduler doesn't run in a thread anymore
This commit is contained in:
parent
ba17b61b84
commit
4bc6702182
@ -7,6 +7,7 @@ v0.83.11 28-Jan-2006
|
|||||||
will completly restart the connection with that remote.
|
will completly restart the connection with that remote.
|
||||||
Made several functions multithread aware (still not Ok).
|
Made several functions multithread aware (still not Ok).
|
||||||
Finished tasks now report using a signal call.
|
Finished tasks now report using a signal call.
|
||||||
|
The main scheduler doesn't run in a thread anymore.
|
||||||
|
|
||||||
mbcico:
|
mbcico:
|
||||||
Assume EXTCMD is set when GZ or BZ2 is active.
|
Assume EXTCMD is set when GZ or BZ2 is active.
|
||||||
|
@ -113,7 +113,6 @@ int T_Shutdown = FALSE; /* Shutdown threads */
|
|||||||
int nodaemon = FALSE; /* Run in foreground */
|
int nodaemon = FALSE; /* Run in foreground */
|
||||||
extern int cmd_run; /* Cmd running */
|
extern int cmd_run; /* Cmd running */
|
||||||
extern int ping_run; /* Ping running */
|
extern int ping_run; /* Ping running */
|
||||||
int sched_run = FALSE; /* Scheduler running */
|
|
||||||
extern int disk_run; /* Disk watch running */
|
extern int disk_run; /* Disk watch running */
|
||||||
extern int ibc_run; /* IBC thread running */
|
extern int ibc_run; /* IBC thread running */
|
||||||
|
|
||||||
@ -809,17 +808,15 @@ void die(int onsig)
|
|||||||
* build to stop within a second.
|
* build to stop within a second.
|
||||||
*/
|
*/
|
||||||
now = time(NULL) + 2;
|
now = time(NULL) + 2;
|
||||||
while ((cmd_run || ping_run || sched_run || disk_run || ibc_run) && (time(NULL) < now)) {
|
while ((cmd_run || ping_run || disk_run || ibc_run) && (time(NULL) < now)) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
if (cmd_run || ping_run || sched_run || disk_run || ibc_run)
|
if (cmd_run || ping_run || disk_run || ibc_run)
|
||||||
Syslog('+', "Not all threads stopped! Forced shutdown");
|
Syslog('+', "Not all threads stopped! Forced shutdown");
|
||||||
if (cmd_run)
|
if (cmd_run)
|
||||||
Syslog('+', "Thread cmd_run not responding");
|
Syslog('+', "Thread cmd_run not responding");
|
||||||
if (ping_run)
|
if (ping_run)
|
||||||
Syslog('+', "Thread ping_run not responding");
|
Syslog('+', "Thread ping_run not responding");
|
||||||
if (sched_run)
|
|
||||||
Syslog('+', "Thread sched_run not responding");
|
|
||||||
if (disk_run)
|
if (disk_run)
|
||||||
Syslog('+', "Thread disk_run not responding");
|
Syslog('+', "Thread disk_run not responding");
|
||||||
if (ibc_run)
|
if (ibc_run)
|
||||||
@ -1111,9 +1108,6 @@ void start_scheduler(void)
|
|||||||
} else if ((rc = pthread_create(&pt_disk, NULL, (void (*))disk_thread, NULL))) {
|
} else if ((rc = pthread_create(&pt_disk, NULL, (void (*))disk_thread, NULL))) {
|
||||||
WriteError("$pthread_create disk_thread rc=%d", rc);
|
WriteError("$pthread_create disk_thread rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
} else if ((rc = pthread_create(&pt_scheduler, NULL, (void (*))scheduler, NULL))) {
|
|
||||||
WriteError("$pthread_create scheduler rc=%d", rc);
|
|
||||||
die(SIGTERM);
|
|
||||||
} else if ((rc = pthread_create(&pt_ibc, NULL, (void (*))ibc_thread, NULL))) {
|
} else if ((rc = pthread_create(&pt_ibc, NULL, (void (*))ibc_thread, NULL))) {
|
||||||
WriteError("$pthread_create ibc rc=%d", rc);
|
WriteError("$pthread_create ibc rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
@ -1124,20 +1118,18 @@ void start_scheduler(void)
|
|||||||
printf("threads installed\n");
|
printf("threads installed\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sleep until we die
|
* Run the scheduler
|
||||||
*/
|
*/
|
||||||
while (! G_Shutdown) {
|
scheduler();
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scheduler thread
|
* Scheduler loop
|
||||||
*/
|
*/
|
||||||
void *scheduler(void)
|
void scheduler(void)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int running = 0, i, found;
|
int running = 0, i, found;
|
||||||
@ -1155,7 +1147,6 @@ void *scheduler(void)
|
|||||||
pp_list *tpl;
|
pp_list *tpl;
|
||||||
|
|
||||||
Syslog('+', "Starting scheduler thread");
|
Syslog('+', "Starting scheduler thread");
|
||||||
sched_run = TRUE;
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1163,7 +1154,7 @@ void *scheduler(void)
|
|||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
if (T_Shutdown)
|
if (G_Shutdown)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1521,11 +1512,9 @@ void *scheduler(void)
|
|||||||
} /* if (Processing) */
|
} /* if (Processing) */
|
||||||
} /* if ((tm->tm_sec / SLOWRUN) != oldmin) */
|
} /* if ((tm->tm_sec / SLOWRUN) != oldmin) */
|
||||||
|
|
||||||
} while (! T_Shutdown);
|
} while (! G_Shutdown);
|
||||||
|
|
||||||
sched_run = FALSE;
|
Syslog('+', "Scheduler stopped");
|
||||||
Syslog('+', "Scheduler thread stopped");
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1554,7 +1543,6 @@ int main(int argc, char **argv)
|
|||||||
else if ((i == SIGINT) || (i == SIGTERM))
|
else if ((i == SIGINT) || (i == SIGTERM))
|
||||||
signal(i, (void (*))start_shutdown);
|
signal(i, (void (*))start_shutdown);
|
||||||
else if (i == SIGCHLD)
|
else if (i == SIGCHLD)
|
||||||
// signal(i, SIG_DFL);
|
|
||||||
signal(i, (void (*))taskdie);
|
signal(i, (void (*))taskdie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ int runtasktype(int);
|
|||||||
int checktasks(int);
|
int checktasks(int);
|
||||||
void die(int);
|
void die(int);
|
||||||
void start_scheduler(void);
|
void start_scheduler(void);
|
||||||
void *scheduler(void);
|
void scheduler(void);
|
||||||
int locktask(char *);
|
int locktask(char *);
|
||||||
void ulocktask(void);
|
void ulocktask(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user