merge with iocLogClientFixes
This commit is contained in:
@@ -52,12 +52,12 @@ EPICS_MODIFICATION = 3
|
||||
|
||||
# EPICS_PATCH_LEVEL must be a number (win32 resource file requirement)
|
||||
# Not included in the official EPICS version number if zero
|
||||
EPICS_PATCH_LEVEL = 0
|
||||
EPICS_PATCH_LEVEL = 1
|
||||
|
||||
# Between official releases, the EPICS_PATCH_LEVEL gets incremented
|
||||
# and a -DEV suffix is added (similar to the Maven -SNAPSHOT versions)
|
||||
EPICS_DEV_SNAPSHOT=
|
||||
#EPICS_DEV_SNAPSHOT=-DEV
|
||||
# Immediately after an official release the EPICS_PATCH_LEVEL is incremented
|
||||
# and the -DEV suffix is added (similar to the Maven -SNAPSHOT versions)
|
||||
#EPICS_DEV_SNAPSHOT=
|
||||
EPICS_DEV_SNAPSHOT=-DEV
|
||||
#EPICS_DEV_SNAPSHOT=-pre1
|
||||
#EPICS_DEV_SNAPSHOT=-pre1-DEV
|
||||
#EPICS_DEV_SNAPSHOT=-pre2
|
||||
|
||||
@@ -20,7 +20,7 @@ release.</p>
|
||||
which should also be read to understand what has changed since an earlier
|
||||
release.</p>
|
||||
|
||||
<h1 align="center">EPICS Release 7.0.3</h1>
|
||||
<h1 align="center">EPICS Release 7.0.3.1</h1>
|
||||
|
||||
<!-- Insert new items immediately below this template ...
|
||||
|
||||
@@ -30,6 +30,18 @@ release.</p>
|
||||
|
||||
-->
|
||||
|
||||
<h3>Non-VME RTEMS targets now define pdevLibVME</h3>
|
||||
|
||||
<p>Previously IOC executables that made calls to devLib routines would fail to
|
||||
link when built for some non-VME based RTEMS targets, which would have to be
|
||||
explicitly filtered out by sites that build Base for those targets.
|
||||
<a href="https://bugs.launchpad.net/epics-base/+bug/1841692">This fix</a> makes
|
||||
that no longer necessary, all RTEMS targets should now link although the IOC
|
||||
won't be able to be used with the VME I/O on those systems (that we don't have
|
||||
VMEbus I/O support for in libCom).</p>
|
||||
|
||||
<h1 align="center">EPICS Release 7.0.3</h1>
|
||||
|
||||
<h3>epicsTimeGetCurrent() optimization</h3>
|
||||
|
||||
<p>Add a fast path to epicsTimeGetCurrent() and related calls
|
||||
|
||||
@@ -289,13 +289,20 @@ starting at <a href="#ReleaseApproval">Release Approval</a>.</p>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>Release Manager</td>
|
||||
<td>Edit and commit changes to the EPICS Base version number file and
|
||||
the embedded module version files:
|
||||
these embedded module version files:
|
||||
<ul>
|
||||
<li>configure/CONFIG_BASE_VERSION </li>
|
||||
<li>modules/libcom/configure/CONFIG_LIBCOM_VERSION</li>
|
||||
<li>modules/ca/configure/CONFIG_CA_VERSION</li>
|
||||
<li>modules/database/configure/CONFIG_DATABASE_VERSION</li>
|
||||
</ul></td>
|
||||
</ul>
|
||||
<p>Version numbers should be set according to the level of changes
|
||||
made since the last release. Note that the MAINTENANCE_VERSION or
|
||||
PATCH_LEVEL value should have been incremented after the previous
|
||||
release tag was applied.</p>
|
||||
<p>Set all DEVELOPMENT_FLAG values to 0 and EPICS_DEV_SNAPSHOT to the
|
||||
empty string.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
@@ -305,7 +312,26 @@ starting at <a href="#ReleaseApproval">Release Approval</a>.</p>
|
||||
cd base-7.0<br />
|
||||
git tag -m 'ANJ: Tagged for 7.0.3' R7.0.3</i>
|
||||
</tt></blockquote>
|
||||
Don't push the new tag to the Launchpad repository yet.</td>
|
||||
<p>Don't push these commits or the new tag to the Launchpad repository
|
||||
yet.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>Release Manager</td>
|
||||
<td>Edit and commit changes to the EPICS Base version number file and
|
||||
the embedded module version files as follows:
|
||||
<ul>
|
||||
<li>configure/CONFIG_BASE_VERSION </li>
|
||||
<li>modules/libcom/configure/CONFIG_LIBCOM_VERSION</li>
|
||||
<li>modules/ca/configure/CONFIG_CA_VERSION</li>
|
||||
<li>modules/database/configure/CONFIG_DATABASE_VERSION</li>
|
||||
</ul>
|
||||
<p>Version numbers should be set for the next expected patch/maintenance
|
||||
release by incrementing the MAINTENANCE_VERSION or PATCH_LEVEL
|
||||
value in each file.</p>
|
||||
<p>Set all DEVELOPMENT_FLAG values to 1 and EPICS_DEV_SNAPSHOT to
|
||||
"-DEV".</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
@@ -327,29 +353,13 @@ starting at <a href="#ReleaseApproval">Release Approval</a>.</p>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>Release Manager</td>
|
||||
<td>Test the tar file by extracting its contents and building it on at
|
||||
least one supported platform. When this succeeds the new git tag can be
|
||||
pushed to the Launchpad repository:
|
||||
least one supported platform. When this succeeds the commits and new git
|
||||
tag can be pushed to the Launchpad repository:
|
||||
<blockquote><tt>
|
||||
git push --follow-tags upstream 7.0
|
||||
</tt></blockquote>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>Release Manager</td>
|
||||
<td>Edit and commit changes to the EPICS Base version number file and
|
||||
the embedded module version files:
|
||||
<ul>
|
||||
<li>configure/CONFIG_BASE_VERSION </li>
|
||||
<li>modules/libcom/configure/CONFIG_LIBCOM_VERSION</li>
|
||||
<li>modules/ca/configure/CONFIG_CA_VERSION</li>
|
||||
<li>modules/database/configure/CONFIG_DATABASE_VERSION</li>
|
||||
</ul>
|
||||
Version numbers should be set to the next expected patch release,
|
||||
with a "-DEV" tag added (where applicable).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th colspan="3">Publish to epics.anl.gov</th>
|
||||
</tr>
|
||||
@@ -398,7 +408,11 @@ starting at <a href="#ReleaseApproval">Release Approval</a>.</p>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>Website Manager</td>
|
||||
<td>Upload the tar file and its <tt>.asc</tt> signature file to the
|
||||
epics-controls web-server [ToDo: ssh-key, location]</td>
|
||||
epics-controls web-server.
|
||||
<blockquote><tt>
|
||||
scp base-7.0.3.tar.gz base-7.0.3.tar.gz.asc epics-controls:download/base<br />
|
||||
</tt></blockquote>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
@@ -406,7 +420,10 @@ starting at <a href="#ReleaseApproval">Release Approval</a>.</p>
|
||||
<td>Follow instructions on
|
||||
<a href="https://epics-controls.org/resources-and-support/documents/epics-website-documentation/adding-a-page-for-a-new-release/">
|
||||
Add a page for a new release</a> to create a new release webpage (not
|
||||
required for a patch release though, just edit the existing page).</td>
|
||||
required for a patch release, just edit the existing page). Update the
|
||||
TablePress "Point Releases" table and add the new download, and adjust
|
||||
the XYZ Html Snippet for the series download.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Version number for the Channel Access API and shared library
|
||||
|
||||
EPICS_CA_MAJOR_VERSION = 4
|
||||
EPICS_CA_MINOR_VERSION = 13
|
||||
EPICS_CA_MAINTENANCE_VERSION = 4
|
||||
EPICS_CA_DEVELOPMENT_FLAG = 0
|
||||
EPICS_CA_MAINTENANCE_VERSION = 5
|
||||
|
||||
# Development flag, set to zero for release versions
|
||||
|
||||
EPICS_CA_DEVELOPMENT_FLAG = 1
|
||||
|
||||
# Immediately after a release the MAINTENANCE_VERSION
|
||||
# will be incremented and the DEVELOPMENT_FLAG set to 1
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Version number for the database APIs and shared library
|
||||
|
||||
EPICS_DATABASE_MAJOR_VERSION = 3
|
||||
EPICS_DATABASE_MINOR_VERSION = 17
|
||||
EPICS_DATABASE_MAINTENANCE_VERSION = 4
|
||||
EPICS_DATABASE_DEVELOPMENT_FLAG = 0
|
||||
EPICS_DATABASE_MAINTENANCE_VERSION = 5
|
||||
|
||||
# Development flag, set to zero for release versions
|
||||
|
||||
EPICS_DATABASE_DEVELOPMENT_FLAG = 1
|
||||
|
||||
# Immediately after a release the MAINTENANCE_VERSION
|
||||
# will be incremented and the DEVELOPMENT_FLAG set to 1
|
||||
|
||||
@@ -33,3 +33,6 @@ variable(callbackParallelThreadsDefault,int)
|
||||
|
||||
# Real-time operation
|
||||
variable(dbThreadRealtimeLock,int)
|
||||
|
||||
# show logClient network activity
|
||||
variable(logClientDebug,int)
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Version number for the libcom APIs and shared library
|
||||
|
||||
EPICS_LIBCOM_MAJOR_VERSION = 3
|
||||
EPICS_LIBCOM_MINOR_VERSION = 17
|
||||
EPICS_LIBCOM_MAINTENANCE_VERSION = 5
|
||||
EPICS_LIBCOM_DEVELOPMENT_FLAG = 0
|
||||
EPICS_LIBCOM_MAINTENANCE_VERSION = 6
|
||||
|
||||
# Development flag, set to zero for release versions
|
||||
|
||||
EPICS_LIBCOM_DEVELOPMENT_FLAG = 1
|
||||
|
||||
# Immediately after a release the MAINTENANCE_VERSION
|
||||
# will be incremented and the DEVELOPMENT_FLAG set to 1
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "envDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "logClient.h"
|
||||
#include "iocLog.h"
|
||||
#include "epicsExit.h"
|
||||
|
||||
int iocLogDisable = 0;
|
||||
|
||||
@@ -74,6 +76,24 @@ void epicsShareAPI epicsShareAPI iocLogFlush (void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* logClientSendMessage ()
|
||||
*/
|
||||
static void logClientSendMessage ( logClientId id, const char * message )
|
||||
{
|
||||
if ( !iocLogDisable ) {
|
||||
logClientSend (id, message);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogClientDestroy()
|
||||
*/
|
||||
static void iocLogClientDestroy (logClientId id)
|
||||
{
|
||||
errlogRemoveListeners (logClientSendMessage, id);
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogClientInit()
|
||||
*/
|
||||
@@ -89,6 +109,10 @@ static logClientId iocLogClientInit (void)
|
||||
return NULL;
|
||||
}
|
||||
id = logClientCreate (addr, port);
|
||||
if (id != NULL) {
|
||||
errlogAddListener (logClientSendMessage, id);
|
||||
epicsAtExit (iocLogClientDestroy, id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -135,3 +159,4 @@ logClientId epicsShareAPI logClientInit (void)
|
||||
{
|
||||
return iocLogClientInit ();
|
||||
}
|
||||
|
||||
|
||||
@@ -486,18 +486,6 @@ static void acceptNewClient ( void *pParam )
|
||||
}
|
||||
}
|
||||
|
||||
status = shutdown(pclient->insock, SHUT_WR);
|
||||
if(status<0){
|
||||
char sockErrBuf[64];
|
||||
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf (stderr, "%s:%d shutdown err %s\n", __FILE__, __LINE__,
|
||||
sockErrBuf);
|
||||
epicsSocketDestroy ( pclient->insock );
|
||||
free(pclient);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
status = fdmgr_add_callback(
|
||||
pserver->pfdctx,
|
||||
pclient->insock,
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbDefs.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "iocLog.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsTime.h"
|
||||
@@ -33,9 +31,13 @@
|
||||
#include "epicsAssert.h"
|
||||
#include "epicsExit.h"
|
||||
#include "epicsSignal.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#include "logClient.h"
|
||||
|
||||
int logClientDebug = 0;
|
||||
epicsExportAddress (int, logClientDebug);
|
||||
|
||||
typedef struct {
|
||||
char msgBuf[0x4000];
|
||||
struct sockaddr_in addr;
|
||||
@@ -44,6 +46,7 @@ typedef struct {
|
||||
SOCKET sock;
|
||||
epicsThreadId restartThreadId;
|
||||
epicsEventId stateChangeNotify;
|
||||
epicsEventId shutdownNotify;
|
||||
unsigned connectCount;
|
||||
unsigned nextMsgIndex;
|
||||
unsigned connected;
|
||||
@@ -53,7 +56,6 @@ typedef struct {
|
||||
} logClient;
|
||||
|
||||
static const double LOG_RESTART_DELAY = 5.0; /* sec */
|
||||
static const double LOG_SERVER_CREATE_CONNECT_SYNC_TIMEOUT = 5.0; /* sec */
|
||||
static const double LOG_SERVER_SHUTDOWN_TIMEOUT = 30.0; /* sec */
|
||||
|
||||
/*
|
||||
@@ -66,10 +68,10 @@ static char* logClientPrefix = NULL;
|
||||
*/
|
||||
static void logClientClose ( logClient *pClient )
|
||||
{
|
||||
# ifdef DEBUG
|
||||
if (logClientDebug) {
|
||||
fprintf (stderr, "log client: lingering for connection close...");
|
||||
fflush (stderr);
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
* mutex on
|
||||
@@ -84,8 +86,6 @@ static void logClientClose ( logClient *pClient )
|
||||
pClient->sock = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
pClient->nextMsgIndex = 0u;
|
||||
memset ( pClient->msgBuf, '\0', sizeof ( pClient->msgBuf ) );
|
||||
pClient->connected = 0u;
|
||||
|
||||
/*
|
||||
@@ -93,9 +93,8 @@ static void logClientClose ( logClient *pClient )
|
||||
*/
|
||||
epicsMutexUnlock (pClient->mutex);
|
||||
|
||||
# ifdef DEBUG
|
||||
if (logClientDebug)
|
||||
fprintf (stderr, "done\n");
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -113,6 +112,7 @@ static void logClientDestroy (logClientId id)
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
pClient->shutdown = 1u;
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
epicsEventSignal ( pClient->shutdownNotify );
|
||||
|
||||
/* unblock log client thread blocking in send() or connect() */
|
||||
interruptInfo =
|
||||
@@ -154,17 +154,40 @@ static void logClientDestroy (logClientId id)
|
||||
return;
|
||||
}
|
||||
|
||||
errlogRemoveListeners ( logClientSendMessage, (void *) pClient );
|
||||
|
||||
logClientClose ( pClient );
|
||||
|
||||
epicsMutexDestroy ( pClient->mutex );
|
||||
|
||||
epicsEventDestroy ( pClient->stateChangeNotify );
|
||||
epicsEventDestroy ( pClient->shutdownNotify );
|
||||
|
||||
free ( pClient );
|
||||
}
|
||||
|
||||
/*
|
||||
* logClientCheckConnection
|
||||
*/
|
||||
static void logClientCheckConnection( logClient * pClient )
|
||||
{
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
while ( pClient->connected ) {
|
||||
struct timeval timeout = { 0, 0 };
|
||||
fd_set set;
|
||||
char buffer[256];
|
||||
|
||||
FD_ZERO ( &set );
|
||||
FD_SET ( pClient->sock, &set );
|
||||
if ( select ( pClient->sock + 1, &set, NULL, NULL, &timeout ) == 0)
|
||||
break;
|
||||
if ( recv ( pClient->sock, buffer, sizeof ( buffer ), 0 ) == 0 ) {
|
||||
fprintf ( stderr, "log client: connection closed by server \"%s\"\n",
|
||||
pClient->name );
|
||||
logClientClose ( pClient );
|
||||
break;
|
||||
}
|
||||
}
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
}
|
||||
|
||||
/*
|
||||
* This method requires the pClient->mutex be owned already.
|
||||
*/
|
||||
@@ -176,57 +199,24 @@ static void sendMessageChunk(logClient * pClient, const char * message) {
|
||||
unsigned msgBufBytesLeft =
|
||||
sizeof ( pClient->msgBuf ) - pClient->nextMsgIndex;
|
||||
|
||||
if ( strSize > msgBufBytesLeft ) {
|
||||
int status;
|
||||
|
||||
if ( ! pClient->connected ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( msgBufBytesLeft > 0u ) {
|
||||
memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
|
||||
message, msgBufBytesLeft );
|
||||
pClient->nextMsgIndex += msgBufBytesLeft;
|
||||
strSize -= msgBufBytesLeft;
|
||||
message += msgBufBytesLeft;
|
||||
}
|
||||
|
||||
status = send ( pClient->sock, pClient->msgBuf,
|
||||
pClient->nextMsgIndex, 0 );
|
||||
if ( status > 0 ) {
|
||||
unsigned nSent = (unsigned) status;
|
||||
if ( nSent < pClient->nextMsgIndex ) {
|
||||
unsigned newNextMsgIndex = pClient->nextMsgIndex - nSent;
|
||||
memmove ( pClient->msgBuf, & pClient->msgBuf[nSent],
|
||||
newNextMsgIndex );
|
||||
pClient->nextMsgIndex = newNextMsgIndex;
|
||||
}
|
||||
else {
|
||||
pClient->nextMsgIndex = 0u;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( ! pClient->shutdown ) {
|
||||
char sockErrBuf[64];
|
||||
if ( status ) {
|
||||
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
}
|
||||
else {
|
||||
strcpy ( sockErrBuf, "server initiated disconnect" );
|
||||
}
|
||||
fprintf ( stderr, "log client: lost contact with log server at \"%s\" because \"%s\"\n",
|
||||
pClient->name, sockErrBuf );
|
||||
}
|
||||
logClientClose ( pClient );
|
||||
break;
|
||||
}
|
||||
if ( msgBufBytesLeft < strSize && pClient->nextMsgIndex != 0u && pClient->connected)
|
||||
{
|
||||
/* buffer is full, thus flush it */
|
||||
logClientCheckConnection( pClient );
|
||||
logClientFlush ( pClient );
|
||||
msgBufBytesLeft = sizeof ( pClient->msgBuf ) - pClient->nextMsgIndex;
|
||||
}
|
||||
else {
|
||||
memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
|
||||
message, strSize );
|
||||
pClient->nextMsgIndex += strSize;
|
||||
if ( msgBufBytesLeft == 0u ) {
|
||||
fprintf ( stderr, "log client: messages to \"%s\" are lost\n",
|
||||
pClient->name );
|
||||
break;
|
||||
}
|
||||
if ( msgBufBytesLeft > strSize) msgBufBytesLeft = strSize;
|
||||
memcpy ( & pClient->msgBuf[pClient->nextMsgIndex],
|
||||
message, msgBufBytesLeft );
|
||||
pClient->nextMsgIndex += msgBufBytesLeft;
|
||||
strSize -= msgBufBytesLeft;
|
||||
message += msgBufBytesLeft;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,32 +245,25 @@ void epicsShareAPI logClientSend ( logClientId id, const char * message )
|
||||
|
||||
void epicsShareAPI logClientFlush ( logClientId id )
|
||||
{
|
||||
unsigned nSent = 0u;
|
||||
|
||||
logClient * pClient = ( logClient * ) id;
|
||||
|
||||
if ( ! pClient ) {
|
||||
if ( ! pClient || ! pClient->connected ) {
|
||||
return;
|
||||
}
|
||||
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
|
||||
while ( pClient->nextMsgIndex && pClient->connected ) {
|
||||
int status = send ( pClient->sock, pClient->msgBuf,
|
||||
pClient->nextMsgIndex, 0 );
|
||||
while ( nSent < pClient->nextMsgIndex && pClient->connected ) {
|
||||
int status = send ( pClient->sock, pClient->msgBuf + nSent,
|
||||
pClient->nextMsgIndex - nSent, 0 );
|
||||
if ( status > 0 ) {
|
||||
unsigned nSent = (unsigned) status;
|
||||
if ( nSent < pClient->nextMsgIndex ) {
|
||||
unsigned newNextMsgIndex = pClient->nextMsgIndex - nSent;
|
||||
memmove ( pClient->msgBuf, & pClient->msgBuf[nSent],
|
||||
newNextMsgIndex );
|
||||
pClient->nextMsgIndex = newNextMsgIndex;
|
||||
}
|
||||
else {
|
||||
pClient->nextMsgIndex = 0u;
|
||||
}
|
||||
nSent += (unsigned) status;
|
||||
}
|
||||
else {
|
||||
if ( ! pClient->shutdown ) {
|
||||
char sockErrBuf[64];
|
||||
char sockErrBuf[128];
|
||||
if ( status ) {
|
||||
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
}
|
||||
@@ -294,6 +277,11 @@ void epicsShareAPI logClientFlush ( logClientId id )
|
||||
break;
|
||||
}
|
||||
}
|
||||
pClient->nextMsgIndex -= nSent;
|
||||
if ( nSent > 0 && pClient->nextMsgIndex > 0 ) {
|
||||
memmove ( pClient->msgBuf, & pClient->msgBuf[nSent],
|
||||
pClient->nextMsgIndex );
|
||||
}
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
}
|
||||
|
||||
@@ -302,10 +290,10 @@ void epicsShareAPI logClientFlush ( logClientId id )
|
||||
*/
|
||||
static void logClientMakeSock (logClient *pClient)
|
||||
{
|
||||
|
||||
# ifdef DEBUG
|
||||
if (logClientDebug) {
|
||||
fprintf (stderr, "log client: creating socket...");
|
||||
# endif
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
epicsMutexMustLock (pClient->mutex);
|
||||
|
||||
@@ -314,7 +302,7 @@ static void logClientMakeSock (logClient *pClient)
|
||||
*/
|
||||
pClient->sock = epicsSocketCreate ( AF_INET, SOCK_STREAM, 0 );
|
||||
if ( pClient->sock == INVALID_SOCKET ) {
|
||||
char sockErrBuf[64];
|
||||
char sockErrBuf[128];
|
||||
epicsSocketConvertErrnoToString (
|
||||
sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf ( stderr, "log client: no socket error %s\n",
|
||||
@@ -323,10 +311,8 @@ static void logClientMakeSock (logClient *pClient)
|
||||
|
||||
epicsMutexUnlock (pClient->mutex);
|
||||
|
||||
# ifdef DEBUG
|
||||
if (logClientDebug)
|
||||
fprintf (stderr, "done\n");
|
||||
# endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -366,7 +352,7 @@ static void logClientConnect (logClient *pClient)
|
||||
}
|
||||
else {
|
||||
if ( pClient->connFailStatus != errnoCpy && ! pClient->shutdown ) {
|
||||
char sockErrBuf[64];
|
||||
char sockErrBuf[128];
|
||||
epicsSocketConvertErrnoToString (
|
||||
sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf (stderr,
|
||||
@@ -392,26 +378,12 @@ static void logClientConnect (logClient *pClient)
|
||||
optval = TRUE;
|
||||
status = setsockopt (pClient->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval));
|
||||
if (status<0) {
|
||||
char sockErrBuf[64];
|
||||
char sockErrBuf[128];
|
||||
epicsSocketConvertErrnoToString (
|
||||
sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf (stderr, "log client: unable to enable keepalive option because \"%s\"\n", sockErrBuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* we don't need full-duplex (clients only write), so we shutdown
|
||||
* the read end of our socket
|
||||
*/
|
||||
status = shutdown (pClient->sock, SHUT_RD);
|
||||
if (status < 0) {
|
||||
char sockErrBuf[64];
|
||||
epicsSocketConvertErrnoToString (
|
||||
sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf (stderr, "%s:%d shutdown(%d,SHUT_RD) error was \"%s\"\n",
|
||||
__FILE__, __LINE__, pClient->sock, sockErrBuf);
|
||||
/* not fatal (although it shouldn't happen) */
|
||||
}
|
||||
|
||||
/*
|
||||
* set how long we will wait for the TCP state machine
|
||||
* to clean up when we issue a close(). This
|
||||
@@ -425,7 +397,7 @@ static void logClientConnect (logClient *pClient)
|
||||
lingerval.l_linger = 60*5;
|
||||
status = setsockopt (pClient->sock, SOL_SOCKET, SO_LINGER, (char *) &lingerval, sizeof(lingerval));
|
||||
if (status<0) {
|
||||
char sockErrBuf[64];
|
||||
char sockErrBuf[128];
|
||||
epicsSocketConvertErrnoToString (
|
||||
sockErrBuf, sizeof ( sockErrBuf ) );
|
||||
fprintf (stderr, "log client: unable to set linger options because \"%s\"\n", sockErrBuf);
|
||||
@@ -451,20 +423,21 @@ static void logClientRestart ( logClientId id )
|
||||
/* SMP safe state inspection */
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
while ( ! pClient->shutdown ) {
|
||||
unsigned isConn;
|
||||
unsigned isConn, dataToSend;
|
||||
|
||||
logClientCheckConnection( pClient );
|
||||
|
||||
isConn = pClient->connected;
|
||||
dataToSend = pClient->nextMsgIndex;
|
||||
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
|
||||
if ( isConn ) {
|
||||
if ( dataToSend ) {
|
||||
if ( ! isConn ) logClientConnect ( pClient );
|
||||
logClientFlush ( pClient );
|
||||
}
|
||||
else {
|
||||
logClientConnect ( pClient );
|
||||
}
|
||||
|
||||
epicsThreadSleep ( LOG_RESTART_DELAY );
|
||||
|
||||
epicsEventWaitWithTimeout ( pClient->shutdownNotify, LOG_RESTART_DELAY);
|
||||
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
}
|
||||
@@ -480,9 +453,7 @@ static void logClientRestart ( logClientId id )
|
||||
logClientId epicsShareAPI logClientCreate (
|
||||
struct in_addr server_addr, unsigned short server_port)
|
||||
{
|
||||
epicsTimeStamp begin, current;
|
||||
logClient *pClient;
|
||||
double diff;
|
||||
|
||||
pClient = calloc (1, sizeof (*pClient));
|
||||
if (pClient==NULL) {
|
||||
@@ -507,14 +478,22 @@ logClientId epicsShareAPI logClientCreate (
|
||||
pClient->shutdownConfirm = 0;
|
||||
|
||||
epicsAtExit (logClientDestroy, (void*) pClient);
|
||||
|
||||
|
||||
pClient->stateChangeNotify = epicsEventCreate (epicsEventEmpty);
|
||||
if ( ! pClient->stateChangeNotify ) {
|
||||
epicsMutexDestroy ( pClient->mutex );
|
||||
free ( pClient );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pClient->shutdownNotify = epicsEventCreate (epicsEventEmpty);
|
||||
if ( ! pClient->shutdownNotify ) {
|
||||
epicsMutexDestroy ( pClient->mutex );
|
||||
epicsEventDestroy ( pClient->stateChangeNotify );
|
||||
free ( pClient );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pClient->restartThreadId = epicsThreadCreate (
|
||||
"logRestart", epicsThreadPriorityLow,
|
||||
epicsThreadGetStackSize(epicsThreadStackSmall),
|
||||
@@ -522,35 +501,12 @@ logClientId epicsShareAPI logClientCreate (
|
||||
if ( pClient->restartThreadId == NULL ) {
|
||||
epicsMutexDestroy ( pClient->mutex );
|
||||
epicsEventDestroy ( pClient->stateChangeNotify );
|
||||
epicsEventDestroy ( pClient->shutdownNotify );
|
||||
free (pClient);
|
||||
fprintf(stderr, "log client: unable to start log client connection watch dog thread\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* attempt to synchronize with circuit connect
|
||||
*/
|
||||
epicsTimeGetCurrent ( & begin );
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
do {
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
epicsEventWaitWithTimeout (
|
||||
pClient->stateChangeNotify,
|
||||
LOG_SERVER_CREATE_CONNECT_SYNC_TIMEOUT / 10.0 );
|
||||
epicsTimeGetCurrent ( & current );
|
||||
diff = epicsTimeDiffInSeconds ( & current, & begin );
|
||||
epicsMutexMustLock ( pClient->mutex );
|
||||
}
|
||||
while ( ! pClient->connected && diff < LOG_SERVER_CREATE_CONNECT_SYNC_TIMEOUT );
|
||||
epicsMutexUnlock ( pClient->mutex );
|
||||
|
||||
if ( ! pClient->connected ) {
|
||||
fprintf (stderr, "log client create: timed out synchronizing with circuit connect to \"%s\" after %.1f seconds\n",
|
||||
pClient->name, LOG_SERVER_CREATE_CONNECT_SYNC_TIMEOUT );
|
||||
}
|
||||
|
||||
errlogAddListener ( logClientSendMessage, (void *) pClient );
|
||||
|
||||
return (void *) pClient;
|
||||
}
|
||||
|
||||
@@ -568,24 +524,21 @@ void epicsShareAPI logClientShow (logClientId id, unsigned level)
|
||||
printf ("log client: disconnected from log server at \"%s\"\n", pClient->name);
|
||||
}
|
||||
|
||||
if (level>1) {
|
||||
printf ("log client: sock=%s, connect cycles = %u\n",
|
||||
pClient->sock==INVALID_SOCKET?"INVALID":"OK",
|
||||
pClient->connectCount);
|
||||
}
|
||||
|
||||
if (logClientPrefix) {
|
||||
printf ("log client: prefix is \"%s\"\n", logClientPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* logClientSendMessage (); deprecated
|
||||
*/
|
||||
void logClientSendMessage ( logClientId id, const char * message )
|
||||
{
|
||||
if ( !iocLogDisable ) {
|
||||
logClientSend (id, message);
|
||||
if (level>0) {
|
||||
printf ("log client: sock %s, connect cycles = %u\n",
|
||||
pClient->sock==INVALID_SOCKET?"INVALID":"OK",
|
||||
pClient->connectCount);
|
||||
}
|
||||
if (level>1) {
|
||||
printf ("log client: %u bytes in buffer\n", pClient->nextMsgIndex);
|
||||
if (pClient->nextMsgIndex)
|
||||
printf("-------------------------\n"
|
||||
"%.*s-------------------------\n",
|
||||
(int)(pClient->nextMsgIndex), pClient->msgBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ epicsShareFunc void epicsShareAPI iocLogPrefix(const char* prefix);
|
||||
/* deprecated interface; retained for backward compatibility */
|
||||
/* note: implementations are in iocLog.c, not logClient.c */
|
||||
epicsShareFunc logClientId epicsShareAPI logClientInit (void);
|
||||
epicsShareFunc void logClientSendMessage (logClientId id, const char *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -350,7 +350,12 @@ static void unsolicitedHandlerEPICS(int vectorNumber)
|
||||
);
|
||||
}
|
||||
|
||||
#endif /* defined(__PPC__) && defined(mpc750) */
|
||||
#else /* !defined(__PPC__) && !defined(__mcf528x__) */
|
||||
|
||||
/* No known VME interface here, provide a dummy */
|
||||
devLibVME *pdevLibVME;
|
||||
|
||||
#endif /* defined(__PPC__) || defined(__mcf528x__) */
|
||||
|
||||
/*
|
||||
* Some vxWorks convenience routines
|
||||
|
||||
Submodule modules/pvAccess updated: 60fefdb2c1...c8c3cf4fd8
Submodule modules/pvData updated: cdd6980117...b903df5d0d
Submodule modules/pvDatabase updated: 428f784826...d7bd5628d4
Reference in New Issue
Block a user