56 #include "rnr/rnrconfig.h" 94 LOGSYSERROR(
"pthread_mutex_lock()");
108 LOGSYSERROR(
"pthread_mutex_unlock()");
139 LOGSYSERROR(
"pthread_cond_broadcast()");
153 LOGSYSERROR(
"pthread_cond_wait()");
196 if( BsVConnTbl[hndVConn] == NULL )
201 BsVConnTbl[hndVConn] = pVConn;
256 return BsVConnTbl[hndVConn];
278 LOGERROR(
"%s: Could not create server service thread.",
ServerHasName());
296 BsVConnTbl[hndVConn] = pVConn;
326 const char *sDevName,
327 const char *sModName,
333 char *sModUri = NULL;
334 char *sDevUri = NULL;
350 "No more virtual connections are available.");
365 else if( (sDevUri =
ThNewDevUri(sDevName)) == NULL )
377 else if( (pModIF =
ModLoad(sModUri)) == NULL )
381 "Could not load or attach to \"%s\" interface module.", sModUri);
391 sDevUri, argbuf, uArgLen)) < 0 )
395 "Could not open \"%s\" interface module.", pModIF->
m_sModUri);
407 "Could not create or attach to \"%s\" device service thread.",
429 LOGDIAG1(
"%s: %s: Virtual connection %d opened: %s('%s',rd=%d).",
431 sModUri, sDevUri, rd);
433 LOGDIAG2(
"%s: %u active module virtual connections.",
523 LOGDIAG1(
"%s: %s: Virtual connection %d closed.",
532 LOGDIAG2(
"%s: %u active module virtual connections.",
563 while( (BsVConnTbl[hndVConn] != NULL) && BsVConnTbl[hndVConn]->m_bBusy )
568 if( (pVConn = BsVConnTbl[hndVConn]) != NULL )
594 if( BsVConnTbl[hndVConn] != NULL )
596 BsVConnTbl[hndVConn]->
m_bBusy =
false;
static uint_t BsVConnActiveCnt
Number of active v. connections.
static void VConnUnlockBusy()
Unlock virtual connection's global busy mutual exclusion.
static bool_t VConnBusyTryLock()
Try to lock virtual connection's global busy mutual exclusion.
BsProxyVConn_T * VConnNew()
Create a new, allocated virtual connection entry.
<b><i>BotSense</i></b> bsProxy IP server declarations.
static pthread_cond_t BsVConnBusyCond
block condition
#define BS_ECODE_BAD_VAL
bad value
int m_rd
module resource descriptor
BsProxyThCtl_T * ThCreateServerThread()
Create the special server service thread.
static BsProxyVConn_T * BsVConnTbl[BSPROXY_VCONN_NUMOF]
table of virtual connections
static void VConnWaitNotBusy()
Wait on a virtual connection to become's free.
char * ThNewDevUri(const char *sDevName)
Convert the device name to a quasi Uniform Resource Id.
int VConnOpenDev(BsProxyClientHnd_T hndClient, const char *sDevName, const char *sModName, byte_t argbuf[], size_t uArgLen, bool_t bTrace)
Open a virtual device connection.
#define BSPROXY_VCONN_NUMOF
total number of module handles
static void VConnBroadcastNotBusy()
Broadcast that a virtual connection has been freed or deleted.
BsProxyThCtl_T * ThCreateDevThread(const char *sDevUri)
Create a device service thread.
#define BSPROXY_VCONN_SERVER
handle for server-terminated msgs
BsProxyThCtl_T * m_pThCtl
service thread
void VConnRelease(BsVConnHnd_T hndVConn)
Release the locked virtual client.
int VConnOpenServer()
Open special server virtual connection.
INLINE_IN_H const char * ServerHasName()
Get the <b><i>BotSense</i></b> server's official name.
static pthread_mutex_t BsVConnBusyMutex
operations mutex
#define BS_OK
not an error, success
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
BsModCloseFunc_P m_fnModClose
device close
int BsProxyClientHnd_T
bsProxy server client handle
char * ModNewModUri(const char *sModName)
Convert the module name to a quasi Uniform Resource Id.
static void VConnLockBusy()
Lock virtual connection's global busy mutual exclusion.
#define BS_ECODE_NO_EXEC
cannot execute
void ThDestroyThread(BsProxyThCtl_T *pThCtl)
Destroy service thread.
BsProxyVConn_T * VConnGet(BsVConnHnd_T hndVConn)
Get the virtual connection entry associated with the handle.
BsProxyClientHnd_T m_hndClient
proxied client handle
BsProxyModIF_T * ModLoad(const char *sModUri)
Load the interface module.
#define BS_ECODE_NO_RSRC
no resource available
#define BSPROXY_CHK_VCONN_HND(hndVConn)
#define BSPROXY_LOG_ERROR(hndClient, ecode, efmt,...)
Log Proxy Server Error.
BsProxyVConn_T * VConnAcquire(BsVConnHnd_T hndVConn)
Acquire virtual connection, locking it from other threads.
#define BS_ECODE_NO_MOD
no interface module
const char * m_sModUri
module Uniform Resource Id
BsVConnHnd_T m_hndVConn
self reference
bool_t m_bBusy
virtual connection is [not] busy
void VConnDelete(BsProxyVConn_T *pVConn)
Delete allocated virtual connection entry.
<b><i>BotSense</i></b> bsProxy Dynamically Linked Library module interface.
#define BSPROXY_CHK_MOD_VCONN_HND(hndVConn)
#define BS_ECODE_NO_VCONN
virtual connection not found
#define BSPROXY_VCONN_MOD_NUMOF
number of module-specific handles
BsModOpenFunc_P m_fnModOpen
device open
INLINE_IN_H const char * ClientHasName(BsProxyClientHnd_T hndClient)
Get the <b><i>BotSense</i></b> client official name.
int VConnClose(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn)
Close the virtual connection.
void VConnOneTimeInit()
The bsProxy virtual connections one-time initialization.
BsProxyModIF_T * m_pModIF
interface module I/F
<b><i>BotSense</i></b> package top-level, unifying header declarations.
int BsVConnHnd_T
virtual connection handle type
void ModUnload(BsProxyModIF_T *pModIF)
Unload the interface module.