Changeset 11895
- Timestamp:
- 08/12/11 09:47:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.c
r11766 r11895 1 1 2 2 // // // #define EVTDEBUG 3 4 #define NUMSOCK 1 //set to 7 for old configuration 5 #define MAXREAD 65536 //64kB wiznet buffer 3 6 4 7 #include <stdlib.h> … … 18 21 #include <netinet/tcp.h> 19 22 #include <pthread.h> 20 #include <sched.h> 23 #include <sched.h> 21 24 22 25 #include "EventBuilder.h" … … 147 150 int32_t bufPos; //next byte to read to the buffer next 148 151 int32_t bufLen; //number of bytes left to read 152 // size_t bufLen; //number of bytes left to read size_t might be better 149 153 int32_t skip; //number of bytes skipped before start of event 150 154 … … 441 445 for (k = 0; k < MAX_RUN; k++) { 442 446 if (runCtrl[k].runId == runID) { 443 if (runCtrl[k].procId > 0) { //run is closed -> reject444 snprintf (str, MXSTR, "skip event since run %d finished", runID);445 factOut (kInfo, 931, str);446 return -21;447 }447 // if (runCtrl[k].procId > 0) { //run is closed -> reject 448 // snprintf (str, MXSTR, "skip event since run %d finished", runID); 449 // factOut (kInfo, 931, str); 450 // return -21; 451 // } 448 452 449 453 if (runCtrl[k].roi0 != nRoi[0] … … 490 494 runCtrl[evFree].firstTime = runCtrl[evFree].lastTime = tsec; 491 495 runCtrl[evFree].closeTime = tsec + 3600 * 24; //max time allowed 492 496 // runCtrl[evFree].lastTime = 0; 493 497 494 498 runTail[evFree].nEventsOk = … … 768 772 numok = numok2 = 0; 769 773 774 int cntsock = 8 - NUMSOCK ; 775 770 776 if (gi_resetS > 0) { 771 777 //make sure all sockets are preallocated as 'not exist' … … 796 802 gj.evtSkip = gj.evtWrite = gj.evtErr = 0; 797 803 798 int b ;804 int b,p; 799 805 for (b = 0; b < NBOARDS; b++) 800 806 gj.badRoi[b] = 0; … … 861 867 862 868 for (i = 0; i < MAX_SOCK; i++) { //check all sockets if something to read 863 b = i / 7; 869 b = i / 7 ; 870 p = i % 7 ; 871 872 //if ( b==32 && p>0) { ; } 873 if ( p >= NUMSOCK) { ; } 874 else { 864 875 if (sockDef[b] > 0) 865 876 s0 = +1; … … 881 892 rd[i].bufPos = 0; // no byte read so far 882 893 rd[i].skip = 0; // start empty 883 gi_NumConnect[b]++; 894 // gi_NumConnect[b]++; 895 gi_NumConnect[b] += cntsock ; 896 884 897 gi.numConn[b]++; 885 898 gj.numConn[b]++; … … 892 905 if (rd[i].bufLen > 0) { //might be nothing to read [buffer full] 893 906 numok++; 907 size_t maxread = rd[i].bufLen ; 908 if (maxread > MAXREAD ) maxread=MAXREAD ; 909 894 910 jrd = 895 911 recv (rd[i].socket, &rd[i].rBuf->B[rd[i].bufPos], 896 rd[i].bufLen, MSG_DONTWAIT); 912 maxread, MSG_DONTWAIT); 913 // rd[i].bufLen, MSG_DONTWAIT); 897 914 898 915 if (jrd > 0) { … … 914 931 GenSock (s0, i, 0, NULL, &rd[i]); 915 932 gi.gotErr[b]++; 916 gi_NumConnect[b]--; 933 // gi_NumConnect[b]--; 934 gi_NumConnect[b]-= cntsock ; 917 935 gi.numConn[b]--; 918 936 gj.numConn[b]--; … … 1220 1238 1221 1239 } //end interpreting last read 1240 } 1222 1241 } //end of successful read anything 1223 1242 } //finished trying to read all sockets … … 1352 1371 GenSock (-1, i, 0, NULL, &rd[i]); //close and destroy open socket 1353 1372 if (i % 7 == 0) { 1354 gi_NumConnect[i / 7]--; 1373 // gi_NumConnect[i / 7]--; 1374 gi_NumConnect[i / 7]-= cntsock ; 1355 1375 gi.numConn[i / 7]--; 1356 1376 gj.numConn[i / 7]--; … … 1644 1664 runCtrl[j].fileId = 91; 1645 1665 runCtrl[j].procId = 91; 1646 } else { 1666 } else { 1647 1667 snprintf (str, MXSTR, "P opened new run_file %d evt %d", 1648 1668 irun, ievt); … … 1670 1690 "P skip event %d because no active run %d", ievt, 1671 1691 irun); 1672 factOut (k Info, 502, str);1692 factOut (kDebug, 502, str); 1673 1693 evtCtrl.evtStat[k0] = 9091; 1674 1694 } else { 1675 1695 //-------- 1676 1696 //-------- 1677 intid = evtCtrl.evtBuf[k0];1697 id = evtCtrl.evtBuf[k0]; 1678 1698 int itevt = mBuffer[id].trgNum; 1679 1699 int itrg = mBuffer[id].trgTyp; … … 2080 2100 2081 2101 if (runCtrl[j].procId == 0) { 2082 runFinish (runCtrl[j].runId);2102 runFinish1 (runCtrl[j].runId); 2083 2103 runCtrl[j].procId = 92; 2084 2104 }
Note:
See TracChangeset
for help on using the changeset viewer.