[TD-2502]<feature>: force version checking with rpc request messages
This commit is contained in:
parent
5444fe6beb
commit
eef2d8f05e
|
@ -67,6 +67,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, 0, 0x0012, "Invalid re
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "Client and server's time is not synchronized")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, 0, 0x0014, "Database not ready")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, 0, 0x0015, "Unable to resolve FQDN")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VERSION, 0, 0x0016, "Invalid app version")
|
||||
|
||||
//common & util
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_COM_OPS_NOT_SUPPORT, 0, 0x0100, "Operation not supported")
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct {
|
|||
char empty[1]; // reserved
|
||||
uint8_t msgType; // message type
|
||||
int32_t msgLen; // message length including the header iteslf
|
||||
uint32_t msgVer;
|
||||
int32_t code; // code in response message
|
||||
uint8_t content[0]; // message body starts from here
|
||||
} SRpcHead;
|
||||
|
|
|
@ -959,6 +959,11 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv, SRpcReqCont
|
|||
terrno = TSDB_CODE_RPC_INVALID_SESSION_ID; return NULL;
|
||||
}
|
||||
|
||||
if (rpcIsReq(pHead->msgType) && htonl(pHead->msgVer) != tsVersion >> 8) {
|
||||
tDebug("%s sid:%d, invalid client version:%d", pRpc->label, sid, htonl(pHead->msgVer));
|
||||
terrno = TSDB_CODE_RPC_INVALID_VERSION; return NULL;
|
||||
}
|
||||
|
||||
pConn = rpcGetConnObj(pRpc, sid, pRecv);
|
||||
if (pConn == NULL) {
|
||||
tDebug("%s %p, failed to get connection obj(%s)", pRpc->label, (void *)pHead->ahandle, tstrerror(terrno));
|
||||
|
@ -1282,6 +1287,7 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
|
|||
|
||||
// set the message header
|
||||
pHead->version = 1;
|
||||
pHead->msgVer = htonl(tsVersion >> 8);
|
||||
pHead->msgType = msgType;
|
||||
pHead->encrypt = 0;
|
||||
pConn->tranId++;
|
||||
|
|
Loading…
Reference in New Issue