static char *rcsId =
- "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.76 2007-01-30 19:24:11 hadaq Exp $";
+ "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.77 2007-04-14 21:49:37 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
static jmp_buf terminateJmp;
+
+
void
sigHandler (int sig)
{
int
is_mismatch_enough_to_stop(TheArgs * theArgs, TheStats * my) {
- unsigned long filesize_enough = (theArgs->maxFileSz) * 0.02;
+ /*unsigned long filesize_enough = (theArgs->maxFileSz) * 0.02;*/
+ unsigned long filesize_enough = (theArgs->maxFileSz) * 0.1;
unsigned long discarded_enough = (*my->evtsComplete) * 0.03;
unsigned long tagerror_enough = (*my->evtsComplete) * 0.03;
if ((*my->bytesWritten) >= filesize_enough)
{
if ((*my->evtsDiscarded) > discarded_enough)
{
- printf("Too many events is broken.\n");
+ printf("Too many events are broken.\n");
printf("Debug Inf: filesize_enough: %u,fileWrittem: %u, DISCARDED_enough: %u, discarded: %u, all_events: %u\n",filesize_enough , (*my->bytesWritten),discarded_enough, (*my->evtsDiscarded), (*my->evtsComplete));
- syslog (LOG_ERR, "Too many events is broken.\n");
+ syslog (LOG_ERR, "Too many events are broken.\n");
syslog (LOG_ERR, "Debug Inf: filesize_enough: %u,fileWrittem: %u, DISCARDED_enough: %u, discarded: %u, all_events: %u\n",filesize_enough , (*my->bytesWritten),discarded_enough, (*my->evtsDiscarded), (*my->evtsComplete));
#if BEAM
system ("echo tagerror | netcat -w1 hadesdaq 12122");
}
if ((*my->evtsTagError) > tagerror_enough)
{
- printf("Too many TagError.\n");
+ printf("Too many TagErrors.\n");
printf("Debug Inf: filesize_enough: %u,fileWrittem: %u, TAGERROR_enough: %u, tag_error: %u, all_events: %u\n",filesize_enough , (*my->bytesWritten),tagerror_enough, (*my->evtsTagError), (*my->evtsComplete));
- syslog(LOG_ERR, "Too many TagError.\n");
+ syslog(LOG_ERR, "Too many TagErrors.\n");
syslog(LOG_ERR, "Debug Inf: filesize_enough: %u,fileWrittem: %u, TAGERROR_enough: %u, tag_error: %u, all_events: %u\n",filesize_enough , (*my->bytesWritten),tagerror_enough, (*my->evtsTagError), (*my->evtsComplete));
#if BEAM
system ("echo tagerror | netcat -w1 hadesdaq 12122");
uint32_t currTrigTag;
uint32_t currId;
+ signal(SIGINT, sigHandler);
+ signal(SIGTERM, sigHandler);
+ signal(SIGHUP, sigHandler);
+
+
openlog (argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0);
setlogmask (LOG_UPTO (LOG_INFO));
theStats->evtsDataError = Worker_addStatistic (worker, "evtsDataError");
theStats->evtsTagError = Worker_addStatistic (worker, "evtsTagError");
theStats->bytesWritten = Worker_addStatistic (worker, "bytesWritten");
+
unsigned long *retVal = NULL;
- theStats->evtsRes = &retVal;
+
+ theStats->evtsRes = (unsigned long *) &retVal;
for (i = 0; i < NEVTIDS; i++)
{
char buf[WORKER_MAX_NAME_LEN];
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/hldread.c,v 6.8 2003-05-14 13:54:43 muench Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/hldread.c,v 6.9 2007-04-14 21:49:37 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
syslog(LOG_INFO, "%5u events processed %-30s", processedEvts, "");
}
+
+
+
+
void sigHandler(int sig)
{
exit(128 + sig);
}
+
void alarmHandler(int x)
{
signal(SIGALRM, alarmHandler);
signal(SIGINT, sigHandler);
signal(SIGTERM, sigHandler);
+ signal(SIGHUP, sigHandler);
signal(SIGALRM, alarmHandler);
alarm(timeout);
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.28 2006-05-02 17:17:36 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.29 2007-04-14 21:49:37 hadaq Exp $";
#define WORKER_NEW_PROTOCOL
static int removeSigHandlers(Worker *my)
{
- return sigaction(my->signal0, my->oldSigAction0, NULL)
- | sigaction(my->signal1, my->oldSigAction1, NULL);
+ return sigaction(my->signal0, my->oldSigAction0, NULL)
+ | sigaction(my->signal1, my->oldSigAction1, NULL)
+ | sigaction(my->signal2, my->oldSigAction2, NULL);
}
-static int installSigHandlers(Worker *my, int s0, int s1, void (*sigHandler) (int))
+static int installSigHandlers(Worker *my, int s0, int s1, int s2, void (*sigHandler) (int))
{
int retVal;
struct sigaction actS, *act = &actS;
syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
my->oldSigAction1 = NULL;
}
- if (my->oldSigAction0 == NULL || my->oldSigAction1 == NULL) {
+
+ my->signal2 = s2;
+ my->oldSigAction2 = &my->oldSigAction2S;
+ if (0 > sigaction(my->signal2, act, my->oldSigAction2)) {
+ syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
+ my->oldSigAction2 = NULL;
+ }
+
+ if (my->oldSigAction0 == NULL || my->oldSigAction1 == NULL || my->oldSigAction2 == NULL) {
removeSigHandlers(my);
retVal = -1;
} else {
my->pid = getpid();
my->isStandalone = isStandalone;
- if (-1 == installSigHandlers(my, SIGINT, SIGTERM, sigHandler)) {
+ if (-1 == installSigHandlers(my, SIGINT, SIGTERM, SIGHUP, sigHandler)) {
syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
Worker_fini(my);
retVal = NULL;
strcpy(my->name, argv[0]);
#ifndef WORKER_NEW_PROTOCOL
- installSigHandlers(my, SIGCHLD, SIGUSR1, noopHandler);
+ installSigHandlers(my, SIGCHLD, SIGUSR1, SIGHUP , noopHandler);
#endif
my->pid = fork();
char name[_POSIX_PATH_MAX];
int signal0;
int signal1;
+ int signal2;
struct sigaction oldSigAction0S;
struct sigaction *oldSigAction0;
struct sigaction oldSigAction1S;
struct sigaction *oldSigAction1;
+ struct sigaction oldSigAction2S;
+ struct sigaction *oldSigAction2;
PsxShm *shm;
Statistic *statistics;
pid_t pid;