Added more program locks

This commit is contained in:
Michiel Broek 2003-08-03 14:42:12 +00:00
parent 709a2ad3af
commit 3c0de46dc9
8 changed files with 296 additions and 262 deletions

View File

@ -36,6 +36,22 @@ v0.37.5 12-Jul-2003
Added program locking, only one mbmon can run at the same time
to prevent troubles with chat and sysop available.
mbaff:
Added program locking to prevent that more than one mbaff can
run at the same time.
mball:
Added program locking to prevent that more than one mball can
run at the same time.
mbfile:
Added program locking to prevent that more than one mbfile can
run at the same time.
mbuser:
Added program locking to prevent that more than one mbuser can
run at the same time.
lang:
Added language prompts 18 and 19.

View File

@ -30,15 +30,11 @@
#include "../config.h"
#include "../lib/libs.h"
//#include "../lib/memwatch.h"
#include "../lib/structs.h"
#include "../lib/users.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
//#include "../lib/dbcfg.h"
//#include "../lib/dbftn.h"
//#include "../lib/mberrors.h"
extern int do_quiet; /* Quiet flag */
@ -141,8 +137,6 @@ void ulockprogram(char *progname)
if (oldpid == getpid()) {
(void)unlink(lockfile);
} else {
WriteError("Lockfile owned by pid %d, not removed", oldpid);
}
free(lockfile);

View File

@ -78,6 +78,7 @@ void die(int onsig)
WriteError("Terminated with error %d", onsig);
}
ulockprogram((char *)"mbaff");
t_end = time(NULL);
Syslog(' ', "MBAFF finished in %s", t_elapsed(t_start, t_end));
@ -113,15 +114,13 @@ int main(int argc, char **argv)
* Catch all signals we can, and ignore the rest.
*/
for (i = 0; i < NSIG; i++) {
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) ||
(i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) ||
(i == SIGKILL))
if ((i == SIGHUP) || (i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM))
signal(i, (void (*))die);
else
signal(i, SIG_IGN);
}
if(argc < 2)
if (argc < 2)
Help();
cmd = xstrcpy((char *)"Command line: mbaff");
@ -155,6 +154,12 @@ int main(int argc, char **argv)
if (!diskfree(CFG.freespace))
die(MBERR_DISK_FULL);
if (lockprogram((char *)"mbaff")) {
if (!do_quiet)
printf("Can't lock mbaff, abort.\n");
die(MBERR_NO_PROGLOCK);
}
memset(&MsgBase, 0, sizeof(MsgBase));
if (do_announce)

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -218,6 +218,12 @@ int main(int argc, char **argv)
if (!diskfree(CFG.freespace))
die(MBERR_DISK_FULL);
if (lockprogram((char *)"mbfile")) {
if (!do_quiet)
printf("Can't lock mbfile, abort.\n");
die(MBERR_NO_PROGLOCK);
}
if (do_adopt) {
AdoptFile(Area, FileName, Description);
die(MBERR_OK);

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance - utilities
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -95,6 +95,7 @@ void die(int onsig)
WriteError("Terminated with error %d", onsig);
}
ulockprogram((char *)"mbfile");
t_end = time(NULL);
Syslog(' ', "MBFILE finished in %s", t_elapsed(t_start, t_end));

View File

@ -95,6 +95,7 @@ void die(int onsig)
WriteError("Terminated with error %d", onsig);
}
ulockprogram((char *)"mball");
t_end = time(NULL);
Syslog(' ', "MBALL finished in %s", t_elapsed(t_start, t_end));
@ -190,6 +191,12 @@ int main(int argc, char **argv)
printf("\n");
}
if (lockprogram((char *)"mball")) {
if (!do_quiet)
printf("Can't lock mball, abort.\n");
die(MBERR_NO_PROGLOCK);
}
if (do_list) {
Masterlist();
if (do_zip)

View File

@ -4,7 +4,7 @@
* Purpose ...............: User Pack Util
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -111,12 +111,19 @@ int main(int argc, char **argv)
if (!diskfree(CFG.freespace))
ExitClient(MBERR_DISK_FULL);
if (lockprogram((char *)"mbuser")) {
if (!do_quiet)
printf("Can't lock mbuser, abort.\n");
ExitClient(MBERR_NO_PROGLOCK);
}
oldmask = umask(027);
if (!do_quiet)
colour(3, 0);
UserPack(Days, Level, pack);
umask(oldmask);
ulockprogram((char *)"mbuser");
t_end = time(NULL);
Syslog(' ', "MBUSER finished in %s", t_elapsed(t_start, t_end));

View File

@ -788,8 +788,6 @@ void ulocktask(void)
if (oldpid == getpid()) {
(void)unlink(lockfile);
} else {
WriteError("Lockfile owned by pid %d, not removed", oldpid);
}
free(lockfile);