Compare commits

...

13 Commits

Author SHA1 Message Date
Andrew Johnson
5097ac3230 Set SNAPSHOT for 3.14.12.6 2016-12-09 13:48:55 -06:00
Andrew Johnson
8d7bf52e51 One more cppcheck issue fixed 2016-12-09 11:17:43 -06:00
Andrew Johnson
1cb75ebb6e asLib message buffer too small (Freddie Akeroyd) 2016-12-08 13:57:23 -06:00
Andrew Johnson
94397b52fc Resolve some cppcheck errors & warnings 2016-12-07 13:53:26 -06:00
Andrew Johnson
7fe152ce1b Merge Bruce Hill's pcas-deadlock-fix-3.14 branch 2016-12-07 10:43:06 -06:00
Bruce Hill
d3568605ce Fetch nativeCount() in casChannelI constructor to avoid deadlock
if we fetch it from eventSysProcess()
2016-12-06 13:43:59 -08:00
Andrew Johnson
666721c7ad Document caput scalar arg's, update usage docs 2016-12-06 12:16:35 -06:00
0f7f4710c6 PCAS dynamic array support for GDD container types 2016-11-30 11:58:24 -06:00
Andrew Johnson
f1439f8b1c Fix epicsStdioTest for MS 2015 compiler 2016-11-15 09:56:42 -06:00
Andrew Johnson
aa6e976f92 Add .local includes to makeBaseApp templates 2016-11-04 17:18:14 -05:00
Andrew Johnson
67daaaa9b7 Set snapshot to -rc1-DEV 2016-10-31 17:06:19 -05:00
Michael Davidsaver
428268a71e rsrv: avoid strlen() on possible unterminated strings
Detect these w/o risk of SIGSEGV
2014-01-11 10:59:57 -05:00
Michael Davidsaver
746c739769 add epicsStrnLen()
Base currently requires only POSIX 2001 while
strnlen() is part of POSIX 2008.
2014-01-11 10:58:39 -05:00
31 changed files with 494 additions and 408 deletions

View File

@@ -36,11 +36,11 @@ EPICS_PATCH_LEVEL = 6
#EPICS_DEV_SNAPSHOT=-pre1-DEV
#EPICS_DEV_SNAPSHOT=-pre2
#EPICS_DEV_SNAPSHOT=-pre2-DEV
EPICS_DEV_SNAPSHOT=-rc1
#EPICS_DEV_SNAPSHOT=-rc1
#EPICS_DEV_SNAPSHOT=-rc1-DEV
#EPICS_DEV_SNAPSHOT=-rc2
#EPICS_DEV_SNAPSHOT=-rc2-DEV
#EPICS_DEV_SNAPSHOT=
EPICS_DEV_SNAPSHOT=
# No changes should be needed below here

View File

@@ -489,7 +489,7 @@ exitHandler(void)
rtems_task
Init (rtems_task_argument ignored)
{
int i;
int result;
char *argv[3] = { NULL, NULL, NULL };
char *cp;
rtems_task_priority newpri;
@@ -612,8 +612,8 @@ Init (rtems_task_argument ignored)
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
atexit(exitHandler);
i = main ((sizeof argv / sizeof argv[0]) - 1, argv);
result = main ((sizeof argv / sizeof argv[0]) - 1, argv);
printf ("***** IOC application terminating *****\n");
epicsThreadSleep(1.0);
epicsExit(0);
epicsExit(result);
}

View File

@@ -68,7 +68,7 @@ INP{link} {
\n { line_num ++;}
. {
char message[20];
char message[40];
YY_BUFFER_STATE *dummy=0;
sprintf(message,"invalid character '%c'",yytext[0]);

View File

@@ -1146,16 +1146,10 @@ the output.</p>
<td>Wide mode "name timestamp value stat sevr" (read PVs as
DBR_TIME_xxx)</td>
</tr>
<tr>
<td>-n</td>
<td>Print DBF_ENUM values as number (default are enum strings)</td>
</tr>
<tr>
<td>-d &lt;type&gt;</td>
<td>Request specific dbr type; use string (DBR_ prefix may be omitted)
<p>or number of one of the following types:</p>
<td>Request specific dbr type; use string (DBR_ prefix may be omitted)<br>
or number of one of the following types:<br>
<table border="1">
<tbody>
<tr>
@@ -1272,6 +1266,14 @@ the output.</p>
</table>
</td>
</tr>
<tr>
<td></td>
<td><strong>Enum format:</strong></td>
</tr>
<tr>
<td>-n</td>
<td>Print DBF_ENUM value as number (default is enum string)</td>
</tr>
<tr>
<td></td>
<td><strong>Arrays:</strong></td>
@@ -1303,15 +1305,15 @@ the output.</p>
</tr>
<tr>
<td>-e &lt;nr&gt;</td>
<td>Use %e format, with &lt;nr&gt; digits after the decimal point</td>
<td>Use %e format, with a precision of &lt;nr&gt; digits</td>
</tr>
<tr>
<td>-f &lt;nr&gt;</td>
<td>Use %f format, with &lt;nr&gt; digits after the decimal point</td>
<td>Use %f format, with a precision of &lt;nr&gt; digits</td>
</tr>
<tr>
<td>-g &lt;nr&gt;</td>
<td>Use %g format, with &lt;nr&gt; digits after the decimal point</td>
<td>Use %g format, with a precision of &lt;nr&gt; digits</td>
</tr>
<tr>
<td>-s</td>
@@ -1349,6 +1351,14 @@ the output.</p>
<td>-0b</td>
<td>Print as binary number</td>
</tr>
<tr>
<td></td>
<td><strong>Alternate output field separator:</strong></td>
</tr>
<tr>
<td>-F &lt;ofs&gt;</td>
<td>Use &lt;ofs&gt; as an alternate output field separator</td>
</tr>
</tbody>
</table>
@@ -1381,9 +1391,10 @@ the output.</p>
<td>Wait time, specifies longer CA timeout, default is 1.0 second</td>
</tr>
<tr>
<td>-m &lt;mask&gt;</td>
<td>Specify CA event mask to use, with &lt;mask&gt; being any combination
of 'v' (value), 'a' (alarm), 'l' (log), 'p' (property). Default: va</td>
<td>-m &lt;msk&gt;</td>
<td>Specify CA event mask to use. &lt;msk&gt; is any combination of<br>
'v' (value), 'a' (alarm), 'l' (log/archive), 'p' (property).<br>
Default event mask is 'va'</td>
</tr>
<tr>
<td>-p &lt;prio&gt;</td>
@@ -1405,8 +1416,8 @@ the output.</p>
'n' = no timestamps<br>
'r' = relative timestamps (time elapsed since start of program)<br>
'i' = incremental timestamps (time elapsed since last update)<br>
'I' = incremental timestamps (time elapsed since last update, by
channel)</td>
'I' = incremental timestamps (time since last update, by channel)<br>
'r', 'i' or 'I' require 's' or 'c' to select the time source</td>
</tr>
<tr>
<td></td>
@@ -1414,7 +1425,7 @@ the output.</p>
</tr>
<tr>
<td>-n</td>
<td>Print DBF_ENUM values as number (default are enum strings)</td>
<td>Print DBF_ENUM values as number (default is enum string)</td>
</tr>
<tr>
<td></td>
@@ -1422,16 +1433,15 @@ the output.</p>
</tr>
<tr>
<td></td>
<td>Value format: Print number of requested values, then list of
values</td>
<td>Array values: Print number of elements, then list of values</td>
</tr>
<tr>
<td>Default:</td>
<td>Print all values</td>
<td>Default: Request and print all elements (dynamic arrays supported)</td>
</tr>
<tr>
<td>-# &lt;count&gt;</td>
<td>Print first &lt;count&gt; elements of an array</td>
<td>-# &lt;num&gt;</td>
<td>Request and print up to &lt;num&gt; elements</td>
</tr>
<tr>
<td>-S</td>
@@ -1439,23 +1449,23 @@ the output.</p>
</tr>
<tr>
<td></td>
<td><strong>Floating point type format:</strong></td>
<td><strong>Floating point format:</strong></td>
</tr>
<tr>
<td>Default:</td>
<td>Use %g format</td>
</tr>
<tr>
<td>-e &lt;nr&gt;</td>
<td>Use %e format, with &lt;nr&gt; digits after the decimal point</td>
<td>-e &lt;num&gt;</td>
<td>Use %e format, with a precision of &lt;num&gt; digits</td>
</tr>
<tr>
<td>-f &lt;nr&gt;</td>
<td>Use %f format, with &lt;nr&gt; digits after the decimal point</td>
<td>-f &lt;num&gt;</td>
<td>Use %f format, with a precision of &lt;num&gt; digits</td>
</tr>
<tr>
<td>-g &lt;nr&gt;</td>
<td>Use %g format, with &lt;nr&gt; digits after the decimal point</td>
<td>-g &lt;num&gt;</td>
<td>Use %g format, with a precision of &lt;num&gt; digits</td>
</tr>
<tr>
<td>-s</td>
@@ -1497,21 +1507,27 @@ the output.</p>
</table>
<h3><a name="caput">caput</a></h3>
<pre>caput [options] &lt;PV name&gt; &lt;value&gt;
<pre>caput [options] &lt;PV name&gt; &lt;value&gt; ...
caput -a [options] &lt;PV name&gt; &lt;no of elements&gt; &lt;value&gt; ...</pre>
<h4>Description</h4>
<p>Put value to a PV.</p>
<p>The specified value is written to the PV (as a string). The PV value is read
before and after the write operation and printed as "Old" and "new" values on
stdout.</p>
<p>The specified value is written to the PV (as a string). The PV's value is
read before and after the write operation and printed as "Old" and "New" values
on stdout.</p>
<p>The array variant writes an array to the specified PV. The first numeric
argument specifying the number of array elements is kept for compatibility with
the array data format of caget - the actual number of values specified on the
command line is used.</p>
<p>There are two variants to the arguments for this command. For the scalar
variant without the <code>-a</code> flag, all the value arguments provided after
the PV name are concatenated with a single space character between them, and the
resulting string (up to 40 characters long unless the <code>-S</code> flag is
given) is written to the specified PV.</p>
<p>The array variant with the <code>-a</code> flag writes an array of string
values to the specified PV. The numeric argument giving the number of array
elements is actually ignored, the array length to be written is actually
controlled by the number of values provided on the command line.</p>
<table border="1">
<caption></caption>
@@ -1550,12 +1566,16 @@ command line is used.</p>
<td>-t</td>
<td>Terse mode - print only successfully written value, without name</td>
</tr>
<tr>
<td>-l</td>
<td>Long mode "name timestamp value stat sevr" (read PVs as DBR_TIME_xxx)</td>
</tr>
<tr>
<td></td>
<td><strong>Enum Format:</strong></td>
</tr>
<tr>
<td></td>
<td>Default:</td>
<td>Auto - try value as ENUM string, then as index number</td>
</tr>
<tr>
@@ -1571,17 +1591,24 @@ command line is used.</p>
<td><strong>Arrays:</strong></td>
</tr>
<tr>
<td>-a</td>
<td>Put array data</td>
<td>Default:</td>
<td>Put scalar</td>
</tr>
<tr>
<td></td>
<td>Value format: Print number of requested values, then list of
values</td>
<td>Value format: all value arguments concatenated with spaces</td>
</tr>
<tr>
<td>-S</td>
<td>Put string as an array of char (long string)</td>
<td>Put string as an array of chars (long string)</td>
</tr>
<tr>
<td>-a</td>
<td>Put array</td>
</tr>
<tr>
<td></td>
<td>Value format: number of values, then list of values</td>
</tr>
</tbody>
</table>

View File

@@ -504,6 +504,7 @@ void ca_repeater ()
if ( sockerrno == SOCK_EADDRINUSE ) {
osiSockRelease ();
debugPrintf ( ( "CA Repeater: exiting because a repeater is already running\n" ) );
delete [] pBuf;
return;
}
char sockErrBuf[64];

View File

@@ -902,10 +902,12 @@ bool udpiiu::pushDatagramMsg ( epicsGuard < epicsMutex > & guard,
caHdr * pbufmsg = ( caHdr * ) &this->xmitBuf[this->nBytesInXmitBuf];
*pbufmsg = msg;
memcpy ( pbufmsg + 1, pExt, extsize );
if ( extsize != alignedExtSize ) {
char *pDest = (char *) ( pbufmsg + 1 );
memset ( pDest + extsize, '\0', alignedExtSize - extsize );
if ( extsize ) {
memcpy ( pbufmsg + 1, pExt, extsize );
if ( extsize != alignedExtSize ) {
char *pDest = (char *) ( pbufmsg + 1 );
memset ( pDest + extsize, '\0', alignedExtSize - extsize );
}
}
AlignedWireRef < epicsUInt16 > ( pbufmsg->m_postsize ) = alignedExtSize;
this->nBytesInXmitBuf += msgsize;

View File

@@ -170,7 +170,7 @@ static int parseDirectoryFP (FILE *pf, const char *pFileName)
status = aToIPAddr (hostNameStr, 0u, &ipa);
if (status) {
fprintf (pf, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n",
fprintf (stderr, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n",
hostNameStr, pFileName, pvNameStr);
return -1;
}

View File

@@ -21,6 +21,7 @@ casChannelI::casChannelI ( casCoreClient & clientIn,
casChannel & chanIn, casPVI & pvIn, ca_uint32_t cidIn ) :
privateForPV ( clientIn, *this ),
pv ( pvIn ),
maxElem( pvIn.nativeCount() ),
chan ( chanIn ),
cid ( cidIn ),
serverDeletePending ( false ),
@@ -29,7 +30,7 @@ casChannelI::casChannelI ( casCoreClient & clientIn,
}
casChannelI::~casChannelI ()
{
{
this->privateForPV.client().removeFromEventQueue (
*this, this->accessRightsEvPending );
@@ -48,7 +49,7 @@ void casChannelI::uninstallFromPV ( casEventSys & eventSys )
this->privateForPV.removeSelfFromPV ( this->pv, dest );
while ( casMonitor * pMon = dest.get () ) {
eventSys.prepareMonitorForDestroy ( *pMon );
}
}
}
void casChannelI::show ( unsigned level ) const
@@ -68,13 +69,13 @@ caStatus casChannelI::cbFunc (
{
caStatus stat = S_cas_success;
{
stat = this->privateForPV.client().accessRightsResponse (
stat = this->privateForPV.client().accessRightsResponse (
clientGuard, this );
}
if ( stat == S_cas_success ) {
this->accessRightsEvPending = false;
}
return stat;
if ( stat == S_cas_success ) {
this->accessRightsEvPending = false;
}
return stat;
}
caStatus casChannelI::read ( const casCtx & ctx, gdd & prototype )

View File

@@ -1,4 +1,3 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
@@ -31,55 +30,62 @@ class casChannelI : public tsDLNode < casChannelI >,
public:
casChannelI ( casCoreClient & clientIn, casChannel & chanIn,
casPVI & pvIn, ca_uint32_t cidIn );
~casChannelI ();
~casChannelI ();
void casChannelDestroyFromInterfaceNotify ();
const caResId getCID ();
const caResId getSID ();
const caResId getCID ();
const caResId getSID ();
void uninstallFromPV ( casEventSys & eventSys );
void installIntoPV ();
void installIO ( casAsyncIOI & );
void uninstallIO ( casAsyncIOI & );
void installMonitor ( casMonitor & mon );
casMonitor * removeMonitor ( ca_uint32_t clientIdIn );
casPVI & getPVI () const;
void clearOutstandingReads ();
void postAccessRightsEvent ();
casPVI & getPVI () const;
void clearOutstandingReads ();
void postAccessRightsEvent ();
const gddEnumStringTable & enumStringTable () const;
void setOwner ( const char * const pUserName,
const char * const pHostName );
bool readAccess () const;
ca_uint32_t getMaxElem () const;
void setOwner ( const char * const pUserName,
const char * const pHostName );
bool readAccess () const;
bool writeAccess () const;
bool confirmationRequested () const;
bool confirmationRequested () const;
caStatus read ( const casCtx & ctx, gdd & prototype );
caStatus write ( const casCtx & ctx, const gdd & value );
caStatus writeNotify ( const casCtx & ctx, const gdd & value );
void show ( unsigned level ) const;
void show ( unsigned level ) const;
private:
chanIntfForPV privateForPV;
tsDLList < casAsyncIOI > ioList;
casPVI & pv;
tsDLList < casAsyncIOI > ioList;
casPVI & pv;
ca_uint32_t maxElem;
casChannel & chan;
caResId cid; // client id
caResId cid; // client id
bool serverDeletePending;
bool accessRightsEvPending;
//epicsShareFunc virtual void destroy ();
caStatus cbFunc (
bool accessRightsEvPending;
//epicsShareFunc virtual void destroy ();
caStatus cbFunc (
casCoreClient &,
epicsGuard < casClientMutex > &,
epicsGuard < evSysMutex > & );
void postDestroyEvent ();
casChannelI ( const casChannelI & );
casChannelI & operator = ( const casChannelI & );
casChannelI ( const casChannelI & );
casChannelI & operator = ( const casChannelI & );
};
inline casPVI & casChannelI::getPVI () const
{
return this->pv;
return this->pv;
}
inline ca_uint32_t casChannelI::getMaxElem () const
{
return this->maxElem;
}
inline const caResId casChannelI::getCID ()
{
return this->cid;
return this->cid;
}
inline const caResId casChannelI::getSID ()
@@ -89,7 +95,7 @@ inline const caResId casChannelI::getSID ()
inline void casChannelI::postAccessRightsEvent ()
{
this->privateForPV.client().addToEventQueue ( *this, this->accessRightsEvPending );
this->privateForPV.client().addToEventQueue ( *this, this->accessRightsEvPending );
}
inline const gddEnumStringTable & casChannelI::enumStringTable () const
@@ -108,7 +114,7 @@ inline void casChannelI::clearOutstandingReads ()
}
inline void casChannelI::setOwner ( const char * const pUserName,
const char * const pHostName )
const char * const pHostName )
{
this->chan.setOwner ( pUserName, pHostName );
}

View File

@@ -24,39 +24,39 @@
casDGClient::pCASMsgHandler const casDGClient::msgHandlers[] =
{
& casDGClient::versionAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::versionAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::searchAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::echoAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::echoAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction
};
//
@@ -84,7 +84,7 @@ casDGClient::~casDGClient()
//
void casDGClient::destroy()
{
printf("Attempt to destroy the DG client was ignored\n");
printf("Attempt to destroy the DG client was ignored\n");
}
//
@@ -92,16 +92,16 @@ void casDGClient::destroy()
//
void casDGClient::show (unsigned level) const
{
printf ( "casDGClient at %p\n",
printf ( "casDGClient at %p\n",
static_cast <const void *> ( this ) );
if (level>=1u) {
char buf[64];
this->hostName (buf, sizeof(buf));
printf ("Client Host=%s\n", buf);
if (level>=1u) {
char buf[64];
this->hostName (buf, sizeof(buf));
printf ("Client Host=%s\n", buf);
this->casCoreClient::show ( level - 1u );
this->in.show ( level - 1u );
this->out.show ( level - 1u );
}
}
}
//
@@ -109,7 +109,7 @@ void casDGClient::show (unsigned level) const
//
caStatus casDGClient::uknownMessageAction ()
{
const caHdrLargeArray * mp = this->ctx.getMsg();
const caHdrLargeArray * mp = this->ctx.getMsg();
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
@@ -117,7 +117,7 @@ caStatus casDGClient::uknownMessageAction ()
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"bad request code=%u in DG\n", mp->m_cmmd );
return S_cas_badProtocol;
return S_cas_badProtocol;
}
//
@@ -125,9 +125,9 @@ caStatus casDGClient::uknownMessageAction ()
//
caStatus casDGClient::searchAction()
{
const caHdrLargeArray *mp = this->ctx.getMsg();
const caHdrLargeArray *mp = this->ctx.getMsg();
const char *pChanName = static_cast <char * > ( this->ctx.getData() );
caStatus status;
caStatus status;
//
// check the sanity of the message
@@ -135,7 +135,7 @@ caStatus casDGClient::searchAction()
if ( mp->m_postsize <= 1 ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"empty PV name extension in UDP search request?\n" );
return S_cas_success;
}
@@ -143,7 +143,7 @@ caStatus casDGClient::searchAction()
if ( pChanName[0] == '\0' ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"zero length PV name in UDP search request?\n" );
return S_cas_success;
}
@@ -155,56 +155,56 @@ caStatus casDGClient::searchAction()
if ( i <= 1 ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"unterminated PV name in UDP search request?\n" );
return S_cas_success;
}
}
if ( this->getCAS().getDebugLevel() > 6u ) {
char pHostName[64u];
this->hostName ( pHostName, sizeof ( pHostName ) );
printf ( "\"%s\" is searching for \"%s\"\n",
if ( this->getCAS().getDebugLevel() > 6u ) {
char pHostName[64u];
this->hostName ( pHostName, sizeof ( pHostName ) );
printf ( "\"%s\" is searching for \"%s\"\n",
pHostName, pChanName );
}
}
//
// verify that we have sufficent memory for a PV and a
// monitor prior to calling PV exist test so that when
// the server runs out of memory we dont reply to
// search requests, and therefore dont thrash through
// caServer::pvExistTest() and casCreatePV::pvAttach()
//
//
// verify that we have sufficent memory for a PV and a
// monitor prior to calling PV exist test so that when
// the server runs out of memory we dont reply to
// search requests, and therefore dont thrash through
// caServer::pvExistTest() and casCreatePV::pvAttach()
//
if ( ! osiSufficentSpaceInPool ( 0 ) ) {
return S_cas_success;
}
//
// ask the server tool if this PV exists
//
this->userStartedAsyncIO = false;
pvExistReturn pver =
this->getCAS()->pvExistTest ( this->ctx, this->lastRecvAddr, pChanName );
//
// ask the server tool if this PV exists
//
this->userStartedAsyncIO = false;
pvExistReturn pver =
this->getCAS()->pvExistTest ( this->ctx, this->lastRecvAddr, pChanName );
//
// prevent problems when they initiate
// async IO but dont return status
// indicating so (and vise versa)
//
if ( this->userStartedAsyncIO ) {
//
// prevent problems when they initiate
// async IO but dont return status
// indicating so (and vise versa)
//
if ( this->userStartedAsyncIO ) {
if ( pver.getStatus() != pverAsyncCompletion ) {
errMessage (S_cas_badParameter,
"- assuming asynch IO status from caServer::pvExistTest()");
errMessage (S_cas_badParameter,
"- assuming asynch IO status from caServer::pvExistTest()");
}
status = S_cas_success;
}
else {
//
// otherwise we assume sync IO operation was initiated
//
}
else {
//
// otherwise we assume sync IO operation was initiated
//
switch ( pver.getStatus() ) {
case pverExistsHere:
status = this->searchResponse (*mp, pver);
status = this->searchResponse (*mp, pver);
break;
case pverDoesNotExistHere:
@@ -212,18 +212,18 @@ caStatus casDGClient::searchAction()
break;
case pverAsyncCompletion:
errMessage (S_cas_badParameter,
"- unexpected asynch IO status from caServer::pvExistTest() ignored");
errMessage (S_cas_badParameter,
"- unexpected asynch IO status from caServer::pvExistTest() ignored");
status = S_cas_success;
break;
default:
errMessage (S_cas_badParameter,
"- invalid return from caServer::pvExistTest() ignored");
errMessage (S_cas_badParameter,
"- invalid return from caServer::pvExistTest() ignored");
status = S_cas_success;
break;
}
}
}
}
return status;
}
@@ -340,21 +340,21 @@ caStatus casDGClient::searchResponse ( const caHdrLargeArray & msg,
}
//
// casDGClient::searchFailResponse()
// (only when requested by the client
// - when it isnt a reply to a broadcast)
// casDGClient::searchFailResponse()
// (only when requested by the client
// - when it isnt a reply to a broadcast)
//
caStatus casDGClient::searchFailResponse ( const caHdrLargeArray * mp )
{
int status;
int status;
epicsGuard < epicsMutex > guard ( this->mutex );
status = this->out.copyInHeader ( CA_PROTO_NOT_FOUND, 0,
mp->m_dataType, mp->m_count, mp->m_cid, mp->m_available, 0 );
this->out.commitMsg ();
this->out.commitMsg ();
return S_cas_success;
return S_cas_success;
}
/*
@@ -362,7 +362,7 @@ caStatus casDGClient::searchFailResponse ( const caHdrLargeArray * mp )
*/
caStatus casDGClient::versionAction ()
{
const caHdrLargeArray * mp = this->ctx.getMsg();
const caHdrLargeArray * mp = this->ctx.getMsg();
if ( mp->m_count != 0 ) {
this->minor_version_number = static_cast <ca_uint16_t> ( mp->m_count );
@@ -373,7 +373,7 @@ caStatus casDGClient::versionAction ()
this->seqNoOfReq = 0;
}
}
return S_cas_success;
return S_cas_success;
}
//
@@ -382,25 +382,25 @@ caStatus casDGClient::versionAction ()
//
void casDGClient::sendBeacon ( ca_uint32_t beaconNumber )
{
union {
caHdr msg;
char buf;
};
union {
caHdr msg;
char buf;
};
//
// create the message
//
memset ( & buf, 0, sizeof ( msg ) );
//
// create the message
//
memset ( & buf, 0, sizeof ( msg ) );
AlignedWireRef < epicsUInt16 > ( msg.m_cmmd ) = CA_PROTO_RSRV_IS_UP;
AlignedWireRef < epicsUInt16 > ( msg.m_dataType ) = CA_MINOR_PROTOCOL_REVISION;
AlignedWireRef < epicsUInt32 > ( msg.m_cid ) = beaconNumber;
//
// 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, msg.m_available );
//
this->sendBeaconIO ( buf, sizeof (msg), msg.m_count, msg.m_available );
}
//
@@ -421,8 +421,8 @@ outBufClient::flushCondition casDGClient::xSend ( char *pBufIn,
if ( pHdr->cadg_addr.isValid() ) {
outBufClient::flushCondition stat =
this->osdSend ( pDG, sizeDG, pHdr->cadg_addr );
if ( stat != outBufClient::flushProgress ) {
this->osdSend ( pDG, sizeDG, pHdr->cadg_addr );
if ( stat != outBufClient::flushProgress ) {
break;
}
}
@@ -431,10 +431,10 @@ outBufClient::flushCondition casDGClient::xSend ( char *pBufIn,
}
if ( totalBytes ) {
//
// !! this time fetch may be slowing things down !!
//
//this->lastSendTS = epicsTime::getCurrent();
//
// !! this time fetch may be slowing things down !!
//
//this->lastSendTS = epicsTime::getCurrent();
nBytesSent = totalBytes;
return outBufClient::flushProgress;
}
@@ -457,16 +457,16 @@ inBufClient::fillCondition casDGClient::xRecv (char *pBufIn, bufSizeT nBytesToRe
while (pAfter-pCurBuf >= static_cast<int>(MAX_UDP_RECV+sizeof(cadg))) {
pHdr = reinterpret_cast < cadg * > ( pCurBuf );
stat = this->osdRecv ( reinterpret_cast < char * > ( pHdr + 1 ),
stat = this->osdRecv ( reinterpret_cast < char * > ( pHdr + 1 ),
MAX_UDP_RECV, parm, nDGBytesRecv, pHdr->cadg_addr);
if (stat==casFillProgress) {
if (stat==casFillProgress) {
pHdr->cadg_nBytes = nDGBytesRecv + sizeof(*pHdr);
pCurBuf += pHdr->cadg_nBytes;
//
// !! this time fetch may be slowing things down !!
//
//this->lastRecvTS = epicsTime::getCurrent();
}
//
// !! this time fetch may be slowing things down !!
//
//this->lastRecvTS = epicsTime::getCurrent();
}
else {
break;
}
@@ -517,7 +517,7 @@ caStatus casDGClient::asyncSearchResponse (
pMsg->m_dataType = htons ( sequenceNoIsValid );
}
caStatus stat = this->searchResponse ( msg, retVal );
caStatus stat = this->searchResponse ( msg, retVal );
pRespHdr->cadg_nBytes = this->out.popCtx (outctx) + sizeof ( *pRespHdr );
if ( pRespHdr->cadg_nBytes > sizeof ( *pRespHdr ) + sizeof (caHdr) ) {
@@ -525,7 +525,7 @@ caStatus casDGClient::asyncSearchResponse (
this->out.commitRawMsg ( pRespHdr->cadg_nBytes );
}
return stat;
return stat;
}
//
@@ -655,7 +655,7 @@ caStatus casDGClient::processDG ()
//
unsigned casDGClient::getDebugLevel() const
{
return this->getCAS().getDebugLevel();
return this->getCAS().getDebugLevel();
}
//
@@ -663,7 +663,7 @@ unsigned casDGClient::getDebugLevel() const
//
caNetAddr casDGClient::fetchLastRecvAddr () const
{
return this->lastRecvAddr;
return this->lastRecvAddr;
}
//
@@ -671,7 +671,7 @@ caNetAddr casDGClient::fetchLastRecvAddr () const
//
ca_uint32_t casDGClient::datagramSequenceNumber () const
{
return this->seqNoOfReq;
return this->seqNoOfReq;
}
//
@@ -731,27 +731,27 @@ outBufClient::flushCondition casDGClient::flush ()
//
caStatus casDGClient::processMsg ()
{
int status = S_cas_success;
int status = S_cas_success;
try {
unsigned bytesLeft;
while ( ( bytesLeft = this->in.bytesPresent() ) ) {
unsigned bytesLeft;
while ( ( bytesLeft = this->in.bytesPresent() ) ) {
caHdrLargeArray msgTmp;
unsigned msgSize;
ca_uint32_t hdrSize;
char * rawMP;
{
//
// copy as raw bytes in order to avoid
// alignment problems
//
//
// copy as raw bytes in order to avoid
// alignment problems
//
caHdr smallHdr;
if ( bytesLeft < sizeof ( smallHdr ) ) {
break;
}
rawMP = this->in.msgPtr ();
memcpy ( & smallHdr, rawMP, sizeof ( smallHdr ) );
memcpy ( & smallHdr, rawMP, sizeof ( smallHdr ) );
ca_uint32_t payloadSize = AlignedWireRef < epicsUInt16 > ( smallHdr.m_postsize );
ca_uint32_t nElem = AlignedWireRef < epicsUInt16 > ( smallHdr.m_count );
@@ -800,45 +800,45 @@ caStatus casDGClient::processMsg ()
this->ctx.setMsg ( msgTmp, rawMP + hdrSize );
if ( this->getCAS().getDebugLevel() > 5u ) {
if ( this->getCAS().getDebugLevel() > 5u ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
caServerI::dumpMsg ( pHostName, "?",
caServerI::dumpMsg ( pHostName, "?",
& msgTmp, rawMP + hdrSize, 0 );
}
}
}
//
// Reset the context to the default
// (guarantees that previous message does not get mixed
// up with the current message)
//
this->ctx.setChannel ( NULL );
this->ctx.setPV ( NULL );
//
// Reset the context to the default
// (guarantees that previous message does not get mixed
// up with the current message)
//
this->ctx.setChannel ( NULL );
this->ctx.setPV ( NULL );
//
// Call protocol stub
//
//
// Call protocol stub
//
casDGClient::pCASMsgHandler pHandler;
if ( msgTmp.m_cmmd < NELEMENTS ( casDGClient::msgHandlers ) ) {
if ( msgTmp.m_cmmd < NELEMENTS ( casDGClient::msgHandlers ) ) {
pHandler = this->casDGClient::msgHandlers[msgTmp.m_cmmd];
}
}
else {
pHandler = & casDGClient::uknownMessageAction;
}
status = ( this->*pHandler ) ();
if ( status ) {
status = ( this->*pHandler ) ();
if ( status ) {
this->in.removeMsg ( this->in.bytesPresent() );
break;
}
break;
}
this->in.removeMsg ( msgSize );
}
}
}
catch ( std::exception & except ) {
this->in.removeMsg ( this->in.bytesPresent() );
status = this->sendErr (
this->sendErr (
this->ctx.getMsg(), invalidResID, ECA_INTERNAL,
"C++ exception \"%s\" in CA circuit server",
except.what () );
@@ -846,13 +846,13 @@ caStatus casDGClient::processMsg ()
}
catch (...) {
this->in.removeMsg ( this->in.bytesPresent() );
status = this->sendErr (
this->sendErr (
this->ctx.getMsg(), invalidResID, ECA_INTERNAL,
"unexpected C++ exception in CA datagram server" );
status = S_cas_internal;
}
return status;
return status;
}
//
@@ -861,24 +861,25 @@ caStatus casDGClient::processMsg ()
caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
ca_uint32_t cid, const int reportedStatus, const char *pformat, ... )
{
unsigned stringSize;
char msgBuf[1024]; /* allocate plenty of space for the message string */
if ( pformat ) {
va_list args;
va_start ( args, pformat );
int status = vsprintf ( msgBuf, pformat, args );
if ( status < 0 ) {
errPrintf (S_cas_internal, __FILE__, __LINE__,
"bad sendErr(%s)", pformat);
stringSize = 0u;
}
else {
stringSize = 1u + (unsigned) status;
}
}
else {
stringSize = 0u;
}
unsigned stringSize;
char msgBuf[1024]; /* allocate plenty of space for the message string */
if ( pformat ) {
va_list args;
va_start ( args, pformat );
int status = vsprintf ( msgBuf, pformat, args );
if ( status < 0 ) {
errPrintf (S_cas_internal, __FILE__, __LINE__,
"bad sendErr(%s)", pformat);
stringSize = 0u;
}
else {
stringSize = 1u + (unsigned) status;
}
va_end ( args );
}
else {
stringSize = 0u;
}
unsigned hdrSize = sizeof ( caHdr );
if ( ( curp->m_postsize >= 0xffff || curp->m_count >= 0xffff ) &&
@@ -929,7 +930,7 @@ caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
this->out.commitMsg ();
}
return S_cas_success;
return S_cas_success;
}
@@ -938,8 +939,8 @@ caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
//
caStatus casDGClient::echoAction ()
{
const caHdrLargeArray * mp = this->ctx.getMsg();
const void * dp = this->ctx.getData();
const caHdrLargeArray * mp = this->ctx.getMsg();
const void * dp = this->ctx.getData();
void * pPayloadOut;
epicsGuard < epicsMutex > guard ( this->mutex );
@@ -950,5 +951,5 @@ caStatus casDGClient::echoAction ()
memcpy ( pPayloadOut, dp, mp->m_postsize );
this->out.commitMsg ();
}
return S_cas_success;
return S_cas_success;
}

View File

@@ -409,7 +409,7 @@ caStatus casStrmClient::verifyRequest (casChannelI * & pChan , bool allowdyn)
//
// element count out of range ?
//
if ( ctx.msg.m_count > pChan->getPVI().nativeCount() ||
if ( ctx.msg.m_count > pChan->getMaxElem() ||
( !allowdyn && ctx.msg.m_count == 0u ) ) {
return ECA_BADCOUNT;
}
@@ -856,8 +856,20 @@ caStatus casStrmClient::monitorResponse (
casChannelI & chan, const caHdrLargeArray & msg,
const gdd & desc, const caStatus completionStatus )
{
aitUint32 elementCount = 0;
if (desc.isContainer()) {
aitUint32 index;
int gdds = gddApplicationTypeTable::app_table.mapAppToIndex
( desc.applicationType(), gddAppType_value, index );
if ( gdds ) {
return S_cas_badType;
}
elementCount = desc.getDD(index)->getDataSizeElements();
} else {
elementCount = desc.getDataSizeElements();
}
ca_uint32_t count = (msg.m_count == 0) ?
(ca_uint32_t)desc.getDataSizeElements() :
(ca_uint32_t)elementCount :
msg.m_count;
void * pPayload = 0;
@@ -883,7 +895,7 @@ caStatus casStrmClient::monitorResponse (
gdd * pDBRDD = 0;
if ( completionStatus == S_cas_success ) {
caStatus status = createDBRDD ( msg.m_dataType, count,
chan.getPVI().nativeCount(), pDBRDD );
chan.getMaxElem(), pDBRDD );
if ( status != S_cas_success ) {
caStatus ecaStatus;
if ( status == S_cas_badType ) {
@@ -1854,7 +1866,7 @@ caStatus casStrmClient::privateCreateChanResponse (
// the protocol buffer.
//
assert ( nativeTypeDBR <= 0xffff );
aitIndex nativeCount = chan.getPVI().nativeCount();
aitIndex nativeCount = chan.getMaxElem();
assert ( nativeCount <= 0xffffffff );
assert ( hdr.m_cid == chan.getCID() );
status = this->out.copyInHeader ( CA_PROTO_CREATE_CHAN, 0,
@@ -2614,7 +2626,7 @@ caStatus casStrmClient::read ()
{
gdd * pDD = 0;
caStatus status = createDBRDD ( pHdr->m_dataType, pHdr->m_count,
this->ctx.getChannel()->getPVI().nativeCount(), pDD );
this->ctx.getChannel()->getMaxElem(), pDD );
if ( status != S_cas_success ) {
return status;
}
@@ -2761,6 +2773,7 @@ caStatus casStrmClient::sendErr ( epicsGuard <casClientMutex> &,
else {
stringSize = 1u + (unsigned) status;
}
va_end ( args );
}
else {
stringSize = 0u;

View File

@@ -56,7 +56,7 @@ static epicsEventId epId;
void usage (void)
{
fprintf (stderr, "\nUsage: caput [options] <PV name> <PV value>\n"
fprintf (stderr, "\nUsage: caput [options] <PV name> <PV value> ...\n"
" caput -a [options] <PV name> <no of values> <PV value> ...\n\n"
" -h: Help: Print this message\n"
"Channel Access options:\n"
@@ -71,9 +71,11 @@ void usage (void)
" -n: Force interpretation of values as numbers\n"
" -s: Force interpretation of values as strings\n"
"Arrays:\n"
" Default: Put scalar\n"
" Value format: all value arguments concatenated with spaces\n"
" -S: Put string as an array of chars (long string)\n"
" -a: Put array\n"
" Value format: number of requested values, then list of values\n"
" -S: Put string as an array of char (long string)\n"
" Value format: number of values, then list of values\n"
"\nExample: caput my_channel 1.2\n"
" (puts 1.2 to my_channel)\n\n"
, DEFAULT_TIMEOUT, CA_PRIORITY_MAX);

View File

@@ -126,8 +126,8 @@ long dbcar(char *precordname, int level)
precord->name,
pdbFldDes->name,
plink->value.pv_link.pvname,
pca->nDisconnect,
pca->nNoWrite);
pca ? pca->nDisconnect : 0,
pca ? pca->nNoWrite : 0);
}
}
}

View File

@@ -3941,10 +3941,9 @@ static long putFloatString(
char *pdest=(char *)(paddr->pfield);
long status = 0;
int precision = 6;
struct rset *prset = 0;
struct rset *prset = dbGetRset(paddr);
short size=paddr->field_size;
if(paddr) prset = dbGetRset(paddr);
if(prset && (prset->get_precision))
status = (*prset->get_precision)(paddr,&precision);
if(nRequest==1 && offset==0) {
@@ -4152,10 +4151,9 @@ static long putDoubleString(
char *pdest=(char *)(paddr->pfield);
long status = 0;
int precision = 6;
struct rset *prset = 0;
struct rset *prset = dbGetRset(paddr);
short size=paddr->field_size;
if(paddr) prset = dbGetRset(paddr);
if(prset && (prset->get_precision))
status = (*prset->get_precision)(paddr,&precision);
if(nRequest==1 && offset==0) {

View File

@@ -699,8 +699,9 @@ int epicsShareAPI tpn(char *pname,char *pvalue)
return(-1);
}
ppn = calloc(1,sizeof(putNotify));
if(!pdbaddr) {
if(!ppn) {
printf("calloc failed\n");
free((void *)pdbaddr);
return(-1);
}
ppn->paddr = pdbaddr;
@@ -708,13 +709,14 @@ int epicsShareAPI tpn(char *pname,char *pvalue)
ppn->nRequest = 1;
if(dbPutNotifyMapType(ppn,DBR_STRING)) {
printf("dbPutNotifyMapType failed\n");
printf("calloc failed\n");
free((void *)pdbaddr);
return(-1);
}
ppn->userCallback = tpnCallback;
ptpnInfo = calloc(1,sizeof(tpnInfo));
if(!ptpnInfo) {
printf("calloc failed\n");
free((void *)pdbaddr);
return(-1);
}
ptpnInfo->ppn = ppn;

View File

@@ -229,24 +229,25 @@ static long dbReadCOM(DBBASE **ppdbbase,const char *filename, FILE *fp,
}
}
pinputFile = dbCalloc(1,sizeof(inputFile));
if(filename) {
pinputFile->filename = macEnvExpand(filename);
if (filename) {
pinputFile->filename = macEnvExpand(filename);
}
if(!fp) {
FILE *fp1;
if (!fp) {
FILE *fp1 = 0;
if(pinputFile->filename) pinputFile->path = dbOpenFile(pdbbase,pinputFile->filename,&fp1);
if(!pinputFile->filename || !fp1) {
errPrintf(0,__FILE__, __LINE__,
"dbRead opening file %s",pinputFile->filename);
free((void *)pinputFile->filename);
free((void *)pinputFile);
if (pinputFile->filename)
pinputFile->path = dbOpenFile(pdbbase, pinputFile->filename, &fp1);
if (!pinputFile->filename || !fp1) {
errPrintf(0, __FILE__, __LINE__,
"dbRead opening file %s",pinputFile->filename);
free(pinputFile->filename);
free(pinputFile);
status = -1;
goto cleanup;
}
pinputFile->fp = fp1;
}
pinputFile->fp = fp1;
} else {
pinputFile->fp = fp;
pinputFile->fp = fp;
}
pinputFile->line_num = 0;
pinputFileNow = pinputFile;

View File

@@ -308,7 +308,7 @@ void gdd::test()
pdd->convertOffsetsToAddress();
pdd->dump();
pdd->unreference();
delete buf;
delete [] buf;
}
#endif
@@ -510,7 +510,7 @@ void gddContainer::test(void)
fprintf(stderr,"=====RE-DUMP OF ORIGINAL CONTAINER:\n");
dump();
cdd1->unreference();
delete buf;
delete [] buf;
// test copy(), Dup(), copyInfo()
fprintf(stderr,"=======CREATING TEST CONTAINER FOR *COPY* TEST:\n");

View File

@@ -239,6 +239,18 @@ int epicsStrPrintEscaped(FILE *fp, const char *s, size_t len)
return nout;
}
/* Until Base requires POSIX 2008 we must provide our own implementation */
size_t epicsStrnLen(const char *s, size_t maxlen)
{
size_t i;
for (i=0; i<maxlen; i++) {
if(s[i]=='\0')
return i;
}
return i;
}
int epicsStrGlobMatch(const char *str, const char *pattern)
{
const char *cp = NULL, *mp = NULL;

View File

@@ -33,6 +33,7 @@ epicsShareFunc int epicsStrnCaseCmp(const char *s1, const char *s2, size_t len);
epicsShareFunc char * epicsStrDup(const char *s);
epicsShareFunc int epicsStrPrintEscaped(FILE *fp, const char *s, size_t n);
#define epicsStrSnPrintEscaped epicsStrnEscapedFromRaw
epicsShareFunc size_t epicsStrnLen(const char *s, size_t maxlen);
epicsShareFunc int epicsStrGlobMatch(const char *str, const char *pattern);
epicsShareFunc char * epicsStrtok_r(char *s, const char *delim, char **lasts);
epicsShareFunc unsigned int epicsStrHash(const char *str, unsigned int seed);

View File

@@ -378,7 +378,7 @@ static gtProvider * findProvider(ELLLIST *plist, epicsMutexId lock,
for (ptp = (gtProvider *)ellFirst(plist);
ptp; ptp = (gtProvider *)ellNext(&ptp->node)) {
if (ptp->priority == ptp->priority &&
if (ptp->priority == priority &&
!strcmp(ptp->name, name))
break;
}

View File

@@ -167,7 +167,7 @@ static int receiveMessage(
return -1;
}
rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay);
if ((rsize < 0) || (rsize > size))
if (rsize > size)
return -1;
memcpy(buffer, id->localBuf, rsize);
}

View File

@@ -404,8 +404,6 @@ void epicsThreadGetName (epicsThreadId id, char *name, size_t size)
struct taskVar *v;
int haveName = 0;
if (size <= 0)
return;
taskVarLock ();
for (v=taskVarHead ; v != NULL ; v=v->forw) {
if (v->id == tid) {

View File

@@ -517,13 +517,8 @@ static win32ThreadParam * epicsThreadParmCreate ( const char *pName )
pParmWIN32 = calloc ( 1, sizeof ( *pParmWIN32 ) + strlen ( pName ) + 1 );
if ( pParmWIN32 ) {
if ( pName ) {
pParmWIN32->pName = (char *) ( pParmWIN32 + 1 );
strcpy ( pParmWIN32->pName, pName );
}
else {
pParmWIN32->pName = 0;
}
pParmWIN32->pName = (char *) ( pParmWIN32 + 1 );
strcpy ( pParmWIN32->pName, pName );
pParmWIN32->isSuspended = 0;
}
return pParmWIN32;

View File

@@ -38,7 +38,14 @@ static void testEpicsSnprintf(void) {
const char *expected = exbuffer;
int size;
int rtn, rlen;
#ifdef _WIN32
#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
(defined(_MINGW) && defined(_TWO_DIGIT_EXPONENT))
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
#endif
sprintf(exbuffer, format, ivalue, fvalue, svalue);
rlen = strlen(expected)+1;
@@ -122,11 +129,7 @@ void testStdoutRedir (const char *report)
MAIN(epicsStdioTest)
{
#ifdef _WIN32
testPlan(166);
#else
testPlan(163);
#endif
testEpicsSnprintf();
testStdoutRedir("report");
return testDone();

View File

@@ -51,7 +51,7 @@ MAIN(epicsStringTest)
char *s;
int status;
testPlan(299);
testPlan(303);
testChars();
@@ -86,6 +86,11 @@ MAIN(epicsStringTest)
testOk1(epicsStrHash(abcd, 0) == epicsMemHash(abcde, 4, 0));
testOk1(epicsStrHash(abcd, 0) != epicsMemHash("abcd\0", 5, 0));
testOk1(epicsStrnLen("abcd", 5)==4);
testOk1(epicsStrnLen("abcd", 4)==4);
testOk1(epicsStrnLen("abcd", 3)==3);
testOk1(epicsStrnLen("abcd", 0)==0);
memset(result, 'x', sizeof(result));
status = epicsStrnEscapedFromRaw(result, 4, ABCD, 3);
testOk(status == 3, "epicsStrnEscapedFromRaw returned %d (exp. 3)", status);

View File

@@ -109,6 +109,7 @@ int main(int argc,char **argv)
pmynode[npv] = callocMustSucceed(1, sizeof(MYNODE), "caMonitor");
npv++;
}
fclose(fp);
SEVCHK(ca_context_create(ca_disable_preemptive_callback),"ca_context_create");
SEVCHK(ca_add_exception_event(exceptionCallback,NULL),
"ca_add_exception_event");

View File

@@ -29,3 +29,10 @@ CHECK_RELEASE = YES
# to the install location. This may be needed to boot from
# a Microsoft FTP server say, or on some NFS configurations.
#IOCS_APPL_TOP = </IOC's/absolute/path/to/install/top>
# These allow developers to override the CONFIG_SITE variable
# settings without having to modify the configure/CONFIG_SITE
# file itself.
-include $(TOP)/../CONFIG_SITE.local
-include $(TOP)/configure/CONFIG_SITE.local

View File

@@ -35,3 +35,9 @@ EPICS_BASE = _EPICS_BASE_
# Set RULES here if you want to use build rules from somewhere
# other than EPICS_BASE:
#RULES = $(MODULES)/build-rules
# These allow developers to override the RELEASE variable settings
# without having to modify the configure/RELEASE file itself.
-include $(TOP)/../RELEASE.local
-include $(TOP)/configure/RELEASE.local

View File

@@ -134,8 +134,8 @@ static long wdogInit(histogramRecord *prec)
if(prec->wdog==NULL && prec->sdel>0) {
/* initialize a watchdog timer */
pcallback = (myCallback *)(calloc(1,sizeof(myCallback)));
if (!pcallback) return -1;
pcallback->prec = prec;
if(!pcallback) return -1;
callbackSetCallback(wdogCallback,&pcallback->callback);
callbackSetUser(pcallback,&pcallback->callback);
callbackSetPriority(priorityLow,&pcallback->callback);

View File

@@ -21,6 +21,7 @@
#include "osiSock.h"
#include "osiPoolStatus.h"
#include "epicsString.h"
#include "epicsEvent.h"
#include "epicsStdio.h"
#include "epicsThread.h"
@@ -638,7 +639,7 @@ static void read_reply ( void *pArg, struct dbAddr *paddr,
static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *pClient )
{
struct channel_in_use *pciu = MPTOPCIU ( mp );
const int readAccess = asCheckGet ( pciu->asClientPVT );
int readAccess;
ca_uint32_t payloadSize;
void *pPayload;
int status;
@@ -648,6 +649,7 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p
logBadId ( pClient, mp, 0 );
return RSRV_ERROR;
}
readAccess = asCheckGet ( pciu->asClientPVT );
SEND_LOCK ( pClient );
@@ -708,7 +710,7 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p
*/
if ( mp->m_dataType == DBR_STRING && mp->m_count == 1 ) {
char * pStr = (char *) pPayload;
size_t strcnt = strlen ( pStr );
size_t strcnt = epicsStrnLen( pStr, payloadSize );
if ( strcnt < payloadSize ) {
payloadSize = ( ca_uint32_t ) ( strcnt + 1u );
}
@@ -843,7 +845,7 @@ static int write_action ( caHdrLargeArray *mp,
static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
struct client *client )
{
unsigned size;
ca_uint32_t size;
char *pName;
char *pMalloc;
int chanCount;
@@ -867,8 +869,8 @@ static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
}
pName = (char *) pPayload;
size = strlen(pName)+1;
if (size > 512) {
size = epicsStrnLen(pName, mp->m_postsize)+1;
if (size > 512 || size > mp->m_postsize) {
log_header ( "bad (very long) host name",
client, mp, pPayload, 0 );
SEND_LOCK(client);
@@ -922,7 +924,7 @@ static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
static int client_name_action ( caHdrLargeArray *mp, void *pPayload,
struct client *client )
{
unsigned size;
ca_uint32_t size;
char *pName;
char *pMalloc;
int chanCount;
@@ -946,8 +948,8 @@ static int client_name_action ( caHdrLargeArray *mp, void *pPayload,
}
pName = (char *) pPayload;
size = strlen(pName)+1;
if (size > 512) {
size = epicsStrnLen(pName, mp->m_postsize)+1;
if (size > 512 || size > mp->m_postsize) {
log_header ("a very long user name was specified",
client, mp, pPayload, 0);
SEND_LOCK(client);

View File

@@ -84,131 +84,132 @@ static int sighupPipe[2];
/*
*
* main()
* main()
*
*/
int main(void)
{
struct sockaddr_in serverAddr; /* server's address */
struct timeval timeout;
int status;
struct ioc_log_server *pserver;
struct sockaddr_in serverAddr; /* server's address */
struct timeval timeout;
int status;
struct ioc_log_server *pserver;
osiSockIoctl_t optval;
osiSockIoctl_t optval;
status = getConfig();
if(status<0){
fprintf(stderr, "iocLogServer: EPICS environment underspecified\n");
fprintf(stderr, "iocLogServer: failed to initialize\n");
return IOCLS_ERROR;
}
status = getConfig();
if (status<0) {
fprintf(stderr, "iocLogServer: EPICS environment underspecified\n");
fprintf(stderr, "iocLogServer: failed to initialize\n");
return IOCLS_ERROR;
}
pserver = (struct ioc_log_server *)
calloc(1, sizeof *pserver);
if(!pserver){
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
return IOCLS_ERROR;
}
pserver = (struct ioc_log_server *)
calloc(1, sizeof *pserver);
if (!pserver) {
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
return IOCLS_ERROR;
}
pserver->pfdctx = (void *) fdmgr_init();
if(!pserver->pfdctx){
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
return IOCLS_ERROR;
}
pserver->pfdctx = (void *) fdmgr_init();
if (!pserver->pfdctx) {
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
return IOCLS_ERROR;
}
/*
* Open the socket. Use ARPA Internet address format and stream
* sockets. Format described in <sys/socket.h>.
*/
pserver->sock = epicsSocketCreate(AF_INET, SOCK_STREAM, 0);
if (pserver->sock==INVALID_SOCKET) {
/*
* Open the socket. Use ARPA Internet address format and stream
* sockets. Format described in <sys/socket.h>.
*/
pserver->sock = epicsSocketCreate(AF_INET, SOCK_STREAM, 0);
if (pserver->sock == INVALID_SOCKET) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: sock create err: %s\n", sockErrBuf);
return IOCLS_ERROR;
}
fprintf(stderr, "iocLogServer: sock create err: %s\n", sockErrBuf);
free(pserver);
return IOCLS_ERROR;
}
epicsSocketEnableAddressReuseDuringTimeWaitState ( pserver->sock );
/* Zero the sock_addr structure */
memset((void *)&serverAddr, 0, sizeof serverAddr);
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(ioc_log_port);
/* Zero the sock_addr structure */
memset((void *)&serverAddr, 0, sizeof serverAddr);
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(ioc_log_port);
/* get server's Internet address */
status = bind ( pserver->sock,
(struct sockaddr *)&serverAddr,
sizeof (serverAddr) );
if (status<0) {
/* get server's Internet address */
status = bind ( pserver->sock,
(struct sockaddr *)&serverAddr,
sizeof (serverAddr) );
if (status < 0) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: bind err: %s\n", sockErrBuf );
fprintf (stderr,
"iocLogServer: a server is already installed on port %u?\n",
(unsigned)ioc_log_port);
return IOCLS_ERROR;
}
fprintf(stderr, "iocLogServer: bind err: %s\n", sockErrBuf );
fprintf (stderr,
"iocLogServer: a server is already installed on port %u?\n",
(unsigned)ioc_log_port);
return IOCLS_ERROR;
}
/* listen and accept new connections */
status = listen(pserver->sock, 10);
if (status<0) {
/* listen and accept new connections */
status = listen(pserver->sock, 10);
if (status < 0) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
return IOCLS_ERROR;
}
fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
return IOCLS_ERROR;
}
/*
* Set non blocking IO
* to prevent dead locks
*/
optval = TRUE;
status = socket_ioctl(
pserver->sock,
FIONBIO,
&optval);
if(status<0){
/*
* Set non blocking IO
* to prevent dead locks
*/
optval = TRUE;
status = socket_ioctl(
pserver->sock,
FIONBIO,
&optval);
if (status < 0){
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
return IOCLS_ERROR;
}
fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
return IOCLS_ERROR;
}
# ifdef UNIX
status = setupSIGHUP(pserver);
if (status<0) {
return IOCLS_ERROR;
}
# endif
# ifdef UNIX
status = setupSIGHUP(pserver);
if (status < 0) {
return IOCLS_ERROR;
}
# endif
status = openLogFile(pserver);
if (status<0) {
fprintf(stderr,
"File access problems to `%s' because `%s'\n",
ioc_log_file_name,
strerror(errno));
return IOCLS_ERROR;
}
status = openLogFile(pserver);
if (status < 0) {
fprintf(stderr,
"File access problems to `%s' because `%s'\n",
ioc_log_file_name,
strerror(errno));
return IOCLS_ERROR;
}
status = fdmgr_add_callback(
pserver->pfdctx,
pserver->sock,
fdi_read,
acceptNewClient,
pserver);
if(status<0){
fprintf(stderr,
"iocLogServer: failed to add read callback\n");
return IOCLS_ERROR;
}
status = fdmgr_add_callback(
pserver->pfdctx,
pserver->sock,
fdi_read,
acceptNewClient,
pserver);
if (status < 0) {
fprintf(stderr,
"iocLogServer: failed to add read callback\n");
return IOCLS_ERROR;
}
while(TRUE){
timeout.tv_sec = 60; /* 1 min */
timeout.tv_usec = 0;
fdmgr_pend_event(pserver->pfdctx, &timeout);
fflush(pserver->poutfile);
}
while (TRUE) {
timeout.tv_sec = 60; /* 1 min */
timeout.tv_usec = 0;
fdmgr_pend_event(pserver->pfdctx, &timeout);
fflush(pserver->poutfile);
}
}
/*
@@ -964,6 +965,7 @@ static int getDirectory(void)
"Problem reading o/p from `%s' because `%s'\n",
ioc_log_file_command,
strerror(errno));
(void) pclose(pipe);
return IOCLS_ERROR;
}
(void) pclose(pipe);