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);
|
pConn = rpcProcessMsgHead(pRpc, pRecv);
|
||||||
|
|
||||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16)) {
|
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,
|
pRpc->label, pConn, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno,
|
||||||
pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->port);
|
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 ( rpcIsReq(pHead->msgType)) {
|
||||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16))
|
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,
|
pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIpstr,
|
||||||
pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
|
pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
|
||||||
} else {
|
} else {
|
||||||
if (pHead->msgType < TSDB_MSG_TYPE_HEARTBEAT || (rpcDebugFlag & 16))
|
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,
|
pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIpstr, pConn->peerPort,
|
||||||
(uint8_t)pHead->content[0], msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
|
(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;
|
static int num = 0;
|
||||||
tTrace("request is received, type:%d, contLen:%d", type, contLen);
|
tTrace("request is received, type:%d, contLen:%d", type, contLen);
|
||||||
|
|
||||||
if (dataFd >=0)
|
if (dataFd >=0) {
|
||||||
write(dataFd, pCont, contLen);
|
if ( write(dataFd, pCont, contLen) <0 ) {
|
||||||
|
tPrint("failed to write data file, reason:%s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (commit >=2) {
|
if (commit >=2) {
|
||||||
++num;
|
++num;
|
||||||
if ( fsync(dataFd) < 0 ) {
|
if ( fsync(dataFd) < 0 ) {
|
||||||
|
@ -117,7 +120,7 @@ int main(int argc, char *argv[]) {
|
||||||
tPrint("RPC server is running, ctrl-c to exit");
|
tPrint("RPC server is running, ctrl-c to exit");
|
||||||
|
|
||||||
if (commit) {
|
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)
|
if (dataFd<0)
|
||||||
tPrint("failed to open data file, reason:%s", strerror(errno));
|
tPrint("failed to open data file, reason:%s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue