From ce3a09929eb00fdf975be28f7e6360fdb256b933 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 15 Nov 2001 12:59:54 +0000 Subject: [PATCH] reverted the new stop protocol introduced yesterday. The current scheme for inserting log info into the DB doesn't need it. --- hadaq/agent.c | 3 +-- hadaq/daq_lib.c | 4 +--- hadaq/worker.c | 60 ++++++++----------------------------------------- hadaq/worker.h | 1 - 4 files changed, 11 insertions(+), 57 deletions(-) diff --git a/hadaq/agent.c b/hadaq/agent.c index c0d315b..1511781 100644 --- a/hadaq/agent.c +++ b/hadaq/agent.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.6 2001-11-14 17:18:52 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.7 2001-11-15 12:59:54 hadaq Exp $"; #include #include "agent.h" @@ -76,7 +76,6 @@ int *rpcworker_stop_1(int *id, CLIENT * cl) { static int retVal; - Worker_halt(getWorker(*id), 15); Worker_stop(getWorker(*id), 15); removeWorker(*id); diff --git a/hadaq/daq_lib.c b/hadaq/daq_lib.c index f506d84..e897dda 100644 --- a/hadaq/daq_lib.c +++ b/hadaq/daq_lib.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/daq_lib.c,v 6.8 2001-11-15 10:20:18 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/daq_lib.c,v 6.9 2001-11-15 12:59:54 hadaq Exp $"; #include @@ -48,8 +48,6 @@ int Daq_start(const char *n, const Param *p) int Daq_stop(const char *n, const Param *p) { exportSetup(p); - Worker_halt(n, 15); - puts(Worker_status(n)); Worker_stop(n, 15); return 0; } diff --git a/hadaq/worker.c b/hadaq/worker.c index 85ee33f..f53ff6a 100644 --- a/hadaq/worker.c +++ b/hadaq/worker.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.10 2001-11-14 17:18:52 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.11 2001-11-15 12:59:54 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -162,8 +162,6 @@ Worker *Worker_initBegin(const char *name, void (*sigHandler) (int), int priorit { Worker *retVal; Worker *my; - int s0; - int s1; if (NULL == (my = malloc(sizeof(Worker)))) { syslog(LOG_ERR, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); @@ -174,24 +172,19 @@ Worker *Worker_initBegin(const char *name, void (*sigHandler) (int), int priorit my->pid = getpid(); my->isStandalone = isStandalone; - if (!my->isStandalone) { - s0 = SIGUSR1; - s1 = SIGUSR2; - } else { - s0 = SIGINT; - s1 = SIGTERM; - } - - if (-1 == installSigHandlers(my, s0, s1, sigHandler)) { + if (-1 == installSigHandlers(my, SIGINT, SIGTERM, sigHandler)) { syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); + Worker_fini(my); retVal = NULL; } else if (-1 == createStatShm(my)) { syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); - removeSigHandlers(my); + Worker_fini(my); retVal = NULL; } else { - my->pidP = Worker_addStatistic(my, "pid"); - *my->pidP = my->pid; + unsigned long *pidP; + + pidP = Worker_addStatistic(my, "pid"); + *pidP = my->pid; if (0 > changePriority(priority)) { syslog(LOG_WARNING, "changeing priority: %s", strerror(errno)); @@ -215,21 +208,6 @@ void Worker_initEnd(Worker *my) void Worker_fini(Worker *my) { - - if (!my->isStandalone) { - sigset_t sigMaskS, *sigMask = &sigMaskS; - - removeSigHandlers(my); - installSigHandlers(my, SIGINT, SIGTERM, noopHandler); - - *my->pidP |= (1 << 31); - - /* BUGBUG there should be a timeout here */ - sigemptyset(sigMask); - sigsuspend(sigMask); - } - - removeStatShm(my); removeSigHandlers(my); @@ -311,25 +289,6 @@ char *Worker_status(const char *name) return retVal; } -void Worker_halt(const char *name, int timeout) -{ - Worker myS, *my = &myS; - - strcpy(my->name, name); - - if (0 == openStatShm(my)) { - my->pid = my->statistics[0].value; - if (my->pid > 0) { - if (0 == kill(my->pid, SIGUSR1)) { - while (((my->pid = my->statistics[0].value) & (1 << 31)) == 0) { - sleep(1); - } - } - } - closeStatShm(my); - } -} - void Worker_stop(const char *name, int timeout) { Worker myS, *my = &myS; @@ -337,14 +296,13 @@ void Worker_stop(const char *name, int timeout) strcpy(my->name, name); if (0 == openStatShm(my)) { - my->pid = my->statistics[0].value & ~(1 << 31); + my->pid = my->statistics[0].value; if (my->pid > 0) { if (0 == kill(my->pid, SIGTERM)) { sleep(1); wait(NULL); } } - closeStatShm(my); } } diff --git a/hadaq/worker.h b/hadaq/worker.h index a7e4f4f..6df8835 100644 --- a/hadaq/worker.h +++ b/hadaq/worker.h @@ -24,7 +24,6 @@ typedef struct WorkerS { PsxShm *shm; Statistic *statistics; pid_t pid; - unsigned long *pidP; int isStandalone; } Worker; -- 2.43.0