Changeset 17679


Ignore:
Timestamp:
04/22/14 14:55:54 (11 years ago)
Author:
tbretz
Message:
Fixed a bug which could cause infinite loops when an event with invalid FADhead was checked for timout (the it++ was missing), added a lot of comments
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilder.cc

    r17678 r17679  
    357357        factPrintf(MessageImp::kInfo, "Closed socket %d (%d)", sockId, socket);
    358358
     359    // Set the socket to "not connected"
    359360    socket = -1;
    360361    connected = false;
    361362    activeSockets--;
     363    bufLen = 0;
    362364}
    363365
     
    645647    evt->nRoi   = nRoi[0];
    646648    evt->nRoiTM = nRoi[8];
     649
     650    //evt->firstBoard = rd.sockId;
    647651
    648652    const bool newrun = actrun->runId != rd.H.runnumber;
     
    13081312            {
    13091313                factPrintf(MessageImp::kError, "Got event %5d from board %3d (i=%3d, len=%5d) twice.",
    1310                            evt->evNum, rs->sockId, rs->sockId, rs->len());
     1314                           evt->evNum, rs->sockId, jj, rs->len());
    13111315                // FIXME: What to do with the validity flag?
    13121316                continue; // Continue reading next header
     
    13541358                    rd[ib].relBytes += uint32_t((*it)->FADhead[ib].package_length)*2;
    13551359
     1360                // The counter must be increased _before_ the pop_front,
     1361                // otherwise the counter is invalidated by the pop_front!
    13561362                it++;
    13571363                evtCtrl.pop_front();
     
    14161422            const shared_ptr<EVT_CTRL2> &evt = *it;
    14171423
    1418             // If there was no memory, it is possible that no header has been processed yet
    1419             // but the event already exists. What we want to check here are only
    1420             // if from partially complete events a baord is missing, not
    1421             // whether the whole event is missing
    1422             if (!evt->valid())
    1423                 continue;
    1424 
    14251424            // The first event is the oldest. If the first event within the
    14261425            // timeout window was received, we can stop searching further.
    14271426            if (evt->time.tv_sec+g_evtTimeout>=actTime)
    14281427                break;
     1428
     1429            // The counter must be increased _before_ the pop_front,
     1430            // otherwise the counter is invalidated by the pop_front!
     1431            it++;
     1432
     1433            // This timeout is caused because complete data from one or more
     1434            // boards has been received, but the memory could not be allocated.
     1435            // There is no reason why we should not go on waiting for
     1436            // memory to become free. However, the FADs will disconnect
     1437            // after 60s due to their keep-alive timeout, but the event builder
     1438            // will still wait for memory to become available.
     1439            // Currently, the only possibility to free the memory from the
     1440            // evtCtrl to restart the event builder (STOP/START).
     1441            if (!evt->valid())
     1442                continue;
    14291443
    14301444            // This will result in the emission of a dim service.
     
    14341448            factReportIncomplete(rep);
    14351449
     1450            // At least the data from one boards is complete...
    14361451            // package_len is 0 when nothing was received from this board
    14371452            for (int ib=0; ib<40; ib++)
    1438                 rd[ib].relBytes += uint32_t((*it)->FADhead[ib].package_length)*2;
    1439 
    1440             it++;
     1453                rd[ib].relBytes += uint32_t(evt->FADhead[ib].package_length)*2;
     1454
    14411455            evtCtrl.pop_front();
    14421456        }
  • trunk/FACT++/src/EventBuilder.h

    r17658 r17679  
    120120    uint32_t  fadLen;
    121121
     122    //uint16_t  firstBoard; // first board from which data was received
    122123    uint16_t  nBoard;
    123124    int16_t   board[NBOARDS];
Note: See TracChangeset for help on using the changeset viewer.