add error
This commit is contained in:
parent
0988064f9c
commit
9fb329f481
|
@ -200,7 +200,7 @@ static FORCE_INLINE void cliMayUpdateFqdnCache(SHashObj* cache, char* dst);
|
|||
// process data read from server, add decompress etc later
|
||||
static void cliHandleResp(SCliConn* conn);
|
||||
// handle except about conn
|
||||
static void cliHandleExcept(SCliConn* conn);
|
||||
static void cliHandleExcept(SCliConn* conn, int32_t code);
|
||||
static void cliReleaseUnfinishedMsg(SCliConn* conn);
|
||||
static void cliHandleFastFail(SCliConn* pConn, int status);
|
||||
|
||||
|
@ -571,8 +571,11 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
|
|||
if (T_REF_VAL_GET(pConn) > 1) transUnrefCliHandle(pConn);
|
||||
transUnrefCliHandle(pConn);
|
||||
}
|
||||
void cliHandleExcept(SCliConn* conn) {
|
||||
void cliHandleExcept(SCliConn* conn, int32_t code) {
|
||||
tTrace("%s conn %p except ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn));
|
||||
if (code != TSDB_CODE_RPC_FQDN_ERROR) {
|
||||
code = -1;
|
||||
}
|
||||
cliHandleExceptImpl(conn, -1);
|
||||
}
|
||||
|
||||
|
@ -866,7 +869,7 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
|||
while (transReadComplete(pBuf)) {
|
||||
tTrace("%s conn %p read complete", CONN_GET_INST_LABEL(conn), conn);
|
||||
if (pBuf->invalid) {
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, -1);
|
||||
break;
|
||||
} else {
|
||||
cliHandleResp(conn);
|
||||
|
@ -886,7 +889,7 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
|||
tDebug("%s conn %p read error:%s, ref:%d", CONN_GET_INST_LABEL(conn), conn, uv_err_name(nread),
|
||||
T_REF_VAL_GET(conn));
|
||||
conn->broken = true;
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1040,7 @@ static void cliSendCb(uv_write_t* req, int status) {
|
|||
} else {
|
||||
if (!uv_is_closing((uv_handle_t*)&pConn->stream)) {
|
||||
tError("%s conn %p failed to write:%s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status));
|
||||
cliHandleExcept(pConn);
|
||||
cliHandleExcept(pConn, -1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1113,7 +1116,7 @@ void cliSend(SCliConn* pConn) {
|
|||
|
||||
if (transQueueEmpty(&pConn->cliMsgs)) {
|
||||
tError("%s conn %p not msg to send", pTransInst->label, pConn);
|
||||
cliHandleExcept(pConn);
|
||||
cliHandleExcept(pConn, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1186,7 +1189,7 @@ void cliSend(SCliConn* pConn) {
|
|||
if (status != 0) {
|
||||
tGError("%s conn %p failed to send msg:%s, errmsg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType),
|
||||
uv_err_name(status));
|
||||
cliHandleExcept(pConn);
|
||||
cliHandleExcept(pConn, -1);
|
||||
}
|
||||
return;
|
||||
_RETURN:
|
||||
|
@ -1242,7 +1245,8 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
|
|||
taosArrayPush(pThrd->timerList, &conn->timer);
|
||||
conn->timer = NULL;
|
||||
|
||||
cliHandleFastFail(conn, -1);
|
||||
cliHandleFastFail(conn, terrno);
|
||||
terrno = 0;
|
||||
return;
|
||||
}
|
||||
struct sockaddr_in addr;
|
||||
|
@ -1304,7 +1308,7 @@ static void cliSendBatchCb(uv_write_t* req, int status) {
|
|||
tDebug("%s conn %p failed to send batch msg, batch size:%d, msgLen:%d, reason:%s", CONN_GET_INST_LABEL(conn), conn,
|
||||
p->wLen, p->batchSize, uv_err_name(status));
|
||||
|
||||
if (!uv_is_closing((uv_handle_t*)&conn->stream)) cliHandleExcept(conn);
|
||||
if (!uv_is_closing((uv_handle_t*)&conn->stream)) cliHandleExcept(conn, -1);
|
||||
|
||||
cliHandleBatchReq(nxtBatch, thrd);
|
||||
} else {
|
||||
|
@ -1362,7 +1366,7 @@ static void cliHandleFastFail(SCliConn* pConn, int status) {
|
|||
cliDestroyBatch(pConn->pBatch);
|
||||
pConn->pBatch = NULL;
|
||||
}
|
||||
cliHandleExcept(pConn);
|
||||
cliHandleExcept(pConn, status);
|
||||
}
|
||||
|
||||
void cliConnCb(uv_connect_t* req, int status) {
|
||||
|
@ -1653,7 +1657,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
taosArrayPush(pThrd->timerList, &conn->timer);
|
||||
conn->timer = NULL;
|
||||
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, terrno);
|
||||
terrno = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1667,20 +1672,20 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
if (fd == -1) {
|
||||
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, -1);
|
||||
errno = 0;
|
||||
return;
|
||||
}
|
||||
int ret = uv_tcp_open((uv_tcp_t*)conn->stream, fd);
|
||||
if (ret != 0) {
|
||||
tGError("%s conn %p failed to set stream, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, -1);
|
||||
return;
|
||||
}
|
||||
ret = transSetConnOption((uv_tcp_t*)conn->stream, tsKeepAliveIdle);
|
||||
if (ret != 0) {
|
||||
tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
|
||||
cliHandleExcept(conn);
|
||||
cliHandleExcept(conn, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue