Prepare for disk watch thread
This commit is contained in:
@@ -73,7 +73,7 @@ scanout.o: ../config.h ../lib/mbselib.h taskutil.h scanout.h
|
||||
taskcomm.o: ../config.h ../lib/mbselib.h taskstat.h taskregs.h taskdisk.h taskinfo.h taskutil.h taskchat.h taskcomm.h
|
||||
taskinfo.o: ../config.h ../lib/mbselib.h taskinfo.h
|
||||
taskstat.o: ../config.h ../lib/mbselib.h taskstat.h callstat.h outstat.h taskutil.h
|
||||
mbtask.o: ../config.h ../lib/mbselib.h ../paths.h signame.h taskstat.h taskutil.h taskregs.h taskcomm.h callstat.h outstat.h ../lib/nodelist.h ports.h calllist.h ping.h taskchat.h mbtask.h
|
||||
mbtask.o: ../config.h ../lib/mbselib.h ../paths.h signame.h taskstat.h taskutil.h taskregs.h taskcomm.h taskdisk.h callstat.h outstat.h ../lib/nodelist.h ports.h calllist.h ping.h taskchat.h mbtask.h
|
||||
outstat.o: ../config.h ../lib/mbselib.h taskutil.h taskstat.h scanout.h ../lib/nodelist.h callstat.h ports.h outstat.h
|
||||
signame.o: ../config.h signame.h
|
||||
taskdisk.o: ../config.h ../lib/mbselib.h taskdisk.h taskutil.h
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "taskutil.h"
|
||||
#include "taskregs.h"
|
||||
#include "taskcomm.h"
|
||||
#include "taskdisk.h"
|
||||
#include "callstat.h"
|
||||
#include "outstat.h"
|
||||
#include "../lib/nodelist.h"
|
||||
@@ -46,7 +47,7 @@
|
||||
#include "mbtask.h"
|
||||
|
||||
|
||||
#define NUM_THREADS 3 /* Max. nr of threads */
|
||||
#define NUM_THREADS 4 /* Max. nr of threads */
|
||||
|
||||
|
||||
/*
|
||||
@@ -113,6 +114,7 @@ int nodaemon = FALSE; /* Run in foreground */
|
||||
extern int cmd_run; /* Cmd running */
|
||||
extern int ping_run; /* Ping running */
|
||||
int sched_run = FALSE; /* Scheduler running */
|
||||
extern int disk_run; /* Disk watch running */
|
||||
|
||||
|
||||
|
||||
@@ -707,7 +709,7 @@ void die(int onsig)
|
||||
* build to stop within a second.
|
||||
*/
|
||||
now = time(NULL) + 2;
|
||||
while ((cmd_run || ping_run || sched_run) && (time(NULL) < now)) {
|
||||
while ((cmd_run || ping_run || sched_run || disk_run) && (time(NULL) < now)) {
|
||||
sleep(1);
|
||||
}
|
||||
Syslog('+', "All threads stopped");
|
||||
@@ -978,7 +980,10 @@ void start_scheduler(void)
|
||||
} else if ((rc = pthread_create(&p_thread[1], NULL, (void (*))cmd_thread, NULL))) {
|
||||
WriteError("$pthread_create cmd_thread rc=%d", rc);
|
||||
die(SIGTERM);
|
||||
} else if ((rc = pthread_create(&p_thread[2], NULL, (void (*))scheduler, NULL))) {
|
||||
} else if ((rc = pthread_create(&p_thread[2], NULL, (void (*))disk_thread, NULL))) {
|
||||
WriteError("$pthread_create disk_thread rc=%d", rc);
|
||||
die(SIGTERM);
|
||||
} else if ((rc = pthread_create(&p_thread[3], NULL, (void (*))scheduler, NULL))) {
|
||||
WriteError("$pthread_create scheduler rc=%d", rc);
|
||||
die(SIGTERM);
|
||||
} else {
|
||||
|
@@ -364,6 +364,36 @@ char *exe_cmd(char *in)
|
||||
return chat_get(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* The D(isk) commands.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DRES:0; Reset and reread disk tables.
|
||||
* 100:0; Always Ok.
|
||||
*/
|
||||
if (strncmp(cmd, "DRES", 4) == 0) {
|
||||
return disk_reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* DSPC:0; Enough free diskspace.
|
||||
* 100:1,0; No
|
||||
* 100:1,1; Yes
|
||||
* 100:1,2; Unknown
|
||||
* 100:1,3; Error
|
||||
*/
|
||||
if (strncmp(cmd, "DSPC", 4) == 0) {
|
||||
return disk_free();
|
||||
}
|
||||
|
||||
/*
|
||||
* DGFS:0; Get filesystem status.
|
||||
* 100:n,data1,..,data10;
|
||||
*/
|
||||
if (strncmp(cmd, "DGFS", 4) == 0) {
|
||||
return disk_getfs();
|
||||
}
|
||||
|
||||
/*
|
||||
* The G(lobal) commands.
|
||||
@@ -416,11 +446,11 @@ char *exe_cmd(char *in)
|
||||
}
|
||||
|
||||
/*
|
||||
* GDST:0;
|
||||
* GDST:0; Obsolete!
|
||||
* 100:n,data1,..,data10;
|
||||
*/
|
||||
if (strncmp(cmd, "GDST", 4) == 0) {
|
||||
return get_diskstat();
|
||||
return disk_getfs();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -34,12 +34,44 @@
|
||||
#include "taskutil.h"
|
||||
|
||||
|
||||
int disk_reread = FALSE; /* Reread tables */
|
||||
extern int T_Shutdown; /* Program shutdown */
|
||||
int disk_run = FALSE; /* Thread running */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function signals the diskwatcher to reread the tables.
|
||||
*/
|
||||
char *disk_reset(void)
|
||||
{
|
||||
static char buf[10];
|
||||
|
||||
disk_reread = TRUE;
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function checks if enough diskspace is available. (0=No, 1=Yes, 2=Unknown, 3=Error).
|
||||
*/
|
||||
char *disk_free(void)
|
||||
{
|
||||
static char buf[20];
|
||||
|
||||
sprintf(buf, "100:1,2;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function returns the information of all mounted filesystems,
|
||||
* but no more then 10 filesystems.
|
||||
*/
|
||||
char *get_diskstat()
|
||||
char *disk_getfs()
|
||||
{
|
||||
static char buf[SS_BUFSIZE];
|
||||
char *tmp = NULL;
|
||||
@@ -143,3 +175,36 @@ char *get_diskstat()
|
||||
|
||||
|
||||
|
||||
void add_path(char *path)
|
||||
{
|
||||
Syslog('d', "add_path(%s)", path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Diskwatch thread
|
||||
*/
|
||||
void *disk_thread(void)
|
||||
{
|
||||
Syslog('+', "Start disk thread");
|
||||
disk_run = TRUE;
|
||||
disk_reread = TRUE;
|
||||
|
||||
while (! T_Shutdown) {
|
||||
|
||||
if (disk_reread) {
|
||||
disk_reread = FALSE;
|
||||
Syslog('+', "Reread disk filesystems");
|
||||
add_path(CFG.bbs_menus);
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
disk_run = FALSE;
|
||||
Syslog('+', "Disk thread stopped");
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
char *get_diskstat(void); /* Get disk status */
|
||||
|
||||
char *disk_reset(void); /* Reset disk tables */
|
||||
char *disk_free(void); /* Enough free space */
|
||||
char *disk_getfs(void); /* Get disk status */
|
||||
void *disk_thread(void); /* Disk watch thread */
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user