-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.151 2011-08-10 11:55:41 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.152 2011-08-12 20:49:45 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
#define DAQVERSION 2 /* needed by Hydra unpackers */
#define RUNID_INFO_DT 600 /* time in s until not available runid info is logged */
+#define LOST_SUBEVT_LIMIT 10000 /* number of popped subevents per trigger sequence until warning */
+#define LOST_SUBEVT_TERM 10 /* terminate after this number of lost sub warnings per trigger sequence */
#define NEVTIDS 64UL /* must be 2^n */
#define NEVTIDS_IN_FILE 0UL /* must be 2^n */
if (theArgs->maxTrigMismatch == -1) {
theArgs->maxTrigMismatch = 30; /* JAM: set reasonable default if not specified */
- sprintf(msglog, "<I> Critical trigger mismatch ratio takes default of %d % ", theArgs->maxTrigMismatch);
+ sprintf(msglog, "<I> Critical trigger mismatch ratio takes default of %d %% ", theArgs->maxTrigMismatch);
storeLogInfo(theArgs, msglog);
/*return retVal; */
}
int brokenEvtCnt = 0;
unsigned long popCnt = 0;
+ unsigned long popTermCnt = 0;
currId = 0;
- int popMaster = 0;
while (setjmp(terminateJmp) == 0) {
void *evt;
evt = newEvt(EvtDecoding_64bitAligned, EvtId_data);
popCnt = 0; /* Counter of popped up subevents */
- popMaster = 1; /* flag to pop subevent from master stream i=0 */
+ popTermCnt = 0; /* defines termination condition for popCnt */
for (i = 0; i < theArgs->nrOfMsgs && !evtIsBroken; i += step) {
uint32_t trigNr;
uint32_t trigTag;
evt = Evt_appendSubEvt(evt, subEvt);
}
- HadTuQueue_pop(hadTuQueue[i]); /* delay pop of master stream until broken checked */
+ HadTuQueue_pop(hadTuQueue[i]);
step = 1;
} else if (trigNr < currTrigNr) {
if (theArgs->debugOptsCnt) {
HadTuQueue_pop(hadTuQueue[i]);
step = 0;
popCnt++;
- if (popCnt > 10000) {
+ if (popCnt >= LOST_SUBEVT_LIMIT) {
if (theArgs->debugOptsCnt)
Debug_printPopTrigMismatch(theArgs, theStats, theDebug, i);
- /* JAM: do not bail out, but display problem message.
- * Termination should be done by real discarded events amount
- * Or by human operator...*/
- sprintf(msglog, "<W> Subevent stream %d has popped nr:%d queue entries to sync with master stream!", i,
- popCnt);
- storeLogInfo(theArgs, msglog);
- /* goto bailOut1; */
+ /* JAM: do not bail out immediately, but display problem message first.
+ * Scale down warning message frequency:*/
+ if ((popCnt % LOST_SUBEVT_LIMIT) == 0) {
+ sprintf(msglog, "<W> Subevent stream %d has popped nr:%d queue entries to sync with master stream!", i,
+ popCnt);
+ storeLogInfo(theArgs, msglog);
+ popTermCnt++;
+ }
+ if (popTermCnt > LOST_SUBEVT_TERM) {
+ storeLogInfo(theArgs, "<E> too many lost subevents. Exiting now!");
+ goto bailOut1;
+ }
}
} else {
if (theArgs->debugOptsCnt) {