fix a write bug, make the connection cache code prettier
This commit is contained in:
parent
5da147a691
commit
8c87d83a56
|
@ -802,7 +802,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
|
|||
pConn = rpcProcessMsgHead(pRpc, pRecv);
|
||||
|
||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16)) {
|
||||
tTrace("%s %p, %s received from 0x%x:%hu, parse code:%x len:%d source:0x%08x dest:0x%08x tranId:%d port:%hu",
|
||||
tTrace("%s %p, %s received from 0x%x:%hu, parse code:%x len:%d sig:0x%08x:0x%08x:%d",
|
||||
pRpc->label, pConn, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno,
|
||||
pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->port);
|
||||
}
|
||||
|
@ -969,12 +969,12 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
|
|||
|
||||
if ( rpcIsReq(pHead->msgType)) {
|
||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16))
|
||||
tTrace("%s %p, %s is sent to %s:%hu, len:%d source:0x%08x dest:0x%08x tranId:%d",
|
||||
tTrace("%s %p, %s is sent to %s:%hu, len:%d sig:0x%08x:0x%08x:%d",
|
||||
pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIpstr,
|
||||
pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
|
||||
} else {
|
||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16))
|
||||
tTrace( "%s %p, %s is sent to %s:%hu, code:%u len:%d source:0x%08x dest:0x%08x tranId:%d",
|
||||
tTrace( "%s %p, %s is sent to %s:%hu, code:%u len:%d sig:0x%08x:0x%08x:%d",
|
||||
pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIpstr, pConn->peerPort,
|
||||
(uint8_t)pHead->content[0], msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,12 @@ void processRequestMsg(char type, void *pCont, int contLen, void *thandle, int32
|
|||
static int num = 0;
|
||||
tTrace("request is received, type:%d, contLen:%d", type, contLen);
|
||||
|
||||
if (dataFd >=0)
|
||||
write(dataFd, pCont, contLen);
|
||||
|
||||
if (dataFd >=0) {
|
||||
if ( write(dataFd, pCont, contLen) <0 ) {
|
||||
tPrint("failed to write data file, reason:%s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (commit >=2) {
|
||||
++num;
|
||||
if ( fsync(dataFd) < 0 ) {
|
||||
|
@ -117,7 +120,7 @@ int main(int argc, char *argv[]) {
|
|||
tPrint("RPC server is running, ctrl-c to exit");
|
||||
|
||||
if (commit) {
|
||||
dataFd = open(dataName, O_APPEND | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
if (dataFd<0)
|
||||
tPrint("failed to open data file, reason:%s", strerror(errno));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue