Prepare for disk watch thread
This commit is contained in:
parent
b94cf4a837
commit
a1345b8c84
@ -27,6 +27,7 @@ v0.51.2 06-Mar-2004
|
||||
Moved the initial delay in the execute functions to the child
|
||||
process, that may be the trick to work around the lost child
|
||||
messages.
|
||||
Added enoughspace function to check diskspace.
|
||||
|
||||
mbcico:
|
||||
Updated file request function to new files database structure.
|
||||
@ -92,6 +93,12 @@ v0.51.2 06-Mar-2004
|
||||
Added setup items in menu 1.5 for child priority and filesystem
|
||||
sync calls.
|
||||
|
||||
mbmon:
|
||||
Switched to use new filesystems command.
|
||||
|
||||
mbtask:
|
||||
Added communication commands for disk watch thread.
|
||||
|
||||
mbuseradd:
|
||||
Fixed removing of a OS created homedir. This may solve problems
|
||||
on RH and Fedora (under test).
|
||||
|
@ -14,7 +14,7 @@
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<BLOCKQUOTE>
|
||||
<div align="right"><h5>Last update 06-Dec-2003</h5></div>
|
||||
<div align="right"><h5>Last update 20-Mar-2004</h5></div>
|
||||
<div align="center"><H1>mbtask - MBSE BBS Taskmanager</H1></div>
|
||||
|
||||
<H3>Sysopsis.</H3>
|
||||
@ -186,6 +186,7 @@ Cat. Description
|
||||
---- -------------------------------------------
|
||||
Axxx Accounting, system monitor info etc.
|
||||
Cxxx Chatting
|
||||
Dxxx Disk watch
|
||||
Gxxx Global commands.
|
||||
Sxxx Status commands.
|
||||
|
||||
@ -234,7 +235,7 @@ Reply: 100:0; Ok.
|
||||
200:1,Syntax Error; Error.
|
||||
|
||||
|
||||
Group C, Chatting (just some ideas).
|
||||
Group C, Chatting
|
||||
|
||||
Command: CIPM:1,pid; Is Personal Message present.
|
||||
Reply: 100:2,fromname,message; Yes, from .. with message text.
|
||||
@ -244,20 +245,55 @@ Command: CSPM:3,fromuser,touser,txt; Send personal message to user.
|
||||
Reply: 100:1,n; n: 0=Ok, 1=Do not disturb, 2=Buffer full, 3=Error.
|
||||
100:0; Impossible.
|
||||
|
||||
The next commands are some ideas, they are not implemented.
|
||||
Channel 0 will be for sysop chat only, other channels are
|
||||
user channels.
|
||||
Command: CSYS:2,pid,1; Sysop available for chat (from mbmon).
|
||||
CSYS:2,pid,0; Sysop goes away (from mbmon).
|
||||
Reply: 100:0; Always Ok.
|
||||
|
||||
-CBPM:2,fromuser,txt; Broadcast message to all users.
|
||||
-CJCH:2,pid,channel; Join Channel
|
||||
-CCCH:2,pid,channel; Close Channel
|
||||
-CAML:2,channel,text; Add textline to channel
|
||||
-CIML:1,channel; Is new textline present
|
||||
-CSSP:1,user,reason; Send Sysop Page
|
||||
-CESP:1,user; Retract Sysop Page
|
||||
-CRSP:1,user; Reject user Page
|
||||
-CFCH:2,channel,user; Force user in chatmode (for Sysop chat).
|
||||
-CKCH:2,channel,user; Kill user chatmode (for Sysops and moderators).
|
||||
Command: CPAG:2,pid,reason; Page sysop for a chat.
|
||||
Reply: 100:1,n; 1=busy, 2=sysop not available, 3=error.
|
||||
100:0; Ok
|
||||
|
||||
Command: CCAN:1,pid; Cancel sysop page.
|
||||
Reply: 100:0; Always Ok.
|
||||
|
||||
Command: CCKP:0; Check sysop page (from mbmon).
|
||||
Reply: 100:3,pid,1,reason; Page is active.
|
||||
100:3,pid,0,reason; Page is cancelled, user still online.
|
||||
100:0; No page active.
|
||||
|
||||
Command: CISC:1,pid; Check sysop in chatmode.
|
||||
Reply: 100:1,1; Yes and drop into chatmode.
|
||||
100:1,0; No.
|
||||
|
||||
Command: CCON:3,pid,username,n; Connect to chatserver with username. n=1 user is sysop.
|
||||
Reply: 100:1,error; Error with message.
|
||||
100:0; Ok.
|
||||
|
||||
Command: CCLO:1,pid; Close chat session.
|
||||
Reply: 100:1,error; Error.
|
||||
100:0; Ok.
|
||||
|
||||
Command: CPUT:2,pid,message; Put message on chatserver.
|
||||
Reply: 100:2,0,error; Error, not fatal and continue.
|
||||
100:2,1,error; Error, fatal and disconnect chat.
|
||||
100:0; Ok.
|
||||
|
||||
Command: CGET:1,pid; Get message from chatserver.
|
||||
100:2,0,message; If message present.
|
||||
100:2,1,error; Error and disconnect chat.
|
||||
100:0; No new message.
|
||||
|
||||
|
||||
Group D, Disk watch command.
|
||||
|
||||
Command: DRES:0; Reset and reread disk tables.
|
||||
Reply: 100:0; Always Ok.
|
||||
|
||||
Command: DSPC:0; Enough free diskspace.
|
||||
Reply: 100:1;n; 0=No, 1=Yes, 2=Unknown, 3=Error.
|
||||
|
||||
Command: DGFS:0; Get filesystem status (see note below).
|
||||
100:n,data1, ..., data10; Maximum 10 filesystems datalines.
|
||||
|
||||
|
||||
Group G, Global commands.
|
||||
@ -272,7 +308,7 @@ Command: GVER:0; Give server version.
|
||||
Reply: 100:1,Version ....; Version reply.
|
||||
|
||||
Command: GSTA:0; Get complete mbsed status record. (13 fields)
|
||||
Reply: 100:20,start,laststart,daily,startups,clients,tot_clients,tot_peak,syntax_errs,
|
||||
Reply: 100:19,start,laststart,daily,startups,clients,tot_clients,tot_peak,syntax_errs,
|
||||
com_errs,today_clients,today_peak,today_syntax,today_comerr,bbsopen,
|
||||
is_zmh,do_inet,processing,system_load,sequence;
|
||||
|
||||
@ -280,7 +316,7 @@ Command: GMON:1,n; Get registration info line, 1=First, 0=N
|
||||
Reply: 100:7,pid,tty,user,program,city,isdoing,starttime;
|
||||
100:0; No more lines.
|
||||
|
||||
Command: GDST:0; Get filesystem status (see note below).
|
||||
Command: GDST:0; Get filesystem status. Obsolete, use DGFS instead.
|
||||
100:n,data1, ..., data10; Maximum 10 filesystems datalines.
|
||||
|
||||
Command: GSYS:0; Get bbs statistics.
|
||||
@ -326,13 +362,14 @@ Command: SERM:1,semafore; Remove semafore
|
||||
Reply: 100:0; Ok (also if there was no semafore).
|
||||
200:1,16; Semafore not known.
|
||||
</pre>
|
||||
Note: in reply of GDST the reply is 100:n,size free mountpoint fstype,.....
|
||||
Note: in reply of DGFS the reply is 100:n,size free mountpoint fstype,.....
|
||||
where n = 1 for 1 filesystem, and 10 for a total of 10 filesystems. There
|
||||
will never be a reply for more then 10 filesystems. The reported filesystems
|
||||
are retrieved from /etc/mtab which is the actual mountstatus. On FreeBSD and
|
||||
NetBSD a system call is used to get the information about the mounted
|
||||
filesystem.
|
||||
are collected by a thread process of mbtask that only includes the filesystems
|
||||
actually used by mbse.
|
||||
This is used by the <b>mbmon</b> program to get a "live" view of your filesystems.
|
||||
The GSPC command is used by utilities to check if enough space is available to
|
||||
continue to work safely.
|
||||
<P> <P>
|
||||
|
||||
<A HREF="index.htm"><IMG SRC="../images/larrow.png" ALT="Index" Border="0">Back to index</A>
|
||||
@ -340,4 +377,3 @@ This is used by the <b>mbmon</b> program to get a "live" view of your filesystem
|
||||
</BLOCKQUOTE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
|
26
lib/clcomm.c
26
lib/clcomm.c
@ -465,6 +465,32 @@ unsigned long sequencer()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check enough diskspace.
|
||||
* return 0=No, 1=Yes, 2=Unknown, 3=Error
|
||||
*/
|
||||
int enoughspace(void)
|
||||
{
|
||||
char *buf, *res;
|
||||
int rc = 3;
|
||||
|
||||
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||
sprintf(buf, "DSPC:0;");
|
||||
|
||||
if (socket_send(buf) == 0) {
|
||||
free(buf);
|
||||
buf = socket_receive();
|
||||
res = strtok(buf, ",");
|
||||
res = strtok(NULL, ";");
|
||||
rc = atoi(res);
|
||||
}
|
||||
|
||||
Syslog('s', "enoughspace() rc=%d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *printable(char *s, int l)
|
||||
{
|
||||
int len;
|
||||
|
@ -1992,6 +1992,7 @@ void UserCity(pid_t, char *, char *);
|
||||
void DoNop(void);
|
||||
void Nopper(void);
|
||||
void Altime(int);
|
||||
int enoughspace(void);
|
||||
unsigned long sequencer(void);
|
||||
char *printable(char *, int);
|
||||
char *printablec(char);
|
||||
|
@ -335,7 +335,7 @@ void disk_stat(void)
|
||||
do {
|
||||
show_date(LIGHTGRAY, BLACK, 0, 0);
|
||||
|
||||
sprintf(buf, "GDST:1,%d;", getpid());
|
||||
sprintf(buf, "DGFS:0;");
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
set_color(LIGHTGRAY, BLACK);
|
||||
|
@ -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