rsrv: Register with dbServer API.
This commit is contained in:
@@ -17,13 +17,13 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiSock.h"
|
||||
#include "epicsTime.h"
|
||||
#include "epicsStdio.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "db_access.h"
|
||||
@@ -165,35 +165,18 @@ void camsgtask ( void *pParm )
|
||||
}
|
||||
|
||||
|
||||
void casHostNameInitiatingCurrentThread ( char * pBuf, unsigned bufSize )
|
||||
int casClientInitiatingCurrentThread ( char * pBuf, size_t bufSize )
|
||||
{
|
||||
if ( bufSize ) {
|
||||
const char * pHostName = "";
|
||||
{
|
||||
struct client * pClient = ( struct client * )
|
||||
epicsThreadPrivateGet ( rsrvCurrentClient );
|
||||
if ( pClient ) {
|
||||
pHostName = pClient->pHostName;
|
||||
}
|
||||
}
|
||||
strncpy ( pBuf, pHostName, bufSize );
|
||||
pBuf [ bufSize - 1u ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void casUserNameInitiatingCurrentThread ( char * pBuf, unsigned bufSize )
|
||||
{
|
||||
if ( bufSize ) {
|
||||
const char * pUserName = "";
|
||||
{
|
||||
struct client * pClient = ( struct client * )
|
||||
epicsThreadPrivateGet ( rsrvCurrentClient );
|
||||
if ( pClient ) {
|
||||
pUserName = pClient->pUserName;
|
||||
}
|
||||
}
|
||||
strncpy ( pBuf, pUserName, bufSize );
|
||||
pBuf [ bufSize - 1u ] = '\0';
|
||||
struct client * pClient = ( struct client * )
|
||||
epicsThreadPrivateGet ( rsrvCurrentClient );
|
||||
|
||||
if ( ! pClient )
|
||||
return RSRV_ERROR;
|
||||
|
||||
if ( pBuf && bufSize ) {
|
||||
epicsSnprintf(pBuf, bufSize, "%s@%s",
|
||||
pClient->pUserName, pClient->pHostName);
|
||||
}
|
||||
return RSRV_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,14 @@
|
||||
#include "dbEvent.h"
|
||||
#include "dbChannel.h"
|
||||
#include "dbCommon.h"
|
||||
#include "dbServer.h"
|
||||
#include "rsrv.h"
|
||||
#define GLBLSOURCE
|
||||
#include "server.h"
|
||||
|
||||
#define DELETE_TASK(NAME)\
|
||||
if(threadNameToId(NAME)!=0)threadDestroy(threadNameToId(NAME));
|
||||
#define DELETE_TASK(NAME) \
|
||||
if (threadNameToId(NAME)!=0) \
|
||||
threadDestroy(threadNameToId(NAME));
|
||||
|
||||
epicsThreadPrivateId rsrvCurrentClient;
|
||||
|
||||
@@ -230,6 +232,14 @@ static void req_server (void *pParm)
|
||||
}
|
||||
}
|
||||
|
||||
static dbServer rsrv_server = {
|
||||
ELLNODE_INIT,
|
||||
"rsrv",
|
||||
casr,
|
||||
casStatsFetch,
|
||||
casClientInitiatingCurrentThread
|
||||
};
|
||||
|
||||
/*
|
||||
* rsrv_init ()
|
||||
*/
|
||||
@@ -250,6 +260,8 @@ int rsrv_init (void)
|
||||
freeListInitPvt ( &rsrvSmallBufFreeListTCP, MAX_TCP, 16 );
|
||||
initializePutNotifyFreeList ();
|
||||
|
||||
dbRegisterServer(&rsrv_server);
|
||||
|
||||
status = envGetLongConfigParam ( &EPICS_CA_MAX_ARRAY_BYTES, &maxBytesAsALong );
|
||||
if ( status || maxBytesAsALong < 0 ) {
|
||||
errlogPrintf ( "cas: EPICS_CA_MAX_ARRAY_BYTES was not a positive integer\n" );
|
||||
@@ -948,16 +960,16 @@ struct client *create_tcp_client ( SOCKET sock )
|
||||
|
||||
void casStatsFetch ( unsigned *pChanCount, unsigned *pCircuitCount )
|
||||
{
|
||||
LOCK_CLIENTQ;
|
||||
LOCK_CLIENTQ;
|
||||
{
|
||||
int circuitCount = ellCount ( &clientQ );
|
||||
if ( circuitCount < 0 ) {
|
||||
*pCircuitCount = 0;
|
||||
*pCircuitCount = 0;
|
||||
}
|
||||
else {
|
||||
*pCircuitCount = (unsigned) circuitCount;
|
||||
*pCircuitCount = (unsigned) circuitCount;
|
||||
}
|
||||
*pChanCount = rsrvChannelCount;
|
||||
}
|
||||
UNLOCK_CLIENTQ;
|
||||
UNLOCK_CLIENTQ;
|
||||
}
|
||||
|
||||
@@ -19,21 +19,28 @@
|
||||
#ifndef rsrvh
|
||||
#define rsrvh
|
||||
|
||||
#include <stddef.h>
|
||||
#include "shareLib.h"
|
||||
|
||||
#define RSRV_OK 0
|
||||
#define RSRV_ERROR (-1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
epicsShareFunc int rsrv_init(void);
|
||||
epicsShareFunc int rsrv_run(void);
|
||||
epicsShareFunc int rsrv_pause(void);
|
||||
|
||||
epicsShareFunc void casr (unsigned level);
|
||||
epicsShareFunc void casHostNameInitiatingCurrentThread (
|
||||
char * pBuf, unsigned bufSize );
|
||||
epicsShareFunc void casUserNameInitiatingCurrentThread (
|
||||
char * pBuf, unsigned bufSize );
|
||||
epicsShareFunc int casClientInitiatingCurrentThread (
|
||||
char * pBuf, size_t bufSize );
|
||||
epicsShareFunc void casStatsFetch (
|
||||
unsigned *pChanCount, unsigned *pConnCount );
|
||||
|
||||
#define RSRV_OK 0
|
||||
#define RSRV_ERROR (-1)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*rsrvh */
|
||||
|
||||
Reference in New Issue
Block a user