From: hadaq Date: Mon, 31 Mar 2008 17:45:21 +0000 (+0000) Subject: 1. the unnecessary do loop from NetTrans_multiRecv was taken out. 2. New function... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=f3199b94dac3dabcabd6cac0980142eee6d772d8;p=daqdata.git 1. the unnecessary do loop from NetTrans_multiRecv was taken out. 2. New function NetTrans_multiReceive. 3. assembleMsg does not do anything if hadTu is NULL. 4. MTU is changed to 63 kB. S.Y. --- diff --git a/hadaq/nettrans.c b/hadaq/nettrans.c index 8fb9096..b747831 100644 --- a/hadaq/nettrans.c +++ b/hadaq/nettrans.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/nettrans.c,v 6.39 2007-07-05 15:56:58 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/nettrans.c,v 6.40 2008-03-31 17:45:21 hadaq Exp $"; #define _GNU_SOURCE @@ -14,8 +14,8 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada #include #include #include -#include -#include +/* #include */ +/* #include */ #include @@ -71,7 +71,7 @@ static int openUdp(NetTrans *my, unsigned long addr, int port, int fl) retVal = -1; } - my->mtuSize = 15 * 1024; + my->mtuSize = 63 * 1024; if (0 > retVal) { syslog(LOG_DEBUG, "openUdp: %s", strerror(errno)); @@ -298,7 +298,7 @@ int NetTrans_send(NetTrans *my, void *hadTu) return 0; } -static int assembleMsg(NetTrans *my, void *hadTu, size_t size) +int assembleMsg(NetTrans *my, void *hadTu, size_t size) { int retVal; @@ -306,13 +306,13 @@ static int assembleMsg(NetTrans *my, void *hadTu, size_t size) /* the parent functions this should be handled, but this would need */ /* better sunc. between nettrans & shmtrans */ if (hadTu == NULL) { - my->pkt = malloc(my->mtuSize); - if (0 > recvGeneric(my)) { - abort(); - } +/* my->pkt = malloc(my->mtuSize); */ +/* if (0 > recvGeneric(my)) { */ +/* abort(); */ +/* } */ my->offset = 0; (*my->pktsDiscarded)++; - free(my->pkt); +/* free(my->pkt); */ return 0; } my->pkt = (char *) hadTu + my->offset; @@ -350,6 +350,10 @@ void NetTrans_recv(NetTrans *my, void *hadTu, size_t size) unsigned long NetTrans_multiRecv(NetTrans *my[], void *hadTu[], size_t size[], int nrOfMsgs) { + /* + * This original function has a limitation of maximum 32 subsystems. + * This limitation is due to a bit mask msgIsComplete of an unsigned long type. + */ int i; unsigned long msgIsComplete; fd_set fdSetS, *fdSet = &fdSetS; @@ -358,7 +362,7 @@ unsigned long NetTrans_multiRecv(NetTrans *my[], void *hadTu[], size_t size[], i msgIsComplete = 0; - do { + /* do { */ FD_ZERO(fdSet); for (i = 0; i < nrOfMsgs; i++) { FD_SET(my[i]->fd, fdSet); @@ -373,7 +377,31 @@ unsigned long NetTrans_multiRecv(NetTrans *my[], void *hadTu[], size_t size[], i } } } - } while (0 && msgIsComplete == 0); + /* } while (0 && msgIsComplete == 0); */ return msgIsComplete; } + +fd_set *NetTrans_multiReceive(NetTrans *my[], void *hadTu[], size_t size[], int nrOfMsgs) +{ + /* + * This function does not have a limitation of a number of subsystems + * due to a bit mask msgIsComplete. Instead the function returns fdSet itself + * which should be later checked with FD_ISSET. S.Y. + */ + int i; + fd_set fdSetS, *fdSet = &fdSetS; + + FD_ZERO(fdSet); + + for (i = 0; i < nrOfMsgs; i++) { + FD_SET(my[i]->fd, fdSet); + } + + if (0 > select(getdtablesize(), fdSet, NULL, NULL, NULL)) { + printf("nettranc::NetTrans_multiReceive: abort after select\n"); + abort(); + } + + return fdSet; +}