many, many changes

This commit is contained in:
Jeff Hill
2000-04-28 02:23:35 +00:00
parent 0e823a62c7
commit eee86b8106
47 changed files with 673 additions and 623 deletions

View File

@@ -8,8 +8,6 @@ USER_VPATH := $(SRC) $(STSRC) $(IOSRC)
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
# sometimes it's good to have different C/C++ flags, not now:
USR_CFLAGS = -I$(SRC) -I$(IOSRC) -I$(STSRC) -I$(CA) -DcaNetAddrSock
USR_CXXFLAGS = $(USR_CFLAGS)
@@ -56,6 +54,8 @@ LIBSRCS += casDGIO.cc
LIBSRCS += casStreamIO.cc
LIBRARY = cas
DLL_LIBS = ca gdd Com
SYS_DLL_LIBS = ws2_32
PROD_LIBS := cas ca gdd Com
SYS_PROD_LIBS_WIN32 := ws2_32

View File

@@ -8,8 +8,6 @@ USER_VPATH := $(SRC) $(STSRC) $(IOSRC)
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
# sometimes it's good to have different C/C++ flags, not now:
USR_CFLAGS = -I$(SRC) -I$(IOSRC) -I$(STSRC) -I$(CA) -DcaNetAddrSock
USR_CXXFLAGS = $(USR_CFLAGS)

View File

@@ -8,8 +8,6 @@ USER_VPATH := $(SRC) $(STSRC) $(IOSRC)
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
# sometimes it's good to have different C/C++ flags, not now:
USR_CFLAGS = -I$(SRC) -I$(IOSRC) -I$(STSRC) -I$(CA) -DcaNetAddrSock
USR_CXXFLAGS = $(USR_CFLAGS)

View File

@@ -3,8 +3,6 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
PROD_LIBS := cas ca gdd Com
cas_DIR = $(INSTALL_LIB)
ca_DIR = $(INSTALL_LIB)

View File

@@ -4,8 +4,6 @@ TOP = $(CAS)/../..
include $(TOP)/config/CONFIG_BASE
CXXCMPLR = STRICT
USR_INCLUDES =
USR_LDFLAGS =

View File

@@ -3,7 +3,6 @@
#include "directoryServer.h"
#include "fdManager.h"
#include "bsdSocketResource.h"
#define LOCAL static

View File

@@ -1,5 +1,8 @@
# $Log$
# Revision 1.4 1999/11/18 14:39:46 mrk
# new way to build
#
# Revision 1.3 1999/09/13 14:09:37 mrk
# for 3.14 only a single Makefile
#
@@ -11,8 +14,6 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
PROD_LIBS := cas ca gdd Com
SRCS += mon.cc monAdl.cc monNode.cc monServer.cc

View File

@@ -7,6 +7,9 @@
*
* $Id$
* $Log$
* Revision 1.3 1998/12/19 00:04:46 jhill
* renamed createPV() to pvAttach()
*
* Revision 1.2 1997/05/13 14:23:02 jbk
* added comments at top
*
@@ -31,11 +34,11 @@ class monServer;
class monFd : public fdReg
{
public:
monFd(const int fdIn,const fdRegType typ,monServer& s):
fdReg(fdIn,typ),server(s) { }
virtual ~monFd(void);
monFd (const int fdIn,const fdRegType typ,monServer& s) :
fdReg (fdIn,typ),server(s) { }
virtual ~monFd (void);
private:
virtual void callBack(void);
virtual void callBack (void);
monServer& server;
};

View File

@@ -3,8 +3,6 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
PROD_LIBS := cas ca gdd Com
cas_DIR = $(INSTALL_LIB)
ca_DIR = $(INSTALL_LIB)

View File

@@ -4,8 +4,6 @@ TOP = $(CAS)/../..
include $(TOP)/config/CONFIG_BASE
CXXCMPLR = STRICT
USR_INCLUDES =
USR_LDFLAGS =

View File

@@ -86,11 +86,6 @@ caStatus exPV::update(gdd &valueIn)
return cas;
}
aitTimeStamp ts = this->currentTime;
this->pValue->setTimeStamp (&ts);
this->pValue->setStat (epicsAlarmNone);
this->pValue->setSevr (epicsSevNone);
//
// post a value change event
//

View File

@@ -52,7 +52,7 @@ aitIndex exVectorPV::maxBound (unsigned dimension) const
void exVectorPV::scan()
{
caStatus status;
double radians;
double radians;
smartGDDPointer pDD;
aitFloat32 *pF, *pFE, *pCF;
float newValue;
@@ -256,6 +256,12 @@ caStatus exVectorPV::updateValue(gdd &valueIn)
if (gdds) {
return S_cas_noConvert;
}
aitTimeStamp ts;
valueIn.getTimeStamp (&ts);
pNewValue->setTimeStamp (&ts);
pNewValue->setStat (valueIn.getStat());
pNewValue->setSevr (valueIn.getSevr());
}
this->pValue = pNewValue;

View File

@@ -1,5 +1,8 @@
# $Log$
# Revision 1.4 1999/11/18 14:39:48 mrk
# new way to build
#
# Revision 1.3 1999/09/13 14:09:40 mrk
# for 3.14 only a single Makefile
#
@@ -11,8 +14,6 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
CXXCMPLR = STRICT
PROD_LIBS := cas ca gdd Com
SRCS += pvServ.cc

View File

@@ -27,14 +27,6 @@
* Argonne National Laboratory
*
*
* History
* $Log$
* Revision 1.2 1996/08/05 19:24:23 jhill
* removed ERROR and OK
*
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
* ca server installation
*
*
*/

View File

@@ -16,7 +16,6 @@
#ifdef caNetAddrSock
#include "osiSock.h"
#include "bsdSocketResource.h"
#endif
#include "epicsAssert.h"

View File

@@ -31,6 +31,7 @@
#include "dbMapper.h" // ait to dbr types
#include "gddAppTable.h" // EPICS application type table
#define CAS_DIAGNOSTICS_API_WHICH_MAY_VANISH_IN_THE_FUTURE
#include "server.h"
#include "caServerIIL.h" // caServerI in line func

View File

@@ -31,6 +31,8 @@
#define CAS_VERSION_GLOBAL
#include "addrList.h"
#define caServerGlobal
#include "server.h"
#include "casCtxIL.h" // casCtx in line func
@@ -76,9 +78,9 @@ caServerI::caServerI (caServer &tool, unsigned nPV) :
status = envGetDoubleConfigParam (&EPICS_CA_BEACON_PERIOD, &maxPeriod);
if (status || maxPeriod<=0.0) {
this->maxBeaconInterval = CAServerMaxBeaconPeriod;
ca_printf (
errlogPrintf (
"EPICS \"%s\" float fetch failed\n", EPICS_CA_BEACON_PERIOD.name);
ca_printf (
errlogPrintf (
"Setting \"%s\" = %f\n", EPICS_CA_BEACON_PERIOD.name,
this->maxBeaconInterval);
}
@@ -321,9 +323,7 @@ void caServerI::show (unsigned level) const
this->chronIntIdResTable<casRes>::show(level);
this->unlock();
}
// @@@@@@ caPrintAddrList(&destAddr);
return;
}

View File

@@ -3,7 +3,6 @@
#define includeCASAddrH
#include "osiSock.h"
#include "addrList.h"
#endif // includeCASAddrH

View File

@@ -64,8 +64,8 @@ casAsyncReadIO::~casAsyncReadIO()
//
// casAsyncReadIO::postIOCompletion()
//
caStatus casAsyncReadIO::postIOCompletion(caStatus completionStatusIn,
gdd &valueRead)
caStatus casAsyncReadIO::postIOCompletion (caStatus completionStatusIn,
const gdd &valueRead)
{
this->lock();
this->pDD = &valueRead;
@@ -93,18 +93,18 @@ epicsShareFunc caStatus casAsyncReadIO::cbFuncAsyncIO()
switch (this->msg.m_cmmd) {
case CA_PROTO_READ:
status = client.readResponse(&this->chan, this->msg,
status = client.readResponse (&this->chan, this->msg,
*this->pDD, this->completionStatus);
break;
case CA_PROTO_READ_NOTIFY:
status = client.readNotifyResponse(&this->chan,
status = client.readNotifyResponse (&this->chan,
this->msg, this->pDD,
this->completionStatus);
break;
case CA_PROTO_EVENT_ADD:
status = client.monitorResponse(this->chan,
status = client.monitorResponse (this->chan,
this->msg, this->pDD,
this->completionStatus);
break;

View File

@@ -56,14 +56,16 @@ inline void casChannelI::unlock() const
//
// casChannelI::postEvent()
//
inline void casChannelI::postEvent(const casEventMask &select, gdd &event)
inline void casChannelI::postEvent (const casEventMask &select, const smartConstGDDPointer &pEvent)
{
this->lock();
tsDLIterBD<casMonitor> iter(this->monitorList.first());
while ( iter!=tsDLIterBD<casMonitor>::eol() ) {
iter->post(select, event);
++iter;
}
tsDLIterBD<casMonitor> iter(this->monitorList.first());
while ( iter != tsDLIterBD<casMonitor>::eol() ) {
iter->post (select, pEvent);
++iter;
}
this->unlock();
}

View File

@@ -235,7 +235,7 @@ caStatus casClient::processMsg ()
this->ctx.setData((void *)(rawMP+sizeof(*mp)));
if (this->getCAS().getDebugLevel()> 2u) {
this->dumpMsg (mp, (void *)(mp+1));
this->dumpMsg (mp, (void *)(mp+1), NULL);
}
//
@@ -264,8 +264,7 @@ caStatus casClient::processMsg ()
}
}
catch (...) {
this->dumpMsg (mp, this->ctx.getData() );
epicsPrintf ("Attempt to execute client request failed (C++ exception)\n");
this->dumpMsg (mp, this->ctx.getData(), "request resulted in C++ exception\n");
status = this->sendErr (mp, ECA_INTERNAL, "request resulted in C++ exception");
if (status) {
break;
@@ -507,12 +506,16 @@ const unsigned id
int status;
if (pFileName) {
ca_printf("Bad client request detected in \"%s\" at line %d\n",
this->dumpMsg (mp, dp,
"bad resource id in \"%s\" at line %d\n",
pFileName, lineno);
}
this->dumpMsg(mp, dp);
else {
this->dumpMsg (mp, dp,
"bad resource id\n");
}
status = this->sendErr(
status = this->sendErr (
mp,
cacStatus,
"Bad Resource ID=%u detected at %s.%d",
@@ -531,41 +534,49 @@ const unsigned id
// dp arg allowed to be null
//
//
void casClient::dumpMsg(const caHdr *mp, const void *dp)
void casClient::dumpMsg(const caHdr *mp, const void *dp, const char *pFormat, ...)
{
casChannelI *pciu;
char pName[64u];
char pPVName[64u];
casChannelI *pciu;
char pName[64u];
char pPVName[64u];
va_list theArgs;
if (pFormat) {
va_start (theArgs, pFormat);
errlogPrintf ("CAS: ");
errlogVprintf (pFormat, theArgs);
va_end (theArgs);
}
this->clientHostName (pName, sizeof (pName));
this->clientHostName (pName, sizeof (pName));
pciu = this->resIdToChannel(mp->m_cid);
pciu = this->resIdToChannel(mp->m_cid);
if (pciu) {
strncpy(pPVName, pciu->getPVI().getName(), sizeof(pPVName));
if (&pciu->getClient()!=this) {
strncat(pPVName, "!Bad Client!", sizeof(pPVName));
}
pPVName[sizeof(pPVName)-1]='\0';
}
else {
sprintf(pPVName,"%u", mp->m_cid);
}
ca_printf(
"CAS %s on %s at %s: cmd=%d cid=%s typ=%d cnt=%d psz=%d avail=%x\n",
this->userName(),
this->hostName(),
pName,
mp->m_cmmd,
pPVName,
mp->m_dataType,
mp->m_count,
mp->m_postsize,
mp->m_available);
if (pciu) {
strncpy(pPVName, pciu->getPVI().getName(), sizeof(pPVName));
if (&pciu->getClient()!=this) {
strncat(pPVName, "!Bad Client!", sizeof(pPVName));
}
pPVName[sizeof(pPVName)-1]='\0';
}
else {
sprintf(pPVName,"%u", mp->m_cid);
}
errlogPrintf(
"CAS: %s on %s at %s: cmd=%d cid=%s typ=%d cnt=%d psz=%d avail=%x\n",
this->userName(),
this->hostName(),
pName,
mp->m_cmmd,
pPVName,
mp->m_dataType,
mp->m_count,
mp->m_postsize,
mp->m_available);
if (mp->m_cmmd==CA_PROTO_WRITE && mp->m_dataType==DBR_STRING && dp) {
ca_printf("CAS: The string written: %s \n", (char *)dp);
}
if (mp->m_cmmd==CA_PROTO_WRITE && mp->m_dataType==DBR_STRING && dp) {
errlogPrintf("CAS: The string written: %s \n", (char *)dp);
}
}
//

View File

@@ -29,6 +29,11 @@
*
* History
* $Log$
* Revision 1.5 1999/09/15 00:00:40 jhill
* changed the field name "m_type" to "m_dataType" to avoid
* collision with a MACRO that is defined by the SENS IP stack
* which is mandatory in WRS's Tornado II product.
*
* Revision 1.4 1998/07/08 15:38:04 jhill
* fixed lost monitors during flow control problem
*
@@ -72,7 +77,7 @@ casClientMon::~casClientMon()
//
// casClientMon::callBack()
//
caStatus casClientMon::callBack(gdd &value)
caStatus casClientMon::callBack (const smartConstGDDPointer &value)
{
casCoreClient &client = this->getChannel().getClient();
caStatus status;
@@ -89,7 +94,7 @@ caStatus casClientMon::callBack(gdd &value)
msg.m_available = this->getClientId();
status = client.monitorResponse (this->getChannel(),
msg, &value, S_cas_success);
msg, value, S_cas_success);
return status;
}

View File

@@ -53,7 +53,7 @@ casCoreClient::casCoreClient (caServerI &serverInternal)
casCoreClient::~casCoreClient()
{
if (this->ctx.getServer()->getDebugLevel()>0u) {
ca_printf ("CAS: Connection Terminated\n");
errlogPrintf ("CAS: Connection Terminated\n");
}
this->lock();
@@ -110,36 +110,36 @@ caStatus casCoreClient::asyncSearchResponse (
{
return S_casApp_noSupport;
}
caStatus casCoreClient::createChanResponse(const caHdr &, const pvAttachReturn &)
caStatus casCoreClient::createChanResponse (const caHdr &, const pvAttachReturn &)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::readResponse(casChannelI *, const caHdr &,
const gdd &, const caStatus)
caStatus casCoreClient::readResponse (casChannelI *, const caHdr &,
const smartConstGDDPointer &, const caStatus)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::readNotifyResponse(casChannelI *, const caHdr &,
const gdd *, const caStatus)
caStatus casCoreClient::readNotifyResponse (casChannelI *, const caHdr &,
const smartConstGDDPointer &, const caStatus)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::writeResponse(const caHdr &,
caStatus casCoreClient::writeResponse (const caHdr &,
const caStatus)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::writeNotifyResponse(const caHdr &,
caStatus casCoreClient::writeNotifyResponse (const caHdr &,
const caStatus)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::monitorResponse(casChannelI &, const caHdr &,
const gdd *, const caStatus)
caStatus casCoreClient::monitorResponse (casChannelI &, const caHdr &,
const smartConstGDDPointer &, const caStatus)
{
return S_casApp_noSupport;
}
caStatus casCoreClient::accessRightsResponse(casChannelI *)
caStatus casCoreClient::accessRightsResponse (casChannelI *)
{
return S_casApp_noSupport;
}
@@ -147,17 +147,17 @@ caStatus casCoreClient::accessRightsResponse(casChannelI *)
//
// casCoreClient::installChannel()
//
void casCoreClient::installChannel(casChannelI &)
void casCoreClient::installChannel (casChannelI &)
{
assert(0); // dont install channels on the wrong type of client
assert (0); // dont install channels on the wrong type of client
}
//
// casCoreClient::removeChannel()
//
void casCoreClient::removeChannel(casChannelI &)
void casCoreClient::removeChannel (casChannelI &)
{
assert(0); // dont install channels on the wrong type of client
assert (0); // dont install channels on the wrong type of client
}
//
@@ -171,7 +171,7 @@ caNetAddr casCoreClient::fetchLastRecvAddr () const
//
// casCoreClient::lookupRes()
//
casRes *casCoreClient::lookupRes(const caResId &idIn, casResType type)
casRes *casCoreClient::lookupRes (const caResId &idIn, casResType type)
{
casRes *pRes;
pRes = this->ctx.getServer()->lookupRes(idIn, type);

View File

@@ -87,8 +87,8 @@ caStatus casDGClient::uknownMessageAction ()
{
const caHdr *mp = this->ctx.getMsg();
ca_printf ("CAS: bad request code in DG =%u\n", mp->m_cmmd);
this->dumpMsg (mp, this->ctx.getData());
this->dumpMsg (mp, this->ctx.getData(),
"bad request code=%u in DG\n", mp->m_cmmd);
return S_cas_internal;
}
@@ -100,12 +100,22 @@ caStatus casDGClient::searchAction()
{
const caHdr *mp = this->ctx.getMsg();
void *dp = this->ctx.getData();
const char *pChanName = (const char *) dp;
char *pChanName = (char *) dp;
caStatus status;
//
// check the sanity of the message
//
if (mp->m_postsize<=1) {
this->dumpMsg (mp, dp,
"empty PV name in UDP search request?\n");
return S_cas_success;
}
pChanName[mp->m_postsize-1] = '\0';
if (this->getCAS().getDebugLevel()>2u) {
char pName[64u];
this->clientHostName (pName, sizeof (pName));
this->clientHostName (pChanName, sizeof (pChanName));
printf("%s is searching for \"%s\"\n", pName, pChanName);
}
@@ -332,14 +342,14 @@ void casDGClient::sendBeacon ()
//
// create the message
//
memset(&buf, 0, sizeof(msg));
msg.m_cmmd = htons(CA_PROTO_RSRV_IS_UP);
msg.m_available = htonl (INADDR_ANY);
memset (&buf, 0, sizeof(msg));
//
// send it to all addresses on the beacon list
// send it to all addresses on the beacon list,
// but let the IO specific code set the address
// field and the port field
//
this->sendBeaconIO (buf, sizeof(msg), msg.m_count);
this->sendBeaconIO (buf, sizeof(msg), msg.m_cmmd, msg.m_available);
}
//
@@ -479,7 +489,7 @@ caStatus casDGClient::processDG ()
if (bytesLeft<sizeof(*pReqHdr)) {
this->inBuf::removeMsg (bytesLeft);
ca_printf ("casDGClient::processMsg: incomplete DG header?");
errlogPrintf ("casDGClient::processMsg: incomplete DG header?");
status = S_cas_internal;
break;
}
@@ -505,7 +515,7 @@ caStatus casDGClient::processDG ()
if ( inctx.pushResult() != inBufCtx::pushCtxSuccess ) {
this->inBuf::removeMsg (bytesLeft);
this->outBuf::popCtx (outctx);
ca_printf ("casDGClient::processMsg: incomplete DG?\n");
errlogPrintf ("casDGClient::processMsg: incomplete DG?\n");
status = S_cas_internal;
break;
}

View File

@@ -89,11 +89,11 @@ inline void casEventSys::insertEventQueue(casEvent &insert, casEvent &prevEvent)
//
// casEventSys::pushOnToEventQueue()
//
inline void casEventSys::pushOnToEventQueue(casEvent &event)
inline void casEventSys::pushOnToEventQueue (casEvent &event)
{
this->mutex.lock();
this->eventLogQue.push(event);
this->mutex.unlock();
this->mutex.lock ();
this->eventLogQue.push (event);
this->mutex.unlock ();
}
//

View File

@@ -86,19 +86,19 @@ public:
virtual ~ioBlocked ();
private:
ioBlockedList *pList;
virtual void ioBlockedSignal () = 0;
virtual void ioBlockedSignal ();
};
//
// ioBlockedList
//
class ioBlockedList : private tsDLList<ioBlocked> {
friend class ioBlocked;
public:
ioBlockedList ();
virtual ~ioBlockedList ();
void signal ();
void removeItemFromIOBLockedList(ioBlocked &item);
void addItemToIOBLockedList(ioBlocked &item);
void addItemToIOBLockedList (ioBlocked &item);
};
class casMonitor;
@@ -113,7 +113,7 @@ public:
// (and we need to postpone true construction)
//
inline casMonEvent ();
inline casMonEvent (casMonitor &monitor, gdd &newValue);
inline casMonEvent (casMonitor &monitor, const smartConstGDDPointer &pNewValue);
inline casMonEvent (const casMonEvent &initValue);
//
@@ -122,20 +122,20 @@ public:
//
~casMonEvent ();
caStatus cbFunc(casEventSys &);
caStatus cbFunc (casEventSys &);
//
// casMonEvent::getValue()
//
inline gdd *getValue() const;
inline smartConstGDDPointer getValue () const;
inline void operator = (const class casMonEvent &monEventIn);
inline void clear();
inline void clear ();
void assign (casMonitor &monitor, gdd *pValueIn);
void assign (casMonitor &monitor, const smartConstGDDPointer &pValueIn);
private:
smartGDDPointer pValue;
smartConstGDDPointer pValue;
caResId id;
};
@@ -152,10 +152,10 @@ public:
caStatus executeEvent(casMonEvent *);
inline void post(const casEventMask &select, gdd &value);
inline void post(const casEventMask &select, const smartConstGDDPointer &pValue);
virtual void show (unsigned level) const;
virtual caStatus callBack(gdd &value)=0;
virtual caStatus callBack (const smartConstGDDPointer &pValue) = 0;
caResId getClientId() const
{
@@ -191,28 +191,28 @@ private:
void enable();
void disable();
void push (gdd &value);
void push (const smartConstGDDPointer &pValue);
};
//
// casMonitor::post()
// (check for NOOP case in line)
//
inline void casMonitor::post(const casEventMask &select, gdd &value)
inline void casMonitor::post (const casEventMask &select, const smartConstGDDPointer &pValue)
{
casEventMask result(select&this->mask);
casEventMask result (select&this->mask);
//
// NOOP if this event isnt selected
// or if it is disabled
//
if (result.noEventsSelected() || !this->enabled) {
if ( result.noEventsSelected() || !this->enabled ) {
return;
}
//
// else push it on the queue
//
this->push(value);
this->push (pValue);
}
class caServer;
@@ -325,7 +325,7 @@ public:
void installAsyncIO (casAsyncIOI &);
void removeAsyncIO (casAsyncIOI &);
void postEvent (const casEventMask &select, gdd &event);
void postEvent (const casEventMask &select, const smartConstGDDPointer &pEvent);
epicsShareFunc virtual casResType resourceType () const;
@@ -436,7 +436,7 @@ public:
//
void deleteSignal ();
void postEvent (const casEventMask &select, gdd &event);
void postEvent (const casEventMask &select, const smartConstGDDPointer &pEvent);
caServer *getExtServer () const;

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.6 1998/07/08 15:38:06 jhill
* fixed lost monitors during flow control problem
*
* Revision 1.5 1998/06/16 02:27:06 jhill
* use smart gdd ptr
*
@@ -85,7 +88,7 @@ caStatus casMonEvent::cbFunc(casEventSys &eSys)
//
// casMonEvent::assign ()
//
void casMonEvent::assign (casMonitor &monitor, gdd *pValueIn)
void casMonEvent::assign (casMonitor &monitor, const smartConstGDDPointer &pValueIn)
{
this->pValue = pValueIn;
this->id = monitor.casRes::getId();

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.6 1998/10/27 21:34:19 jhill
* avoid problems with early g++
*
* Revision 1.5 1998/10/23 00:28:20 jhill
* fixed HP-UX warnings
*
@@ -60,26 +63,23 @@ inline casMonEvent::casMonEvent () :
//
// casMonEvent::casMonEvent()
//
inline casMonEvent::casMonEvent (casMonitor &monitor, gdd &newValue) :
pValue(&newValue),
id(monitor.casRes::getId()) {}
inline casMonEvent::casMonEvent (casMonitor &monitor, const smartConstGDDPointer &pNewValue) :
pValue ( pNewValue ),
id ( monitor.casRes::getId () ) {}
//
// casMonEvent::casMonEvent()
//
inline casMonEvent::casMonEvent (const casMonEvent &initValue) :
pValue(initValue.pValue),
id(initValue.id) {}
pValue ( initValue.pValue ),
id ( initValue.id ) {}
//
// casMonEvent::operator = ()
//
inline void casMonEvent::operator = (const class casMonEvent &monEventIn)
{
//
// this cast is a workaround for defects in early versions of GNU g++
//
this->pValue = (gdd *) monEventIn.pValue;
this->pValue = monEventIn.pValue;
this->id = monEventIn.id;
}
@@ -95,7 +95,7 @@ inline void casMonEvent::clear()
//
// casMonEvent::getValue()
//
inline gdd *casMonEvent::getValue() const
inline smartConstGDDPointer casMonEvent::getValue() const
{
return this->pValue;
}

View File

@@ -122,9 +122,9 @@ void casMonitor::disable()
//
// casMonitor::push()
//
void casMonitor::push(gdd &newValue)
void casMonitor::push (const smartConstGDDPointer &pNewValue)
{
casCoreClient &client = this->ciu.getClient();
casCoreClient &client = this->ciu.getClient ();
casMonEvent *pLog;
char full;
@@ -135,10 +135,10 @@ void casMonitor::push(gdd &newValue)
//
// get a new block if we havent exceeded quotas
//
full = (this->nPend>=individualEventEntries)
|| client.casEventSys::full();
full = ( this->nPend >= individualEventEntries )
|| client.casEventSys::full ();
if (!full) {
pLog = new casMonEvent(*this, newValue);
pLog = new casMonEvent (*this, pNewValue);
if (pLog) {
this->nPend++;
}
@@ -154,19 +154,21 @@ void casMonitor::push(gdd &newValue)
// (ugly - but avoids purify ukn sym type problem)
// (better to create a temp event object)
//
smartGDDPointer pValue = this->overFlowEvent.getValue();
assert (pValue!=NULL);
smartConstGDDPointer pValue = this->overFlowEvent.getValue ();
if (!pValue) {
assert (0);
}
this->overFlowEvent = *pLog;
pLog->assign(*this, pValue);
client.insertEventQueue(*pLog, this->overFlowEvent);
pLog->assign (*this, pValue);
client.insertEventQueue (*pLog, this->overFlowEvent);
}
else {
//
// replace the value with the current one
//
this->overFlowEvent.assign(*this, &newValue);
this->overFlowEvent.assign (*this, pNewValue);
}
client.removeFromEventQueue(this->overFlowEvent);
client.removeFromEventQueue (this->overFlowEvent);
pLog = &this->overFlowEvent;
}
else if (!pLog) {
@@ -175,14 +177,14 @@ void casMonitor::push(gdd &newValue)
// => use the over flow block in the event structure
//
this->ovf = TRUE;
this->overFlowEvent.assign(*this, &newValue);
this->overFlowEvent.assign (*this, pNewValue);
this->nPend++;
pLog = &this->overFlowEvent;
}
client.addToEventQueue(*pLog);
client.addToEventQueue (*pLog);
this->mutex.unlock();
this->mutex.unlock ();
}
//
@@ -191,14 +193,16 @@ void casMonitor::push(gdd &newValue)
caStatus casMonitor::executeEvent(casMonEvent *pEV)
{
caStatus status;
smartGDDPointer pVal;
smartConstGDDPointer pVal;
pVal = pEV->getValue ();
assert (pVal!=NULL);
if (!pVal) {
assert (0);
}
this->mutex.lock();
this->mutex.lock ();
status = this->callBack (*pVal);
this->mutex.unlock();
this->mutex.unlock ();
//
// if the event isnt accepted we will try

View File

@@ -51,7 +51,7 @@ epicsShareFunc casPV::casPV (caServer &)
{
}
epicsShareFunc casPV::~casPV()
epicsShareFunc casPV::~casPV ()
{
}
@@ -78,7 +78,7 @@ epicsShareFunc casChannel *casPV::createChannel (const casCtx &ctx, const char *
//
// casPV::interestRegister()
//
epicsShareFunc caStatus casPV::interestRegister()
epicsShareFunc caStatus casPV::interestRegister ()
{
return S_casApp_success;
}
@@ -86,14 +86,14 @@ epicsShareFunc caStatus casPV::interestRegister()
//
// casPV::interestDelete()
//
epicsShareFunc void casPV::interestDelete()
epicsShareFunc void casPV::interestDelete ()
{
}
//
// casPV::beginTransaction()
//
epicsShareFunc caStatus casPV::beginTransaction()
epicsShareFunc caStatus casPV::beginTransaction ()
{
return S_casApp_success;
}
@@ -101,14 +101,14 @@ epicsShareFunc caStatus casPV::beginTransaction()
//
// casPV::endTransaction()
//
epicsShareFunc void casPV::endTransaction()
epicsShareFunc void casPV::endTransaction ()
{
}
//
// casPV::read()
//
epicsShareFunc caStatus casPV::read(const casCtx &, gdd &)
epicsShareFunc caStatus casPV::read (const casCtx &, gdd &)
{
return S_casApp_noSupport;
}
@@ -116,7 +116,7 @@ epicsShareFunc caStatus casPV::read(const casCtx &, gdd &)
//
// casPV::write()
//
epicsShareFunc caStatus casPV::write(const casCtx &, gdd &)
epicsShareFunc caStatus casPV::write (const casCtx &, const gdd &)
{
return S_casApp_noSupport;
}
@@ -124,7 +124,7 @@ epicsShareFunc caStatus casPV::write(const casCtx &, gdd &)
//
// casPV::bestExternalType()
//
epicsShareFunc aitEnum casPV::bestExternalType() const
epicsShareFunc aitEnum casPV::bestExternalType () const
{
return aitEnumString;
}
@@ -133,7 +133,7 @@ epicsShareFunc aitEnum casPV::bestExternalType() const
// casPV::maxDimension()
// (base returns zero - scalar)
//
epicsShareFunc unsigned casPV::maxDimension() const
epicsShareFunc unsigned casPV::maxDimension () const
{
return 0u;
}
@@ -142,7 +142,7 @@ epicsShareFunc unsigned casPV::maxDimension() const
// casPV::maxBound()
// (base returns scalar bound independent of the dimension arg)
//
epicsShareFunc aitIndex casPV::maxBound(unsigned /* dimension */) const
epicsShareFunc aitIndex casPV::maxBound (unsigned /* dimension */) const
{
return 1u;
}
@@ -158,7 +158,7 @@ epicsShareFunc void casPV::show (unsigned level) const
//
// Server tool calls this function to post a PV event.
//
epicsShareFunc void casPV::postEvent (const casEventMask &select, gdd &event)
epicsShareFunc void casPV::postEvent (const casEventMask &select, const gdd &event)
{
this->casPVI::postEvent (select, event);
}
@@ -170,9 +170,9 @@ epicsShareFunc void casPV::postEvent (const casEventMask &select, gdd &event)
// into a server.
// ***************
//
epicsShareFunc caServer *casPV::getCAS() const
epicsShareFunc caServer *casPV::getCAS () const
{
return this->casPVI::getExtServer();
return this->casPVI::getExtServer ();
}
//

View File

@@ -90,11 +90,50 @@ casPVI::~casPVI()
casVerify (this->nMonAttached==0u);
}
//
// casPVI::deleteSignal()
// check for none attached and delete self if so
//
void casPVI::deleteSignal ()
{
caServerI *pLocalCAS = this->pCAS;
//
// if we are not attached to a server then the
// following steps are not relevant
//
if (pLocalCAS) {
//
// We dont take the PV lock here because
// the PV may be destroyed and we must
// keep the lock unlock pairs consistent
// (because the PV's lock is really a ref
// to the server's lock)
//
// This is safe to do because we take the PV
// lock when we add a new channel (and the
// PV lock is realy the server's lock)
//
pLocalCAS->lock();
if (this->chanList.count()==0u) {
pLocalCAS->removeItem (*this);
this->pCAS = NULL;
this->destroy ();
//
// !! dont access self after destroy !!
//
}
pLocalCAS->unlock();
}
}
//
// casPVI::destroy()
//
// This version of destroy() is provided only because it can
// be safely calle din the casPVI destructor as a side effect
// be safely called in the casPVI destructor as a side effect
// of deleting the last channel.
//
void casPVI::destroy ()

View File

@@ -103,44 +103,6 @@ inline void casPVI::unregisterIO()
this->ioBlockedList::signal();
}
//
// casPVI::deleteSignal()
// check for none attached and delete self if so
//
inline void casPVI::deleteSignal()
{
caServerI *pLocalCAS = this->pCAS;
//
// if we are not attached to a server then the
// following steps are not relevant
//
if (pLocalCAS) {
//
// We dont take the PV lock here because
// the PV may be destroyed and we must
// keep the lock unlock pairs consistent
// (because the PV's lock is really a ref
// to the server's lock)
//
// This is safe to do because we take the PV
// lock when we add a new channel (and the
// PV lock is realy the server's lock)
//
pLocalCAS->lock();
if (this->chanList.count()==0u) {
this->pCAS = NULL;
this->destroy ();
//
// !! dont access self after destroy !!
//
}
pLocalCAS->unlock();
}
}
//
// casPVI::bestDBRType()
//
@@ -166,22 +128,16 @@ inline caStatus casPVI::bestDBRType (unsigned &dbrType)
//
// casPVI::postEvent()
//
inline void casPVI::postEvent (const casEventMask &select, gdd &event)
inline void casPVI::postEvent (const casEventMask &select, const smartConstGDDPointer &pEvent)
{
if (this->nMonAttached==0u) {
return;
}
//
// the event queue is looking at the DD
// now so it must not be changed
//
event.markConstant();
this->lock();
tsDLIterBD<casPVListChan> iter(this->chanList.first());
while ( iter != tsDLIterBD<casPVListChan>::eol() ) {
iter->postEvent(select, event);
iter->postEvent(select, pEvent);
++iter;
}
this->unlock();

View File

@@ -117,8 +117,8 @@ caStatus casStrmClient::uknownMessageAction ()
const caHdr *mp = this->ctx.getMsg();
caStatus status;
ca_printf ("CAS: bad request code from virtual circuit=%u\n", mp->m_cmmd);
this->dumpMsg (mp, this->ctx.getData());
this->dumpMsg (mp, this->ctx.getData(),
"bad request code from virtual circuit=%u\n", mp->m_cmmd);
/*
* most clients dont recover from this
@@ -228,7 +228,7 @@ caStatus casStrmClient::readAction ()
return this->sendErr(mp, status, "read access denied");
}
status = this->read(pDesc);
status = this->read (pDesc);
if (status==S_casApp_success) {
status = this->readResponse(pChan, *mp, *pDesc, S_cas_success);
}
@@ -249,7 +249,7 @@ caStatus casStrmClient::readAction ()
// casStrmClient::readResponse()
//
caStatus casStrmClient::readResponse (casChannelI *pChan, const caHdr &msg,
const gdd &desc, const caStatus status)
const smartConstGDDPointer &pDesc, const caStatus status)
{
caHdr *reply;
unsigned size;
@@ -281,9 +281,9 @@ caStatus casStrmClient::readResponse (casChannelI *pChan, const caHdr &msg,
// convert gdd to db_access type
// (places the data in network format)
//
mapDBRStatus = gddMapDbr[msg.m_dataType].conv_dbr((reply+1), msg.m_count, desc, pChan->enumStringTable());
mapDBRStatus = gddMapDbr[msg.m_dataType].conv_dbr((reply+1), msg.m_count, *pDesc, pChan->enumStringTable());
if (mapDBRStatus<0) {
desc.dump();
pDesc->dump();
errPrintf (S_cas_badBounds, __FILE__, __LINE__, "- get with PV=%s type=%u count=%u",
pChan->getPVI().getName(), msg.m_dataType, msg.m_count);
return this->sendErrWithEpicsStatus(&msg, S_cas_badBounds, ECA_GETFAIL);
@@ -338,9 +338,9 @@ caStatus casStrmClient::readNotifyAction ()
}
}
status = this->read(pDesc);
status = this->read (pDesc);
if (status == S_casApp_success) {
status = this->readNotifyResponse(pChan, *mp, pDesc, status);
status = this->readNotifyResponse (pChan, *mp, pDesc, status);
}
else if (status == S_casApp_asyncCompletion) {
status = S_cas_success;
@@ -359,7 +359,7 @@ caStatus casStrmClient::readNotifyAction ()
// casStrmClient::readNotifyResponse()
//
caStatus casStrmClient::readNotifyResponse (casChannelI *pChan,
const caHdr &msg, const gdd *pDesc, const caStatus completionStatus)
const caHdr &msg, const smartConstGDDPointer &pDesc, const caStatus completionStatus)
{
caStatus ecaStatus;
@@ -369,7 +369,7 @@ caStatus casStrmClient::readNotifyResponse (casChannelI *pChan,
else {
ecaStatus = ECA_NORMAL;
}
ecaStatus = this->readNotifyResponseECA_XXX(pChan, msg, pDesc, ecaStatus);
ecaStatus = this->readNotifyResponseECA_XXX (pChan, msg, pDesc, ecaStatus);
if (ecaStatus) {
return ecaStatus;
}
@@ -400,7 +400,7 @@ caStatus casStrmClient::readNotifyResponse (casChannelI *pChan,
// casStrmClient::readNotifyResponseECA_XXX ()
//
caStatus casStrmClient::readNotifyResponseECA_XXX (casChannelI *pChan,
const caHdr &msg, const gdd *pDesc, const caStatus ecaStatus)
const caHdr &msg, const smartConstGDDPointer &pDesc, const caStatus ecaStatus)
{
caHdr *reply;
unsigned size;
@@ -437,7 +437,12 @@ caStatus casStrmClient::readNotifyResponseECA_XXX (casChannelI *pChan,
// cid field abused to store the status here
//
if (ecaStatus == ECA_NORMAL) {
if (pDesc) {
if (!pDesc) {
errMessage(S_cas_badParameter,
"because no data in server tool asynch read resp");
reply->m_cid = ECA_GETFAIL;
}
else {
int mapDBRStatus;
//
// convert gdd to db_access type
@@ -454,11 +459,6 @@ caStatus casStrmClient::readNotifyResponseECA_XXX (casChannelI *pChan,
reply->m_cid = ECA_NORMAL;
}
}
else {
errMessage(S_cas_badParameter,
"because no data in server tool asynch read resp");
reply->m_cid = ECA_GETFAIL;
}
}
else {
reply->m_cid = ecaStatus;
@@ -502,10 +502,136 @@ caStatus casStrmClient::readNotifyResponseECA_XXX (casChannelI *pChan,
}
//
// casStrmClient::monitorResponse()
// createDBRDD ()
//
caStatus casStrmClient::monitorResponse(casChannelI &chan, const caHdr &msg,
const gdd *pDesc, const caStatus completionStatus)
static smartGDDPointer createDBRDD (unsigned dbrType, aitIndex dbrCount)
{
smartGDDPointer pDescRet;
aitUint32 valIndex;
aitUint32 gddStatus;
aitUint16 appType;
smartGDDPointer pVal;
/*
* DBR type has already been checked, but it is possible
* that "gddDbrToAit" will not track with changes in
* the DBR_XXXX type system
*/
if (dbrType>=NELEMENTS(gddDbrToAit)) {
return pDescRet;
}
if (gddDbrToAit[dbrType].type==aitEnumInvalid) {
return pDescRet;
}
appType = gddDbrToAit[dbrType].app;
//
// create the descriptor
//
pDescRet = gddApplicationTypeTable::app_table.getDD (appType);
if (!pDescRet) {
return pDescRet;
}
if (pDescRet->isContainer()) {
//
// unable to change the bounds on the managed GDD that is
// returned for DBR types
//
if (dbrCount>1 ) {
pDescRet = (gdd *) new gdd (*pDescRet);
//
// smart pointer class maintains the ref count from here down
//
gddStatus = pDescRet->unreference();
assert (!gddStatus);
}
//
// All DBR types have a value member
//
gddStatus =
gddApplicationTypeTable::app_table.mapAppToIndex
(appType, gddAppType_value, valIndex);
if (gddStatus) {
pDescRet = NULL;
return pDescRet;
}
pVal = pDescRet->getDD (valIndex);
if (!pVal) {
pDescRet = NULL;
return pDescRet;
}
}
else {
pVal = pDescRet;
}
if (pVal->isScalar()) {
if (dbrCount<=1u) {
return S_cas_success;
}
//
// scalar and managed (and need to set the bounds)
// => out of luck (cant modify bounds)
//
if (pDescRet->isManaged()) {
pDescRet = NULL;
return pDescRet;
}
//
// convert to atomic
//
gddBounds bds;
bds.setSize(dbrCount);
bds.setFirst(0u);
pVal->setDimension(1u, &bds);
}
else if (pVal->isAtomic()) {
const gddBounds* pB = pVal->getBounds();
aitIndex bound = dbrCount;
unsigned dim;
int modAllowed;
if (pDescRet->isManaged() || pDescRet->isFlat()) {
modAllowed = FALSE;
}
else {
modAllowed = TRUE;
}
for (dim=0u; dim<(unsigned)pVal->dimension(); dim++) {
if (pB[dim].first()!=0u && pB[dim].size()!=bound) {
if (modAllowed) {
pVal->setBound(dim, 0u, bound);
}
else {
pDescRet = NULL;
return pDescRet;
}
}
bound = 1u;
}
}
else {
//
// the GDD is container or isnt any of the normal types
//
pDescRet = NULL;
return pDescRet;
}
return pDescRet;
}
//
// casStrmClient::monitorResponse ()
//
caStatus casStrmClient::monitorResponse (casChannelI &chan, const caHdr &msg,
const smartConstGDDPointer &pDesc, const caStatus completionStatus)
{
caStatus completionStatusCopy = completionStatus;
smartGDDPointer pDBRDD;
@@ -548,12 +674,17 @@ caStatus casStrmClient::monitorResponse(casChannelI &chan, const caHdr &msg,
//
if (completionStatusCopy == S_cas_success) {
if (pDesc) {
completionStatusCopy = createDBRDD(msg.m_dataType,
msg.m_count, pDBRDD);
if (completionStatusCopy==S_cas_success) {
if (!pDesc) {
completionStatusCopy = S_cas_badParameter;
}
else {
pDBRDD = createDBRDD (msg.m_dataType, msg.m_count);
if (!pDBRDD) {
completionStatusCopy = S_cas_noMemory;
}
else {
gdds = gddApplicationTypeTable::
app_table.smartCopy(pDBRDD, pDesc);
app_table.smartCopy ( & (*pDBRDD), & (*pDesc) );
if (gdds) {
errPrintf (status, __FILE__, __LINE__,
"no conversion between event app type=%d and DBR type=%d Element count=%d",
@@ -564,9 +695,6 @@ caStatus casStrmClient::monitorResponse(casChannelI &chan, const caHdr &msg,
}
}
}
else {
completionStatusCopy = S_cas_badParameter;
}
}
//
@@ -680,7 +808,6 @@ caStatus casStrmClient::writeAction()
}
//
// casStrmClient::writeResponse()
//
@@ -914,7 +1041,6 @@ caStatus casStrmClient::claimChannelAction()
const caHdr *mp = this->ctx.getMsg();
char *pName = (char *) this->ctx.getData();
caServerI &cas = *this->ctx.getServer();
unsigned nameLength;
caStatus status;
/*
@@ -944,16 +1070,13 @@ caStatus casStrmClient::claimChannelAction()
return S_cas_badProtocol; // disconnect client
}
if (mp->m_postsize == 0u) {
if (mp->m_postsize <= 1u) {
return S_cas_badProtocol; // disconnect client
}
nameLength = strlen(pName);
if (nameLength>mp->m_postsize) {
return S_cas_badProtocol; // disconnect client
}
pName[mp->m_postsize-1] = '\0';
if (nameLength>unreasonablePVNameSize) {
if (mp->m_postsize-1>unreasonablePVNameSize) {
return S_cas_badProtocol; // disconnect client
}
@@ -1074,7 +1197,7 @@ caStatus casStrmClient::createChanResponse(const caHdr &hdr, const pvAttachRetur
status = casStrmClient::accessRightsResponse(pChanI);
if (status) {
this->outBuf::popCtx (outctx);
errMessage(status, "incompplete channel create?");
errMessage(status, "incomplete channel create?");
pChanI->destroyNoClientNotify();
return this->channelCreateFailed(&hdr, status);
}
@@ -1090,7 +1213,12 @@ caStatus casStrmClient::createChanResponse(const caHdr &hdr, const pvAttachRetur
// the protocol buffer.
//
status = this->allocMsg (0u, &claim_reply);
assert (status==S_cas_success);
if (status!=S_cas_success) {
this->outBuf::popCtx (outctx);
errMessage(status, "incomplete channel create?");
pChanI->destroyNoClientNotify();
return this->channelCreateFailed(&hdr, status);
}
*claim_reply = nill_msg;
claim_reply->m_cmmd = CA_PROTO_CLAIM_CIU;
@@ -1179,7 +1307,7 @@ caStatus casStrmClient::disconnectChan(caResId id)
createStatus = S_cas_success;
}
else {
ca_printf(
errlogPrintf(
"Disconnecting old client because of internal channel or PV delete\n");
createStatus = S_cas_disconnect;
}
@@ -1652,8 +1780,10 @@ caStatus casStrmClient::writeScalarData()
return S_cas_badType;
}
pDD = new gddScalar (gddAppType_value, type);
if (pDD==NULL) {
aitEnum bestExternalType = this->ctx.getPV()->bestExternalType ();
pDD = new gddScalar (gddAppType_value, bestExternalType);
if (!pDD) {
return S_cas_noMemory;
}
@@ -1664,36 +1794,36 @@ caStatus casStrmClient::writeScalarData()
gddStat = pDD->unreference();
assert (!gddStat);
if (type==aitEnumFixedString) {
aitFixedString *pFStr =
(aitFixedString *) this->ctx.getData();
gddStat = pDD->put(*pFStr);
}
else {
gddStat = pDD->genCopy(type, this->ctx.getData());
}
if (gddStat) {
return S_cas_badType;
}
//
// copy in, and convert to native type, the incoming data
//
gddStat = aitConvert (pDD->primitiveType(), pDD->dataAddress(), type,
this->ctx.getData(), 1, this->ctx.getPV()->enumStringTable());
if (gddStat<0) {
status = S_cas_noConvert;
}
else {
//
// set the status and severity to normal
//
pDD->setStat (epicsAlarmNone);
pDD->setSevr (epicsSevNone);
pDD->setStat(epicsAlarmNone);
pDD->setSevr(epicsSevNone);
//
// No suprises when multiple codes are looking
// at the same data
//
pDD->markConstant ();
//
// call the server tool's virtual function
//
status = this->ctx.getPV()->write(this->ctx, *pDD);
//
// set the time stamp to the last time that
// we added bytes to the in buf
//
aitTimeStamp gddts = this->lastRecvTS;
pDD->setTimeStamp (&gddts);
//
// call the server tool's virtual function
//
status = this->ctx.getPV()->write (this->ctx, *pDD);
}
return status;
}
//
// casStrmClient::writeArrayData()
//
@@ -1721,7 +1851,9 @@ caStatus casStrmClient::writeArrayData()
return S_cas_badType;
}
pDD = new gddAtomic(gddAppType_value, type, 1, pHdr->m_count);
aitEnum bestExternalType = this->ctx.getPV()->bestExternalType ();
pDD = new gddAtomic(gddAppType_value, bestExternalType, 1, pHdr->m_count);
if (!pDD) {
return S_cas_noMemory;
}
@@ -1732,7 +1864,7 @@ caStatus casStrmClient::writeArrayData()
gddStat = pDD->unreference();
assert (!gddStat);
size = dbr_size_n (pHdr->m_dataType, pHdr->m_count);
size = aitSize[bestExternalType] * pHdr->m_count;
pData = new char [size];
if (!pData) {
return S_cas_noMemory;
@@ -1749,49 +1881,54 @@ caStatus casStrmClient::writeArrayData()
}
//
// move the data from the protocol buffer
// convert the data from the protocol buffer
// to the allocated area so that they
// will be allowed to ref the DD
//
memcpy (pData, this->ctx.getData(), size);
gddStat = aitConvert (bestExternalType, pData, type, this->ctx.getData(),
pHdr->m_count, this->ctx.getPV()->enumStringTable() );
if (gddStat<0) {
status = S_cas_noConvert;
delete pDestructor;
delete [] pData;
}
else {
//
// install allocated area into the DD
//
pDD->putRef (pData, type, pDestructor);
//
// install allocated area into the DD
//
pDD->putRef (pData, type, pDestructor);
//
// set the status and severity to normal
//
pDD->setStat (epicsAlarmNone);
pDD->setSevr (epicsSevNone);
pDD->setStat(epicsAlarmNone);
pDD->setSevr(epicsSevNone);
//
// No suprises when multiple codes are looking
// at the same data
//
pDD->markConstant ();
//
// call the server tool's virtual function
//
status = this->ctx.getPV()->write(this->ctx, *pDD);
//
// set the time stamp to the last time that
// we added bytes to the in buf
//
aitTimeStamp gddts = this->lastRecvTS;
pDD->setTimeStamp (&gddts);
//
// call the server tool's virtual function
//
status = this->ctx.getPV()->write(this->ctx, *pDD);
}
return status;
}
//
// casStrmClient::read()
//
caStatus casStrmClient::read(smartGDDPointer &pDescRet)
caStatus casStrmClient::read (smartGDDPointer &pDescRet)
{
const caHdr *pHdr = this->ctx.getMsg();
caStatus status;
pDescRet = NULL;
status = createDBRDD (pHdr->m_dataType, pHdr->m_count, pDescRet);
if (status) {
return status;
}
if (pDescRet==NULL) {
pDescRet = createDBRDD (pHdr->m_dataType, pHdr->m_count);
if (!pDescRet) {
return S_cas_noMemory;
}
@@ -1811,7 +1948,7 @@ caStatus casStrmClient::read(smartGDDPointer &pDescRet)
//
// call the server tool's virtual function
//
status = this->ctx.getPV()->read(this->ctx, *pDescRet);
status = this->ctx.getPV()->read (this->ctx, *pDescRet);
//
// prevent problems when they initiate
@@ -1841,144 +1978,6 @@ caStatus casStrmClient::read(smartGDDPointer &pDescRet)
return status;
}
//
// createDBRDD ()
//
caStatus createDBRDD (unsigned dbrType, aitIndex dbrCount, smartGDDPointer &pDescRet)
{
aitUint32 valIndex;
aitUint32 gddStatus;
aitUint16 appType;
gdd *pVal;
/*
* DBR type has already been checked, but it is possible
* that "gddDbrToAit" will not track with changes in
* the DBR_XXXX type system
*/
if (dbrType>=NELEMENTS(gddDbrToAit)) {
return S_cas_badType;
}
if (gddDbrToAit[dbrType].type==aitEnumInvalid) {
return S_cas_badType;
}
appType = gddDbrToAit[dbrType].app;
//
// create the descriptor
//
pDescRet = gddApplicationTypeTable::app_table.getDD (appType);
if (!pDescRet) {
return S_cas_noMemory;
}
//
// smart pointer class maintains the ref count from here down
//
gddStatus = pDescRet->unreference();
assert (!gddStatus);
if (pDescRet->isContainer()) {
gdd *pGdd = pDescRet;
//
// this cast is ugly and dangerous
// (Jim should have used virtual functions in gdd)
//
gddContainer *pCont = (gddContainer *) pGdd;
//
// unable to change the bounds on the managed GDD that is
// returned for DBR types
//
if (dbrCount>1 ) {
pDescRet = (gdd *) new gddContainer (pCont);
//
// smart pointer class maintains the ref count from here down
//
gddStatus = pDescRet->unreference();
assert (!gddStatus);
}
//
// All DBR types have a value member
//
gddStatus =
gddApplicationTypeTable::app_table.mapAppToIndex
(appType, gddAppType_value, valIndex);
if (gddStatus) {
pDescRet = NULL;
return S_cas_internal;
}
pVal = pCont->getDD(valIndex);
if (!pVal) {
pDescRet = NULL;
return S_cas_internal;
}
}
else {
pVal = pDescRet;
}
if (pVal->isScalar()) {
if (dbrCount<=1u) {
return S_cas_success;
}
//
// scalar and managed (and need to set the bounds)
// => out of luck (cant modify bounds)
//
if (pDescRet->isManaged()) {
pDescRet = NULL;
return S_cas_internal;
}
//
// convert to atomic
//
gddBounds bds;
bds.setSize(dbrCount);
bds.setFirst(0u);
pVal->setDimension(1u, &bds);
}
else if (pVal->isAtomic()) {
const gddBounds* pB = pVal->getBounds();
aitIndex bound = dbrCount;
unsigned dim;
int modAllowed;
if (pDescRet->isManaged() || pDescRet->isFlat()) {
modAllowed = FALSE;
}
else {
modAllowed = TRUE;
}
for (dim=0u; dim<(unsigned)pVal->dimension(); dim++) {
if (pB[dim].first()!=0u && pB[dim].size()!=bound) {
if (modAllowed) {
pVal->setBound(dim, 0u, bound);
}
else {
pDescRet = NULL;
return S_cas_internal;
}
}
bound = 1u;
}
}
else {
//
// the GDD is container or isnt any of the normal types
//
pDescRet = NULL;
return S_cas_internal;
}
return S_cas_success;
}
//
// casStrmClient::userName()
//
@@ -2080,12 +2079,10 @@ inBuf::fillCondition casStrmClient::xRecv(char *pBufIn, bufSizeT nBytes,
inBuf::fillCondition stat;
stat = this->osdRecv (pBufIn, nBytes, nActualBytes);
//if (stat==casFillProgress) {
//
// !! this time fetch may be slowing things down !!
//
//this->lastRecvTS = osiTime::getCurrent();
//}
//
// this is used to set the time stamp for write GDD's
//
this->lastRecvTS = osiTime::getCurrent();
return stat;
}

View File

@@ -472,6 +472,11 @@ public:
// asynchronous IO operation (read or write) completes
// against the PV.
//
// NOTE:
// o the server tool is encouraged to change the prototype GDD's
// primitive type to whatever primitive data type is most convient
// for the server side tool.
//
epicsShareFunc virtual caStatus read (const casCtx &ctx, gdd &prototype);
//
@@ -486,7 +491,15 @@ public:
// asynchronous IO operation (read or write) completes
// against the PV.
//
epicsShareFunc virtual caStatus write (const casCtx &ctx, gdd &value);
// NOTE:
// o The incoming GDD with application type "value" is always
// converted to the PV.bestExternalType() primitive type.
// o The time stamp in the incoming GDD is set to the time that
// the last message was received from the client.
// o Currently, no container type GDD's are passed here and
// the application type is always "value". This may change.
//
epicsShareFunc virtual caStatus write (const casCtx &ctx, const gdd &value);
//
// chCreate() is called each time that a PV is attached to
@@ -564,7 +577,7 @@ public:
//
// Server tool calls this function to post a PV event.
//
epicsShareFunc void postEvent (const casEventMask &select, gdd &event);
epicsShareFunc void postEvent (const casEventMask &select, const gdd &event);
//
// peek at the pv name
@@ -767,7 +780,7 @@ public:
//
// only the first call to this function has any effect
//
epicsShareFunc caStatus postIOCompletion (caStatus completionStatusIn, gdd &valueRead);
epicsShareFunc caStatus postIOCompletion (caStatus completionStatusIn, const gdd &valueRead);
//
// Find the server associated with this async IO
@@ -790,7 +803,7 @@ public:
private:
caHdr const msg;
casChannelI &chan;
smartGDDPointer pDD;
smartConstGDDPointer pDD;
caStatus completionStatus;
epicsShareFunc bool readOP() const;

View File

@@ -121,7 +121,7 @@ void outBuf::commitMsg ()
}
if (this->getDebugLevel()) {
ca_printf (
errlogPrintf (
"CAS Response => cmd=%d id=%x typ=%d cnt=%d psz=%d avail=%x outBuf ptr=%lx\n",
mp->m_cmmd, mp->m_cid, mp->m_dataType, mp->m_count, mp->m_postsize,
mp->m_available, (long)mp);
@@ -192,7 +192,7 @@ outBuf::flushCondition outBuf::flush (bufSizeT spaceRequired)
if (this->getDebugLevel()>2u) {
char buf[64];
this->clientHostName (buf, sizeof(buf));
ca_printf ("CAS: Sent a %d byte reply to %s\n",
errlogPrintf ("CAS: Sent a %d byte reply to %s\n",
nBytes, buf);
}
}
@@ -212,8 +212,7 @@ const outBufCtx outBuf::pushCtx (bufSizeT headerSize, bufSizeT maxBodySize, void
if (status!=S_cas_success) {
return outBufCtx ();
}
else if (this->ctxRecursCount==UINT_MAX) {
this->mutex.unlock();
else if (this->ctxRecursCount>=UINT_MAX) {
return outBufCtx ();
}
else {

View File

@@ -46,6 +46,7 @@
// are included first here so that they are included
// once only before epicsExportSharedSymbols is defined)
//
#undef epicsAssertAuthor
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
#include "epicsAssert.h" // EPICS assert() macros
#include "osiTime.h" // EPICS os independent time
@@ -53,6 +54,7 @@
#include "errMdef.h" // EPICS error codes
#include "gdd.h" // EPICS data descriptors
#include "resourceLib.h" // EPICS hashing templates
#include "errlog.h" // EPICS error logging interface
//
// CA
@@ -69,13 +71,12 @@
//
#define epicsExportSharedSymbols
#include "casdef.h" // sets proper def for shareLib.h defines
#include "osiMutexCAS.h" // NOOP on single threaded OS
#include "osiMutex.h"
void casVerifyFunc(const char *pFile, unsigned line, const char *pExp);
void serverToolDebugFunc(const char *pFile, unsigned line, const char *pComment);
#define serverToolDebug(COMMENT) \
{serverToolDebugFunc(__FILE__, __LINE__, COMMENT); }
#define casVerify(EXP) {if ((EXP)==0) casVerifyFunc(__FILE__, __LINE__, #EXP); }
caStatus createDBRDD(unsigned dbrType, aitIndex dbrCount, smartGDDPointer &pDescRet);
caStatus copyBetweenDD(gdd &dest, gdd &src);
enum xBlockingStatus {xIsBlocking, xIsntBlocking};
@@ -168,7 +169,7 @@ public:
const casEventMask &maskIn, osiMutex &mutexIn);
virtual ~casClientMon();
caStatus callBack(gdd &value);
caStatus callBack (const smartConstGDDPointer &pValue);
virtual casResType resourceType() const;
@@ -436,7 +437,7 @@ public:
caServerI &getCAS() const;
virtual caStatus monitorResponse (casChannelI &chan, const caHdr &msg,
const gdd *pDesc, const caStatus status);
const smartConstGDDPointer &pDesc, const caStatus status);
virtual caStatus accessRightsResponse(casChannelI *);
@@ -444,15 +445,15 @@ public:
// one virtual function for each CA request type that has
// asynchronous completion
//
virtual caStatus asyncSearchResponse(
virtual caStatus asyncSearchResponse (
const caNetAddr &outAddr,
const caHdr &, const pvExistReturn &);
virtual caStatus createChanResponse(
virtual caStatus createChanResponse (
const caHdr &, const pvAttachReturn &);
virtual caStatus readResponse(
casChannelI *, const caHdr &, const gdd &, const caStatus);
virtual caStatus readNotifyResponse(
casChannelI *, const caHdr &, const gdd *, const caStatus);
virtual caStatus readResponse (
casChannelI *, const caHdr &, const smartConstGDDPointer &, const caStatus);
virtual caStatus readNotifyResponse (
casChannelI *, const caHdr &, const smartConstGDDPointer &, const caStatus);
virtual caStatus writeResponse (const caHdr &, const caStatus);
virtual caStatus writeNotifyResponse (const caHdr &, const caStatus);
@@ -516,7 +517,7 @@ protected:
//
// dump message to stderr
//
void dumpMsg(const caHdr *mp, const void *dp);
void dumpMsg (const caHdr *mp, const void *dp, const char *pFormat, ...);
private:
@@ -581,16 +582,15 @@ public:
// one function for each CA request type that has
// asynchronous completion
//
virtual caStatus createChanResponse(const caHdr &, const pvAttachReturn &);
caStatus readResponse(casChannelI *pChan, const caHdr &msg,
const gdd &desc, const caStatus status);
caStatus readNotifyResponse(casChannelI *pChan, const caHdr &msg,
const gdd *pDesc, const caStatus status);
caStatus writeResponse(const caHdr &msg,
const caStatus status);
caStatus writeNotifyResponse(const caHdr &msg, const caStatus status);
caStatus monitorResponse(casChannelI &chan, const caHdr &msg,
const gdd *pDesc, const caStatus status);
virtual caStatus createChanResponse (const caHdr &, const pvAttachReturn &);
caStatus readResponse (casChannelI *pChan, const caHdr &msg,
const smartConstGDDPointer &pDesc, const caStatus status);
caStatus readNotifyResponse (casChannelI *pChan, const caHdr &msg,
const smartConstGDDPointer &pDesc, const caStatus status);
caStatus writeResponse (const caHdr &msg, const caStatus status);
caStatus writeNotifyResponse (const caHdr &msg, const caStatus status);
caStatus monitorResponse (casChannelI &chan, const caHdr &msg,
const smartConstGDDPointer &pDesc, const caStatus status);
caStatus noReadAccessEvent(casClientMon *);
@@ -645,8 +645,8 @@ private:
// accessRightsResponse()
//
caStatus accessRightsResponse (casChannelI *pciu);
//
//
// these prepare the gdd based on what is in the ca hdr
//
caStatus read (smartGDDPointer &pDesc);
@@ -677,8 +677,8 @@ private:
bufSizeT &nBytesActual) = 0;
caStatus readNotifyResponseECA_XXX (casChannelI *pChan,
const caHdr &msg, const gdd *pDesc, const caStatus ecaStatus);
caStatus writeNotifyResponseECA_XXX(const caHdr &msg,
const caHdr &msg, const smartConstGDDPointer &pDesc, const caStatus ecaStatus);
caStatus writeNotifyResponseECA_XXX (const caHdr &msg,
const caStatus status);
};
@@ -699,7 +699,9 @@ public:
// only for use with DG io
//
void sendBeacon ();
virtual void sendBeaconIO (char &msg, unsigned length, aitUint16 &m_port) = 0;
virtual void sendBeaconIO (char &msg, bufSizeT length,
aitUint16 &portField, aitUint32 &addrField) = 0;
void destroy();
@@ -827,17 +829,17 @@ public:
//
// find the channel associated with a resource id
//
casChannelI *resIdToChannel(const caResId &id);
casChannelI *resIdToChannel (const caResId &id);
//
// find the PV associated with a resource id
//
casPVI *resIdToPV(const caResId &id);
casPVI *resIdToPV (const caResId &id);
//
// find the client monitor associated with a resource id
//
casClientMon *resIdToClientMon(const caResId &idIn);
casClientMon *resIdToClientMon (const caResId &idIn);
void installClient (casStrmClient *pClient);
@@ -851,7 +853,7 @@ public:
unsigned getDebugLevel() const { return debugLevel; }
inline void setDebugLevel (unsigned debugLevelIn);
void show(unsigned level) const;
void show (unsigned level) const;
casRes *lookupRes (const caResId &idIn, casResType type);
@@ -903,12 +905,12 @@ private:
casEventMask logEvent; // DBE_LOG registerEvent("log")
casEventMask alarmEvent; // DBE_ALARM registerEvent("alarm")
double getBeaconPeriod() const;
double getBeaconPeriod () const;
//
// send beacon and advance beacon timer
//
void sendBeacon();
void sendBeacon ();
caStatus attachInterface (const caNetAddr &addr, bool autoBeaconAddr,
bool addConfigAddr);
@@ -937,14 +939,6 @@ private:
caStatus cbFunc(casEventSys &);
};
/*
* this really should be in another header file
*/
extern "C" {
void ca_printf (const char *pFormat, ...);
}
#endif /*INCLserverh*/

View File

@@ -12,8 +12,8 @@
#undef epicsExportSharedSymbols
#include "osiTimer.h"
#include "fdManager.h"
#define epicsExportSharedSymbols
#define epicsExportSharedSymbols
#include "shareLib.h" // redefine share lib defines
class caServerI;

View File

@@ -10,8 +10,6 @@
#include <stdio.h>
#include "casdef.h"
#include "osiMutexNOOP.h"
//
// ioBlocked::ioBlocked ()
@@ -26,6 +24,24 @@ ioBlocked::ioBlocked () :
//
ioBlocked::~ioBlocked ()
{
if (this->pList) {
this->pList->remove (*this);
this->pList = NULL;
}
}
//
// ioBlocked::ioBlockedSignal ()
//
void ioBlocked::ioBlockedSignal ()
{
//
// this must _not_ be pure virtual because
// there are situations where this is called
// inbetween the derived class's and this base
// class's destructors, and therefore a
// NOOP is required
//
}
//
@@ -70,17 +86,6 @@ void ioBlockedList::signal ()
}
}
//
// ioBlockedList::removeItemFromIOBLockedList ()
//
void ioBlockedList::removeItemFromIOBLockedList (ioBlocked &item)
{
if (item.pList==this) {
this->remove (item);
item.pList = NULL;
}
}
//
// ioBlockedList::addItemToIOBLockedList ()
//

View File

@@ -8,9 +8,7 @@
#include <ctype.h>
#include "server.h"
#include "sigPipeIgnore.h"
#include "addrList.h"
#include "bsdSocketResource.h"
#include "osiSigPipeIgnore.h"
static char *getToken(const char **ppString, char *pBuf, unsigned bufSIze);
@@ -48,10 +46,10 @@ void caServerIO::locateInterfaces ()
// then use a hard coded default - CA_SERVER_PORT.
//
if (envGetConfigParamPtr(&EPICS_CAS_SERVER_PORT)) {
port = caFetchPortConfig(&EPICS_CAS_SERVER_PORT, CA_SERVER_PORT);
port = envGetInetPortConfigParam (&EPICS_CAS_SERVER_PORT, CA_SERVER_PORT);
}
else {
port = caFetchPortConfig(&EPICS_CA_SERVER_PORT, CA_SERVER_PORT);
port = envGetInetPortConfigParam (&EPICS_CA_SERVER_PORT, CA_SERVER_PORT);
}
memset ((char *)&saddr,0,sizeof(saddr));
@@ -89,11 +87,11 @@ void caServerIO::locateInterfaces ()
status = aToIPAddr (pToken, 0u, &saddr);
if (status) {
ca_printf(
errlogPrintf(
"%s: Parsing '%s'\n",
__FILE__,
EPICS_CAS_INTF_ADDR_LIST.name);
ca_printf(
errlogPrintf(
"\tBad internet address or host name: '%s'\n",
pToken);
continue;

View File

@@ -30,4 +30,3 @@
#include "server.h"
#include "dgInBufIL.h" // in line func for dgInBuf
#include "bsdSocketResource.h"

View File

@@ -36,7 +36,6 @@
#include "server.h"
#include "addrList.h"
#include "bsdSocketResource.h"
//
// casDGIntfIO::casDGIntfIO()
@@ -45,8 +44,8 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr,
bool autoBeaconAddr, bool addConfigBeaconAddr) :
casDGClient (serverIn)
{
struct sockaddr_in serverAddr;
struct sockaddr_in serverBCastAddr;
osiSockAddr serverAddr;
osiSockAddr serverBCastAddr;
int status;
unsigned short beaconPort;
@@ -61,60 +60,64 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr,
throw S_cas_internal;
}
this->beaconSock = casDGIntfIO::makeSockDG();
if (this->beaconSock==INVALID_SOCKET) {
socket_close (this->sock);
throw S_cas_internal;
}
//
// Fetch port configuration from EPICS environment variables
//
if (envGetConfigParamPtr(&EPICS_CAS_SERVER_PORT)) {
this->dgPort = caFetchPortConfig(&EPICS_CAS_SERVER_PORT,
this->dgPort = envGetInetPortConfigParam (&EPICS_CAS_SERVER_PORT,
CA_SERVER_PORT);
}
else {
this->dgPort = caFetchPortConfig(&EPICS_CA_SERVER_PORT,
this->dgPort = envGetInetPortConfigParam (&EPICS_CA_SERVER_PORT,
CA_SERVER_PORT);
}
beaconPort = caFetchPortConfig(&EPICS_CA_REPEATER_PORT,
beaconPort = envGetInetPortConfigParam (&EPICS_CA_REPEATER_PORT,
CA_REPEATER_PORT);
//
// set up the primary address of the server
//
serverAddr = addr;
serverAddr.sin_port = htons (this->dgPort);
serverAddr.ia = addr;
serverAddr.ia.sin_port = htons (this->dgPort);
//
// discover beacon addresses associated with this interface
//
{
ELLLIST BCastAddrList;
caAddrNode *pAddr;
osiSockAddrNode *pAddr;
ellInit (&BCastAddrList);
caDiscoverInterfaces (&BCastAddrList, this->sock, beaconPort,
serverAddr.sin_addr); // match addr
osiSockDiscoverBroadcastAddresses (&BCastAddrList,
this->sock, &serverAddr); // match addr
if (ellCount(&BCastAddrList)<1) {
errMessage (S_cas_noInterface, "unable to continue");
socket_close (this->sock);
throw S_cas_noInterface;
}
pAddr = (caAddrNode *) ellFirst (&BCastAddrList);
serverBCastAddr = pAddr->destAddr.in;
serverBCastAddr.sin_port = htons (this->dgPort);
pAddr = (osiSockAddrNode *) ellFirst (&BCastAddrList);
serverBCastAddr.ia = pAddr->addr.ia;
serverBCastAddr.ia.sin_port = htons (this->dgPort);
if (autoBeaconAddr) {
ellConcat(&this->beaconAddrList, &BCastAddrList);
setPortAndRemoveDuplicates (&this->beaconAddrList, &BCastAddrList, beaconPort);
}
else {
ellFree(&BCastAddrList);
ellFree (&BCastAddrList);
}
}
status = bind(this->sock, (struct sockaddr *)&serverAddr,
sizeof (serverAddr));
status = bind ( this->sock, &serverAddr.sa, sizeof (serverAddr) );
if (status<0) {
char buf[64];
int errnoCpy = SOCKERRNO;
ipAddrToA (&serverAddr, buf, sizeof(buf));
ipAddrToA (&serverAddr.ia, buf, sizeof(buf));
errPrintf (S_cas_bindFail, __FILE__, __LINE__,
"- bind UDP IP addr=%s failed because %s", buf, SOCKERRSTR(errnoCpy) );
socket_close (this->sock);
@@ -140,11 +143,8 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr,
//
// add in the configured addresses
//
caAddConfiguredAddr(
&this->beaconAddrList,
pParam,
this->sock,
beaconPort);
addAddrToChannelAccessAddressList (
&this->beaconAddrList, pParam, beaconPort);
}
//
@@ -167,7 +167,7 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr,
// address.
//
#if !defined(_WIN32)
if (serverAddr.sin_addr.s_addr != htonl(INADDR_ANY)) {
if (serverAddr.ia.sin_addr.s_addr != htonl(INADDR_ANY)) {
this->bcastRecvSock = casDGIntfIO::makeSockDG ();
if (this->bcastRecvSock==INVALID_SOCKET) {
@@ -175,12 +175,12 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr,
throw S_cas_internal;
}
status = bind (this->bcastRecvSock, (struct sockaddr *)&serverBCastAddr,
sizeof (serverAddr));
status = bind (this->bcastRecvSock, &serverBCastAddr.sa,
sizeof (serverBCastAddr.sa);
if (status<0) {
char buf[64];
int errnoCpy = SOCKERRNO;
ipAddrToA (&serverBCastAddr, buf, sizeof(buf));
ipAddrToA (&serverBCastAddr.ia, buf, sizeof(buf));
errPrintf (S_cas_bindFail, __FILE__, __LINE__,
"- bind UDP IP addr=%s failed because %s",
buf, SOCKERRSTR(errnoCpy));
@@ -221,6 +221,7 @@ casDGIntfIO::~casDGIntfIO()
void casDGIntfIO::show (unsigned level) const
{
printf ("casDGIntfIO at %p\n", this);
printChannelAccessAddressList (&this->beaconAddrList);
this->casDGClient::show (level);
}
@@ -234,7 +235,7 @@ void casDGIntfIO::xSetNonBlocking()
status = socket_ioctl(this->sock, FIONBIO, &yes);
if (status<0) {
ca_printf("%s:CAS: UDP non blocking IO set fail because \"%s\"\n",
errlogPrintf("%s:CAS: UDP non blocking IO set fail because \"%s\"\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
}
}
@@ -264,7 +265,7 @@ inBuf::fillCondition casDGIntfIO::osdRecv(char *pBufIn, bufSizeT size,
if (status<0) {
int errnoCpy = SOCKERRNO;
if( errnoCpy != SOCK_EWOULDBLOCK ){
ca_printf("CAS: UDP recv error was %s",
errlogPrintf("CAS: UDP recv error was %s",
SOCKERRSTR(errnoCpy));
}
}
@@ -300,7 +301,7 @@ outBuf::flushCondition casDGIntfIO::osdSend (const char *pBufIn, bufSizeT size,
if (errnoCpy != SOCK_EWOULDBLOCK) {
char buf[64];
sockAddrToA (&dest, buf, sizeof(buf));
ca_printf (
errlogPrintf (
"CAS: UDP socket send to \"%s\" failed because \"%s\"\n",
buf, SOCKERRSTR(errnoCpy));
}
@@ -311,7 +312,7 @@ outBuf::flushCondition casDGIntfIO::osdSend (const char *pBufIn, bufSizeT size,
//
// casDGIntfIO::incommingBytesPresent()
//
// OK to return a size of one here when a datagram is present, and
// ok to return a size of one here when a datagram is present, and
// zero otherwise.
//
bufSizeT casDGIntfIO::incommingBytesPresent () const
@@ -321,7 +322,7 @@ bufSizeT casDGIntfIO::incommingBytesPresent () const
status = socket_ioctl (this->sock, FIONREAD, &nchars);
if (status<0) {
ca_printf ("CAS: FIONREAD failed because \"%s\"\n",
errlogPrintf ("CAS: FIONREAD failed because \"%s\"\n",
SOCKERRSTR(SOCKERRNO));
return 0u;
}
@@ -333,35 +334,54 @@ bufSizeT casDGIntfIO::incommingBytesPresent () const
}
}
//
// casDGIntfIO::sendBeacon()
//
void casDGIntfIO::sendBeaconIO (char &msg, unsigned length, aitUint16 &m_port)
void casDGIntfIO::sendBeaconIO (char &msg, unsigned length, aitUint16 &portField, aitUint32 &addrField)
{
caAddrNode *pAddr;
int status;
//
// the broadcast bound socket is not used here because
// it will have the wrong source address.
//
for (pAddr = (caAddrNode *)ellFirst(&this->beaconAddrList);
pAddr; pAddr = (caAddrNode *)ellNext(&pAddr->node)) {
m_port = htons (this->dgPort);
status = sendto (this->sock, &msg, length, 0,
&pAddr->destAddr.sa, sizeof(pAddr->destAddr.sa));
if (status < 0) {
char buf[64];
int errnoCpy = SOCKERRNO;
caNetAddr addr = this->serverAddress ();
struct sockaddr_in inetAddr = addr.getSockIP();
osiSockAddrNode *pAddr;
int status;
char buf[64];
ipAddrToA(&pAddr->destAddr.in, buf, sizeof(buf));
ca_printf(
"CAS:beacon error was \"%s\" dest=%s sock=%d\n",
SOCKERRSTR(errnoCpy), buf, this->sock);
}
}
portField = htons (inetAddr.sin_port); // the TCP port
for (pAddr = (osiSockAddrNode *)ellFirst(&this->beaconAddrList);
pAddr; pAddr = (osiSockAddrNode *)ellNext(&pAddr->node)) {
status = connect (this->beaconSock, &pAddr->addr.sa, sizeof(pAddr->addr.sa));
if (status<0) {
ipAddrToA (&pAddr->addr.ia, buf, sizeof(buf));
errlogPrintf ( "%s: CA beacon routing (connect to \"%s\") error was \"%s\"\n",
__FILE__, buf, SOCKERRSTR(SOCKERRNO));
}
else {
osiSockAddr addr;
int size = sizeof (addr.sa);
status = getsockname (this->beaconSock, &addr.sa, &size);
if (status<0) {
errlogPrintf ( "%s: CA beacon routing (getsockname) error was \"%s\"\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
}
else if (addr.sa.sa_family==AF_INET) {
addrField = addr.ia.sin_addr.s_addr;
printf ("sending beacon specifying port %u addr %x\n", portField, addr.ia.sin_addr.s_addr);
status = sendto (this->beaconSock, &msg, length, 0,
&pAddr->addr.sa, sizeof(pAddr->addr.sa));
if (status < 0) {
ipAddrToA (&pAddr->addr.ia, buf, sizeof(buf));
errlogPrintf ( "%s: CA beacon (send to \"%s\") error was \"%s\"\n",
__FILE__, buf, SOCKERRSTR(SOCKERRNO));
}
else {
assert (status == length);
}
}
}
}
}
//
@@ -507,7 +527,7 @@ SOCKET casDGIntfIO::makeSockDG ()
status = setsockopt(
newSock,
SOL_SOCKET,
SO_REUSEADDR,
s SO_REUSEADDR,
(char *) &yes,
sizeof (yes));
if (status<0) {

View File

@@ -32,7 +32,8 @@ public:
bool validBCastFD () const;
void xSetNonBlocking ();
void sendBeaconIO (char &msg, bufSizeT length, aitUint16 &m_port);
void sendBeaconIO (char &msg, bufSizeT length,
aitUint16 &portField, aitUint32 &addrField);
casIOState state () const;
outBuf::flushCondition osdSend (const char *pBuf, bufSizeT nBytesReq,
@@ -50,6 +51,7 @@ private:
ELLLIST beaconAddrList;
SOCKET sock;
SOCKET bcastRecvSock; // fix for solaris bug
SOCKET beaconSock; // allow connect
unsigned short dgPort;
static SOCKET makeSockDG ();

View File

@@ -2,7 +2,6 @@
#ifndef casIODILh
#define casIODILh
#include "bsdSocketResource.h"
//
// casDGIntfIO::getFD()

View File

@@ -8,7 +8,7 @@
//
#include "server.h"
#include "bsdSocketResource.h"
//
// 5 appears to be a TCP/IP built in maximum
@@ -49,7 +49,7 @@ casIntfIO::casIntfIO (const caNetAddr &addrIn) :
(char *) &yes,
sizeof (yes));
if (status<0) {
ca_printf("CAS: server set SO_REUSEADDR failed? %s\n",
errlogPrintf("CAS: server set SO_REUSEADDR failed? %s\n",
SOCKERRSTR(SOCKERRNO));
socket_close (this->sock);
throw S_cas_internal;
@@ -88,7 +88,7 @@ casIntfIO::casIntfIO (const caNetAddr &addrIn) :
status = getsockname (this->sock,
(struct sockaddr *)&this->addr, &addrSize);
if (status) {
ca_printf("CAS: getsockname() error %s\n",
errlogPrintf("CAS: getsockname() error %s\n",
SOCKERRSTR(SOCKERRNO));
socket_close (this->sock);
throw S_cas_internal;
@@ -102,7 +102,7 @@ casIntfIO::casIntfIO (const caNetAddr &addrIn) :
status = listen(this->sock, caServerConnectPendQueueSize);
if(status < 0) {
ca_printf("CAS: listen() error %s\n", SOCKERRSTR(SOCKERRNO));
errlogPrintf("CAS: listen() error %s\n", SOCKERRSTR(SOCKERRNO));
socket_close (this->sock);
throw S_cas_internal;
}
@@ -135,14 +135,14 @@ casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const
if (newSock==INVALID_SOCKET) {
int errnoCpy = SOCKERRNO;
if (errnoCpy!=SOCK_EWOULDBLOCK) {
ca_printf ("CAS: %s accept error %s\n",
errlogPrintf ("CAS: %s accept error %s\n",
__FILE__,SOCKERRSTR(errnoCpy));
}
return NULL;
}
else if (sizeof(newAddr)>(size_t)length) {
socket_close(newSock);
ca_printf("CAS: accept returned bad address len?\n");
errlogPrintf("CAS: accept returned bad address len?\n");
return NULL;
}
@@ -158,7 +158,7 @@ casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const
char pName[64u];
pOS->clientHostName (pName, sizeof (pName));
ca_printf("CAS: allocated client object for \"%s\"\n", pName);
errlogPrintf("CAS: allocated client object for \"%s\"\n", pName);
}
}
return pOS;
@@ -174,7 +174,7 @@ void casIntfIO::setNonBlocking()
status = socket_ioctl(this->sock, FIONBIO, &yes);
if (status<0) {
ca_printf(
errlogPrintf(
"%s:CAS: server non blocking IO set fail because \"%s\"\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
}

View File

@@ -5,6 +5,10 @@
//
//
// $Log$
// Revision 1.19 1999/09/02 21:50:28 jhill
// o changed UDP to non-blocking IO
// o cleaned up (consolodated) UDP interface class structure
//
// Revision 1.18 1998/12/18 18:58:20 jhill
// fixed warning
//
@@ -65,7 +69,6 @@
//
#include "server.h"
#include "bsdSocketResource.h"
//
// casStreamIO::casStreamIO()
@@ -88,7 +91,7 @@ casStreamIO::casStreamIO(caServerI &cas, const ioArgsToNewStreamIO &args) :
(char *)&yes,
sizeof(yes));
if (status<0) {
ca_printf(
errlogPrintf(
"CAS: %s TCP_NODELAY option set failed %s\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
throw S_cas_internal;
@@ -105,7 +108,7 @@ casStreamIO::casStreamIO(caServerI &cas, const ioArgsToNewStreamIO &args) :
(char *)&yes,
sizeof(yes));
if (status<0) {
ca_printf(
errlogPrintf(
"CAS: %s SO_KEEPALIVE option set failed %s\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
throw S_cas_internal;
@@ -132,7 +135,7 @@ casStreamIO::casStreamIO(caServerI &cas, const ioArgsToNewStreamIO &args) :
(char *)&i,
sizeof(i));
if(status < 0){
ca_printf("CAS: SO_SNDBUF set failed\n");
errlogPrintf("CAS: SO_SNDBUF set failed\n");
throw S_cas_internal;
}
i = MAX_MSG_SIZE;
@@ -143,7 +146,7 @@ casStreamIO::casStreamIO(caServerI &cas, const ioArgsToNewStreamIO &args) :
(char *)&i,
sizeof(i));
if(status < 0){
ca_printf("CAS: SO_RCVBUF set failed\n");
errlogPrintf("CAS: SO_RCVBUF set failed\n");
throw S_cas_internal;
}
#endif
@@ -180,11 +183,14 @@ outBuf::flushCondition casStreamIO::osdSend (const char *pInBuf, bufSizeT nBytes
int errnoCpy = SOCKERRNO;
ipAddrToA (&this->addr, buf, sizeof(buf));
ca_printf(
errlogPrintf(
"CAS: TCP socket send to \"%s\" failed because \"%s\"\n",
buf, SOCKERRSTR(errnoCpy));
return outBuf::flushDisconnect;
}
else {
return outBuf::flushNone;
}
return outBuf::flushNone;
}
nBytesActual = (bufSizeT) status;
return outBuf::flushProgress;
@@ -211,7 +217,7 @@ inBuf::fillCondition casStreamIO::osdRecv (char *pInBuf, bufSizeT nBytes,
}
else {
ipAddrToA (&this->addr, buf, sizeof(buf));
ca_printf(
errlogPrintf(
"CAS: client %s disconnected because \"%s\"\n",
buf, SOCKERRSTR(myerrno));
return casFillDisconnect;
@@ -251,7 +257,7 @@ void casStreamIO::xSetNonBlocking()
this->blockingFlag = xIsntBlocking;
}
else {
ca_printf("%s:CAS: TCP non blocking IO set fail because \"%s\"\n",
errlogPrintf("%s:CAS: TCP non blocking IO set fail because \"%s\"\n",
__FILE__, SOCKERRSTR(SOCKERRNO));
throw S_cas_internal;
}
@@ -279,7 +285,7 @@ bufSizeT casStreamIO::incommingBytesPresent() const
int errnoCpy = SOCKERRNO;
ipAddrToA (&this->addr, buf, sizeof(buf) );
ca_printf ("CAS: FIONREAD for %s failed because \"%s\"\n",
errlogPrintf ("CAS: FIONREAD for %s failed because \"%s\"\n",
buf, SOCKERRSTR(errnoCpy));
return 0u;
}

View File

@@ -5,6 +5,9 @@
*
*
* $Log$
* Revision 1.2 1996/09/16 18:27:09 jhill
* vxWorks port changes
*
* Revision 1.1 1996/09/04 22:06:43 jhill
* installed
*
@@ -62,7 +65,7 @@ caStatus caServerOS::init()
{
this->pBTmr = new casBeaconTimer((*this)->getBeaconPeriod(), *this);
if (!this->pBTmr) {
ca_printf("CAS: Unable to start server beacon\n");
errlogPrintf("CAS: Unable to start server beacon\n");
return S_cas_noMemory;
}

View File

@@ -7,6 +7,10 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.6 1999/09/02 21:50:29 jhill
// o changed UDP to non-blocking IO
// o cleaned up (consolodated) UDP interface class structure
//
// Revision 1.5 1997/08/05 00:47:26 jhill
// fixed warnings
//
@@ -30,9 +34,6 @@
#ifndef includeCASOSDH
#define includeCASOSDH
#include "osiMutex.h"
#include "osiTimer.h"
class caServerI;
class caServerOS;