[td-1716] enable repeatably close connection to avoid close the connection twice in c# driver #3737
This commit is contained in:
parent
4b3254a380
commit
7f70eff949
|
@ -27,6 +27,7 @@
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tscProfile.h"
|
#include "tscProfile.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
|
||||||
static bool validImpl(const char* str, size_t maxsize) {
|
static bool validImpl(const char* str, size_t maxsize) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
|
@ -256,10 +257,21 @@ TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port,
|
||||||
void taos_close(TAOS *taos) {
|
void taos_close(TAOS *taos) {
|
||||||
STscObj *pObj = (STscObj *)taos;
|
STscObj *pObj = (STscObj *)taos;
|
||||||
|
|
||||||
if (pObj == NULL || pObj->signature != pObj) {
|
if (pObj == NULL) {
|
||||||
|
tscDebug("(null) try to free tscObj and close dnodeConn");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tscDebug("%p try to free tscObj and close dnodeConn:%p", pObj, pObj->pDnodeConn);
|
||||||
|
if (pObj->signature != pObj) {
|
||||||
|
tscDebug("%p already closed or invalid tscObj", pObj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure that the close connection can only be executed once.
|
||||||
|
pObj->signature = NULL;
|
||||||
|
taosTmrStopA(&(pObj->pTimer));
|
||||||
|
|
||||||
SSqlObj* pHb = pObj->pHb;
|
SSqlObj* pHb = pObj->pHb;
|
||||||
if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) {
|
if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) {
|
||||||
if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode
|
if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode
|
||||||
|
|
Loading…
Reference in New Issue