made minor changes to make code nicer
This commit is contained in:
parent
25a4625ef6
commit
f9302e8a39
|
@ -51,20 +51,20 @@ typedef struct {
|
||||||
int connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
int connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||||
int idleTime; // milliseconds, 0 means idle timer is disabled
|
int idleTime; // milliseconds, 0 means idle timer is disabled
|
||||||
|
|
||||||
// the following is for client security only
|
// the following is for client app ecurity only
|
||||||
char *user; // user name
|
char *user; // user name
|
||||||
char spi; // security parameter index
|
char spi; // security parameter index
|
||||||
char encrypt; // encrypt algorithm
|
char encrypt; // encrypt algorithm
|
||||||
char *secret; // key for authentication
|
char *secret; // key for authentication
|
||||||
char *ckey; // ciphering key
|
char *ckey; // ciphering key
|
||||||
|
|
||||||
// call back to process incoming msg
|
// call back to process incoming msg, code shall be ignored by server app
|
||||||
void (*cfp)(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
void (*cfp)(char type, void *pCont, int contLen, void *handle, int32_t code);
|
||||||
|
|
||||||
// call back to process notify the ipSet changes
|
// call back to process notify the ipSet changes, for client app only
|
||||||
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
|
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
|
||||||
|
|
||||||
// call back to retrieve the client auth info
|
// call back to retrieve the client auth info, for server app only
|
||||||
int (*afp)(char *meterId, char *spi, char *encrypt, char *secret, char *ckey);
|
int (*afp)(char *meterId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ typedef struct {
|
||||||
int connType;
|
int connType;
|
||||||
char label[12];
|
char label[12];
|
||||||
|
|
||||||
char user[TSDB_UNI_LEN]; // meter ID
|
char user[TSDB_UNI_LEN]; // meter ID
|
||||||
char spi; // security parameter index
|
char spi; // security parameter index
|
||||||
char encrypt; // encrypt algorithm
|
char encrypt; // encrypt algorithm
|
||||||
char secret[TSDB_KEY_LEN]; // secret for the link
|
char secret[TSDB_KEY_LEN]; // secret for the link
|
||||||
char ckey[TSDB_KEY_LEN]; // ciphering key
|
char ckey[TSDB_KEY_LEN]; // ciphering key
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ void (*taosCloseConn[])(void *chandle) = {
|
||||||
|
|
||||||
static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerIpStr, uint16_t peerPort, int8_t connType);
|
static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerIpStr, uint16_t peerPort, int8_t connType);
|
||||||
static void rpcCloseConn(void *thandle);
|
static void rpcCloseConn(void *thandle);
|
||||||
static SRpcConn *rpcSetConnToServer(SRpcReqContext *pContext);
|
static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext);
|
||||||
static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc);
|
static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc);
|
||||||
static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, char *user, char *hashstr);
|
static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, char *user, char *hashstr);
|
||||||
static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, char *user, char *hashstr);
|
static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, char *user, char *hashstr);
|
||||||
|
@ -567,7 +567,7 @@ static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, char *user, char *hashst
|
||||||
return pConn;
|
return pConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcConn *rpcSetConnToServer(SRpcReqContext *pContext) {
|
static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) {
|
||||||
SRpcConn *pConn;
|
SRpcConn *pConn;
|
||||||
SRpcInfo *pRpc = pContext->pRpc;
|
SRpcInfo *pRpc = pContext->pRpc;
|
||||||
SRpcIpSet *pIpSet = &pContext->ipSet;
|
SRpcIpSet *pIpSet = &pContext->ipSet;
|
||||||
|
@ -888,7 +888,7 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
|
||||||
char msgType = pContext->msgType;
|
char msgType = pContext->msgType;
|
||||||
|
|
||||||
pContext->numOfTry++;
|
pContext->numOfTry++;
|
||||||
SRpcConn *pConn = rpcSetConnToServer(pContext);
|
SRpcConn *pConn = rpcSetupConnToServer(pContext);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
pContext->code = terrno;
|
pContext->code = terrno;
|
||||||
taosTmrStart(rpcProcessConnError, 0, pContext, pRpc->tmrCtrl);
|
taosTmrStart(rpcProcessConnError, 0, pContext, pRpc->tmrCtrl);
|
||||||
|
@ -921,7 +921,7 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
|
||||||
pthread_mutex_unlock(&pRpc->mutex);
|
pthread_mutex_unlock(&pRpc->mutex);
|
||||||
|
|
||||||
rpcSendMsgToPeer(pConn, msg, msgLen);
|
rpcSendMsgToPeer(pConn, msg, msgLen);
|
||||||
//taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer);
|
taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
|
static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
|
||||||
|
|
Loading…
Reference in New Issue