提交 af7d630e 编写于 作者: U ubuntu

handle except

上级 e11d53f5
...@@ -169,6 +169,19 @@ static void destroyThrdObj(SCliThrdObj* pThrd); ...@@ -169,6 +169,19 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
pMsg = transQueueRm(&conn->cliMsgs, i); \ pMsg = transQueueRm(&conn->cliMsgs, i); \
} \ } \
} while (0) } while (0)
#define CONN_GET_NEXT_SENDMSG(conn) \
do { \
int i = 0; \
do { \
pCliMsg = transQueueGet(&conn->cliMsgs, i++); \
if (pCliMsg && 0 == pCliMsg->sent) { \
break; \
} \
} while (pCliMsg != NULL); \
if (pCliMsg == NULL) { \
goto _RETURN; \
} \
} while (0)
#define CONN_HANDLE_THREAD_QUIT(thrd) \ #define CONN_HANDLE_THREAD_QUIT(thrd) \
do { \ do { \
...@@ -203,19 +216,12 @@ static void* cliWorkThread(void* arg); ...@@ -203,19 +216,12 @@ static void* cliWorkThread(void* arg);
bool cliMaySendCachedMsg(SCliConn* conn) { bool cliMaySendCachedMsg(SCliConn* conn) {
if (!transQueueEmpty(&conn->cliMsgs)) { if (!transQueueEmpty(&conn->cliMsgs)) {
SCliMsg* pCliMsg = NULL; SCliMsg* pCliMsg = NULL;
int i = 0; CONN_GET_NEXT_SENDMSG(conn);
do {
pCliMsg = transQueueGet(&conn->cliMsgs, i++);
if (pCliMsg && 0 == pCliMsg->sent) {
break;
}
} while (pCliMsg != NULL);
if (pCliMsg == NULL) {
return false;
}
cliSend(conn); cliSend(conn);
} }
return false; return false;
_RETURN:
return false;
} }
void cliHandleResp(SCliConn* conn) { void cliHandleResp(SCliConn* conn) {
SCliThrdObj* pThrd = conn->hostThrd; SCliThrdObj* pThrd = conn->hostThrd;
...@@ -565,17 +571,7 @@ void cliSend(SCliConn* pConn) { ...@@ -565,17 +571,7 @@ void cliSend(SCliConn* pConn) {
assert(!transQueueEmpty(&pConn->cliMsgs)); assert(!transQueueEmpty(&pConn->cliMsgs));
SCliMsg* pCliMsg = NULL; SCliMsg* pCliMsg = NULL;
int i = 0; CONN_GET_NEXT_SENDMSG(pConn);
do {
pCliMsg = transQueueGet(&pConn->cliMsgs, i++);
if (pCliMsg && 0 == pCliMsg->sent) {
break;
}
} while (pCliMsg != NULL);
if (pCliMsg == NULL) {
return;
}
pCliMsg->sent = 1; pCliMsg->sent = 1;
STransConnCtx* pCtx = pCliMsg->ctx; STransConnCtx* pCtx = pCliMsg->ctx;
...@@ -630,6 +626,8 @@ void cliSend(SCliConn* pConn) { ...@@ -630,6 +626,8 @@ void cliSend(SCliConn* pConn) {
pConn->writeReq.data = pConn; pConn->writeReq.data = pConn;
uv_write(&pConn->writeReq, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb); uv_write(&pConn->writeReq, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb);
return;
_RETURN:
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册