Merge branch 'develop' into feature/lihui
This commit is contained in:
commit
e9c56255ef
|
@ -13,8 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
|
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
|
@ -13,12 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tast.h"
|
#include "tast.h"
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "os.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
|
@ -13,14 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include "os.h"
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "tglobalcfg.h"
|
#include "tglobalcfg.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
|
@ -15,16 +15,6 @@
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <wctype.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tast.h"
|
#include "tast.h"
|
||||||
|
|
|
@ -13,13 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <tsclient.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tscJoinProcess.h"
|
#include "tscJoinProcess.h"
|
||||||
|
|
|
@ -13,9 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "os.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
|
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
|
|
|
@ -21,22 +21,8 @@
|
||||||
#pragma GCC diagnostic ignored "-Woverflow"
|
#pragma GCC diagnostic ignored "-Woverflow"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#include "ihash.h"
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "ihash.h"
|
||||||
#include "tscSecondaryMerge.h"
|
#include "tscSecondaryMerge.h"
|
||||||
#include "tscUtil.h"
|
#include "tscUtil.h"
|
||||||
#include "tschemautil.h"
|
#include "tschemautil.h"
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
#include "tsql.h"
|
#include "tsql.h"
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
|
@ -23,6 +20,27 @@
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
|
void tscSaveSlowQueryFp(void *handle, void *tmrId);
|
||||||
|
void *tscSlowQueryConn = NULL;
|
||||||
|
bool tscSlowQueryConnInitialized = false;
|
||||||
|
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||||
|
void *param, void **taos);
|
||||||
|
|
||||||
|
void tscInitConnCb(void *param, TAOS_RES *result, int code) {
|
||||||
|
char *sql = param;
|
||||||
|
if (code < 0) {
|
||||||
|
tscError("taos:%p, slow query connect failed, code:%d", tscSlowQueryConn, code);
|
||||||
|
taos_close(tscSlowQueryConn);
|
||||||
|
tscSlowQueryConn = NULL;
|
||||||
|
tscSlowQueryConnInitialized = false;
|
||||||
|
free(sql);
|
||||||
|
} else {
|
||||||
|
tscTrace("taos:%p, slow query connect success, code:%d", tscSlowQueryConn, code);
|
||||||
|
tscSlowQueryConnInitialized = true;
|
||||||
|
tscSaveSlowQueryFp(sql, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tscAddIntoSqlList(SSqlObj *pSql) {
|
void tscAddIntoSqlList(SSqlObj *pSql) {
|
||||||
static uint32_t queryId = 1;
|
static uint32_t queryId = 1;
|
||||||
|
|
||||||
|
@ -47,26 +65,28 @@ void tscAddIntoSqlList(SSqlObj *pSql) {
|
||||||
|
|
||||||
void tscSaveSlowQueryFpCb(void *param, TAOS_RES *result, int code) {
|
void tscSaveSlowQueryFpCb(void *param, TAOS_RES *result, int code) {
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tscError("failed to save slowquery, code:%d", code);
|
tscError("failed to save slow query, code:%d", code);
|
||||||
|
} else {
|
||||||
|
tscTrace("success to save slow query, code:%d", code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSaveSlowQueryFp(void *handle, void *tmrId) {
|
void tscSaveSlowQueryFp(void *handle, void *tmrId) {
|
||||||
char *sql = handle;
|
char *sql = handle;
|
||||||
|
|
||||||
static void *taos = NULL;
|
if (!tscSlowQueryConnInitialized) {
|
||||||
if (taos == NULL) {
|
if (tscSlowQueryConn == NULL) {
|
||||||
taos = taos_connect(NULL, "monitor", tsInternalPass, NULL, 0);
|
tscTrace("start to init slow query connect");
|
||||||
if (taos == NULL) {
|
taos_connect_a(NULL, "monitor", tsInternalPass, "", 0, tscInitConnCb, sql, &tscSlowQueryConn);
|
||||||
tscError("failed to save slow query, can't connect to server");
|
} else {
|
||||||
|
tscError("taos:%p, slow query connect is already initialized", tscSlowQueryConn);
|
||||||
free(sql);
|
free(sql);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
tscTrace("taos:%p, save slow query:%s", tscSlowQueryConn, sql);
|
||||||
tscTrace("save slow query:sql", sql);
|
taos_query_a(tscSlowQueryConn, sql, tscSaveSlowQueryFpCb, NULL);
|
||||||
taos_query_a(taos, sql, tscSaveSlowQueryFpCb, NULL);
|
|
||||||
free(sql);
|
free(sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSaveSlowQuery(SSqlObj *pSql) {
|
void tscSaveSlowQuery(SSqlObj *pSql) {
|
||||||
|
|
|
@ -13,13 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tglobalcfg.h"
|
#include "tglobalcfg.h"
|
||||||
#include "tsql.h"
|
#include "tsql.h"
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tschemautil.h"
|
#include "tschemautil.h"
|
||||||
|
|
|
@ -13,13 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <tsclient.h>
|
|
||||||
|
|
||||||
#include "tlosertree.h"
|
#include "os.h"
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tscSecondaryMerge.h"
|
#include "tscSecondaryMerge.h"
|
||||||
#include "tscUtil.h"
|
#include "tscUtil.h"
|
||||||
|
|
|
@ -13,12 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
@ -2848,7 +2842,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql) {
|
||||||
return msgLen;
|
return msgLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscEstimateBuildHeartBeatMsgLength(SSqlObj *pSql) {
|
int tscEstimateHeartBeatMsgLength(SSqlObj *pSql) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
STscObj *pObj = pSql->pTscObj;
|
STscObj *pObj = pSql->pTscObj;
|
||||||
|
|
||||||
|
@ -2881,7 +2875,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql) {
|
||||||
|
|
||||||
pthread_mutex_lock(&pObj->mutex);
|
pthread_mutex_lock(&pObj->mutex);
|
||||||
|
|
||||||
size = tscEstimateBuildHeartBeatMsgLength(pSql);
|
size = tscEstimateHeartBeatMsgLength(pSql);
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
tscError("%p failed to malloc for heartbeat msg", pSql);
|
tscError("%p failed to malloc for heartbeat msg", pSql);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3613,7 +3607,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *meterId) {
|
||||||
|
|
||||||
code = tscDoGetMeterMeta(pSql, meterId, 0); // todo ??
|
code = tscDoGetMeterMeta(pSql, meterId, 0); // todo ??
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%d, addr:%p", pSql,
|
tscTrace("%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%lld, addr:%p", pSql,
|
||||||
pMeterMetaInfo->pMeterMeta->numOfTags, pCmd->numOfCols, pMeterMetaInfo->pMeterMeta->uid,
|
pMeterMetaInfo->pMeterMeta->numOfTags, pCmd->numOfCols, pMeterMetaInfo->pMeterMeta->uid,
|
||||||
pMeterMetaInfo->pMeterMeta);
|
pMeterMetaInfo->pMeterMeta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <signal.h>
|
#include "os.h"
|
||||||
|
|
||||||
#include "shash.h"
|
#include "shash.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
|
@ -13,10 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include "os.h"
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tscSyntaxtreefunction.h"
|
#include "tscSyntaxtreefunction.h"
|
||||||
#include "tsql.h"
|
#include "tsql.h"
|
||||||
|
|
|
@ -13,15 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <locale.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "ihash.h"
|
#include "ihash.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
|
|
|
@ -29,7 +29,7 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsafe.Pointer, err error){
|
func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsafe.Pointer, err error) {
|
||||||
cuser := C.CString(user)
|
cuser := C.CString(user)
|
||||||
cpass := C.CString(pass)
|
cpass := C.CString(pass)
|
||||||
cip := C.CString(ip)
|
cip := C.CString(ip)
|
||||||
|
@ -48,7 +48,7 @@ func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsaf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *taosConn) taosQuery(sqlstr string) (int, error) {
|
func (mc *taosConn) taosQuery(sqlstr string) (int, error) {
|
||||||
taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
//taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
||||||
|
|
||||||
csqlstr := C.CString(sqlstr)
|
csqlstr := C.CString(sqlstr)
|
||||||
defer C.free(unsafe.Pointer(csqlstr))
|
defer C.free(unsafe.Pointer(csqlstr))
|
||||||
|
@ -58,6 +58,7 @@ func (mc *taosConn) taosQuery(sqlstr string) (int, error) {
|
||||||
mc.taos_error()
|
mc.taos_error()
|
||||||
errStr := C.GoString(C.taos_errstr(mc.taos))
|
errStr := C.GoString(C.taos_errstr(mc.taos))
|
||||||
taosLog.Println("taos_query() failed:", errStr)
|
taosLog.Println("taos_query() failed:", errStr)
|
||||||
|
taosLog.Printf("taosQuery() input sql:%s\n", sqlstr)
|
||||||
return 0, errors.New(errStr)
|
return 0, errors.New(errStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,8 @@ extern uint32_t debugFlag;
|
||||||
extern uint32_t odbcdebugFlag;
|
extern uint32_t odbcdebugFlag;
|
||||||
extern uint32_t qdebugFlag;
|
extern uint32_t qdebugFlag;
|
||||||
|
|
||||||
|
extern uint32_t taosMaxTmrCtrl;
|
||||||
|
|
||||||
extern int tsRpcTimer;
|
extern int tsRpcTimer;
|
||||||
extern int tsRpcMaxTime;
|
extern int tsRpcMaxTime;
|
||||||
extern int tsUdpDelay;
|
extern int tsUdpDelay;
|
||||||
|
|
|
@ -25,6 +25,7 @@ typedef void (*TAOS_TMR_CALLBACK)(void *, void *);
|
||||||
|
|
||||||
extern uint32_t tmrDebugFlag;
|
extern uint32_t tmrDebugFlag;
|
||||||
extern int taosTmrThreads;
|
extern int taosTmrThreads;
|
||||||
|
extern uint32_t taosMaxTmrCtrl;
|
||||||
|
|
||||||
#define tmrError(...) \
|
#define tmrError(...) \
|
||||||
do { if (tmrDebugFlag & DEBUG_ERROR) { \
|
do { if (tmrDebugFlag & DEBUG_ERROR) { \
|
||||||
|
@ -41,7 +42,6 @@ extern int taosTmrThreads;
|
||||||
tprintf("TMR ", tmrDebugFlag, __VA_ARGS__); \
|
tprintf("TMR ", tmrDebugFlag, __VA_ARGS__); \
|
||||||
} } while(0)
|
} } while(0)
|
||||||
|
|
||||||
#define MAX_NUM_OF_TMRCTL 32
|
|
||||||
#define MSECONDS_PER_TICK 5
|
#define MSECONDS_PER_TICK 5
|
||||||
|
|
||||||
void *taosTmrInit(int maxTmr, int resoultion, int longest, const char *label);
|
void *taosTmrInit(int maxTmr, int resoultion, int longest, const char *label);
|
||||||
|
|
|
@ -169,8 +169,6 @@ int32_t taosInitTimer(void (*callback)(int), int32_t ms);
|
||||||
*/
|
*/
|
||||||
uint32_t MurmurHash3_32(const void *key, int32_t len);
|
uint32_t MurmurHash3_32(const void *key, int32_t len);
|
||||||
|
|
||||||
bool taosCheckDbName(char *db, char *monitordb);
|
|
||||||
|
|
||||||
bool taosMbsToUcs4(char *mbs, int32_t mbs_len, char *ucs4, int32_t ucs4_max_len);
|
bool taosMbsToUcs4(char *mbs, int32_t mbs_len, char *ucs4, int32_t ucs4_max_len);
|
||||||
|
|
||||||
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
|
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_PLATFORM_LINUX_H
|
#ifndef TDENGINE_PLATFORM_LINUX_H
|
||||||
#define TDENGINE_PLATFORM_LINUX_H
|
#define TDENGINE_PLATFORM_LINUX_H
|
||||||
|
@ -25,10 +25,12 @@ extern "C" {
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <dirent.h>
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <locale.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -37,7 +39,8 @@ extern "C" {
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdbool.h>
|
#include <semaphore.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -45,21 +48,19 @@ extern "C" {
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <sys/sendfile.h>
|
#include <sys/sendfile.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
#include <locale.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#define taosCloseSocket(x) \
|
#define taosCloseSocket(x) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -30,6 +30,7 @@ char* mgmtMeterGetTag(STabObj* pMeter, int32_t col, SSchema* pTagColSchema);
|
||||||
int32_t mgmtFindTagCol(STabObj * pMetric, const char * tagName);
|
int32_t mgmtFindTagCol(STabObj * pMetric, const char * tagName);
|
||||||
|
|
||||||
int32_t mgmtGetTagsLength(STabObj* pMetric, int32_t col);
|
int32_t mgmtGetTagsLength(STabObj* pMetric, int32_t col);
|
||||||
|
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
|
||||||
|
|
||||||
int32_t mgmtRetrieveMetersFromMetric(SMetricMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes);
|
int32_t mgmtRetrieveMetersFromMetric(SMetricMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes);
|
||||||
int32_t mgmtDoJoin(SMetricMetaMsg* pMetricMetaMsg, tQueryResultset* pRes);
|
int32_t mgmtDoJoin(SMetricMetaMsg* pMetricMetaMsg, tQueryResultset* pRes);
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "mgmt.h"
|
#include "mgmt.h"
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include "mgmtBalance.h"
|
#include "mgmtBalance.h"
|
||||||
|
#include "mgmtUtil.h"
|
||||||
#include "tschemautil.h"
|
#include "tschemautil.h"
|
||||||
|
|
||||||
void *dbSdb = NULL;
|
void *dbSdb = NULL;
|
||||||
|
@ -373,10 +375,12 @@ int mgmtDropDbByName(SAcctObj *pAcct, char *name) {
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
mWarn("db:%s is not there", name);
|
mWarn("db:%s is not there", name);
|
||||||
// return TSDB_CODE_INVALID_DB;
|
// return TSDB_CODE_INVALID_DB;
|
||||||
return 0;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
|
return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
return mgmtDropDb(pDb);
|
return mgmtDropDb(pDb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,8 +688,10 @@ int mgmtDropMeter(SDbObj *pDb, char *meterId, int ignore) {
|
||||||
|
|
||||||
pAcct = mgmtGetAcct(pDb->cfg.acct);
|
pAcct = mgmtGetAcct(pDb->cfg.acct);
|
||||||
|
|
||||||
// 0.sys
|
// 0.log
|
||||||
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
|
return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
if (mgmtIsNormalMeter(pMeter)) {
|
if (mgmtIsNormalMeter(pMeter)) {
|
||||||
return dropMeterImp(pDb, pMeter, pAcct);
|
return dropMeterImp(pDb, pMeter, pAcct);
|
||||||
|
@ -719,8 +721,8 @@ int mgmtAlterMeter(SDbObj *pDb, SAlterTableMsg *pAlter) {
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0.sys
|
// 0.log
|
||||||
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
|
||||||
|
|
||||||
if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
|
if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
|
||||||
if (!mgmtIsNormalMeter(pMeter) || !mgmtMeterCreateFromMetric(pMeter)) {
|
if (!mgmtIsNormalMeter(pMeter) || !mgmtMeterCreateFromMetric(pMeter)) {
|
||||||
|
@ -833,6 +835,7 @@ static void removeMeterFromMetricIndex(STabObj *pMetric, STabObj *pMeter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tSkipListDestroyKey(&key);
|
||||||
if (num != 0) {
|
if (num != 0) {
|
||||||
free(pRes);
|
free(pRes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,3 +87,10 @@ int32_t mgmtGetTagsLength(STabObj* pMetric, int32_t col) { // length before col
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mgmtCheckIsMonitorDB(char *db, char *monitordb) {
|
||||||
|
char dbName[TSDB_DB_NAME_LEN + 1] = {0};
|
||||||
|
extractDBName(db, dbName);
|
||||||
|
|
||||||
|
return (strncasecmp(dbName, monitordb, strlen(dbName)) == 0);
|
||||||
|
}
|
||||||
|
|
|
@ -3436,9 +3436,18 @@ void pointInterpSupporterSetData(SQInfo *pQInfo, SPointInterpoSupporter *pPointI
|
||||||
if (pQuery->interpoType == TSDB_INTERPO_SET_VALUE) {
|
if (pQuery->interpoType == TSDB_INTERPO_SET_VALUE) {
|
||||||
for (int32_t i = 0; i < pQuery->numOfOutputCols; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfOutputCols; ++i) {
|
||||||
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
||||||
|
|
||||||
|
// only the function of interp needs the corresponding information
|
||||||
|
if (pCtx->functionId != TSDB_FUNC_INTERP) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCtx->numOfParams = 4;
|
||||||
|
|
||||||
SInterpInfo * pInterpInfo = (SInterpInfo *)pRuntimeEnv->pCtx[i].aOutputBuf;
|
SInterpInfo * pInterpInfo = (SInterpInfo *)pRuntimeEnv->pCtx[i].aOutputBuf;
|
||||||
|
|
||||||
pInterpInfo->pInterpDetail = calloc(1, sizeof(SInterpInfoDetail));
|
pInterpInfo->pInterpDetail = calloc(1, sizeof(SInterpInfoDetail));
|
||||||
|
|
||||||
SInterpInfoDetail *pInterpDetail = pInterpInfo->pInterpDetail;
|
SInterpInfoDetail *pInterpDetail = pInterpInfo->pInterpDetail;
|
||||||
|
|
||||||
// for primary timestamp column, set the flag
|
// for primary timestamp column, set the flag
|
||||||
|
|
|
@ -419,7 +419,7 @@ void vnodeExecuteRetrieveReq(SSchedMsg *pSched) {
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
pRsp->offset = htobe64(vnodeGetOffsetVal(pRetrieve->qhandle));
|
pRsp->offset = htobe64(vnodeGetOffsetVal(pRetrieve->qhandle));
|
||||||
pRsp->useconds = ((SQInfo *)(pRetrieve->qhandle))->useconds;
|
pRsp->useconds = htobe64(((SQInfo *)(pRetrieve->qhandle))->useconds);
|
||||||
} else {
|
} else {
|
||||||
pRsp->offset = 0;
|
pRsp->offset = 0;
|
||||||
pRsp->useconds = 0;
|
pRsp->useconds = 0;
|
||||||
|
|
|
@ -536,6 +536,11 @@ void tsInitGlobalConfig() {
|
||||||
0, 2, 0, TSDB_CFG_UTYPE_NONE);
|
0, 2, 0, TSDB_CFG_UTYPE_NONE);
|
||||||
// 0-any, 1-mgmt, 2-dnode
|
// 0-any, 1-mgmt, 2-dnode
|
||||||
|
|
||||||
|
// timer
|
||||||
|
tsInitConfigOption(cfg++, "maxTmrCtrl", &taosMaxTmrCtrl, TSDB_CFG_VTYPE_INT,
|
||||||
|
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLUSTER,
|
||||||
|
8, 2048, 0, TSDB_CFG_UTYPE_NONE);
|
||||||
|
|
||||||
// time
|
// time
|
||||||
tsInitConfigOption(cfg++, "monitorInterval", &tsMonitorInterval, TSDB_CFG_VTYPE_INT,
|
tsInitConfigOption(cfg++, "monitorInterval", &tsMonitorInterval, TSDB_CFG_VTYPE_INT,
|
||||||
TSDB_CFG_CTYPE_B_CONFIG,
|
TSDB_CFG_CTYPE_B_CONFIG,
|
||||||
|
|
|
@ -82,12 +82,15 @@ typedef struct time_wheel_t {
|
||||||
} time_wheel_t;
|
} time_wheel_t;
|
||||||
|
|
||||||
uint32_t tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
|
uint32_t tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
|
||||||
|
uint32_t taosMaxTmrCtrl = 512;
|
||||||
|
|
||||||
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
|
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
|
||||||
static pthread_mutex_t tmrCtrlMutex;
|
static pthread_mutex_t tmrCtrlMutex;
|
||||||
static tmr_ctrl_t tmrCtrls[MAX_NUM_OF_TMRCTL];
|
static tmr_ctrl_t* tmrCtrls;
|
||||||
static tmr_ctrl_t* unusedTmrCtrl = NULL;
|
static tmr_ctrl_t* unusedTmrCtrl = NULL;
|
||||||
void* tmrQhandle;
|
static void* tmrQhandle;
|
||||||
|
static int numOfTmrCtrl = 0;
|
||||||
|
|
||||||
int taosTmrThreads = 1;
|
int taosTmrThreads = 1;
|
||||||
|
|
||||||
static uintptr_t nextTimerId = 0;
|
static uintptr_t nextTimerId = 0;
|
||||||
|
@ -129,7 +132,7 @@ static void unlockTimerList(timer_list_t* list) {
|
||||||
int64_t tid = taosGetPthreadId();
|
int64_t tid = taosGetPthreadId();
|
||||||
if (__sync_val_compare_and_swap_64(&(list->lockedBy), tid, 0) != tid) {
|
if (__sync_val_compare_and_swap_64(&(list->lockedBy), tid, 0) != tid) {
|
||||||
assert(false);
|
assert(false);
|
||||||
tmrError("trying to unlock a timer list not locked by current thread.");
|
tmrError("%d trying to unlock a timer list not locked by current thread.", tid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,13 +259,13 @@ static void processExpiredTimer(void* handle, void* arg) {
|
||||||
timer->executedBy = taosGetPthreadId();
|
timer->executedBy = taosGetPthreadId();
|
||||||
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
||||||
if (state == TIMER_STATE_WAITING) {
|
if (state == TIMER_STATE_WAITING) {
|
||||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] execution start.";
|
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] execution start.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
|
|
||||||
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
||||||
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
||||||
|
|
||||||
fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] execution end.";
|
fmt = "%s timer[id=%lld, fp=%p, param=%p] execution end.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
}
|
}
|
||||||
removeTimer(timer->id);
|
removeTimer(timer->id);
|
||||||
|
@ -270,18 +273,21 @@ static void processExpiredTimer(void* handle, void* arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addToExpired(tmr_obj_t* head) {
|
static void addToExpired(tmr_obj_t* head) {
|
||||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] expired";
|
const char* fmt = "%s adding expired timer[id=%lld, fp=%p, param=%p] to queue.";
|
||||||
|
|
||||||
while (head != NULL) {
|
while (head != NULL) {
|
||||||
tmrTrace(fmt, head->ctrl->label, head->id, head->fp, head->param);
|
uintptr_t id = head->id;
|
||||||
|
|
||||||
tmr_obj_t* next = head->next;
|
tmr_obj_t* next = head->next;
|
||||||
|
tmrTrace(fmt, head->ctrl->label, id, head->fp, head->param);
|
||||||
|
|
||||||
SSchedMsg schedMsg;
|
SSchedMsg schedMsg;
|
||||||
schedMsg.fp = NULL;
|
schedMsg.fp = NULL;
|
||||||
schedMsg.tfp = processExpiredTimer;
|
schedMsg.tfp = processExpiredTimer;
|
||||||
schedMsg.ahandle = head;
|
schedMsg.ahandle = head;
|
||||||
schedMsg.thandle = NULL;
|
schedMsg.thandle = NULL;
|
||||||
taosScheduleTask(tmrQhandle, &schedMsg);
|
taosScheduleTask(tmrQhandle, &schedMsg);
|
||||||
|
|
||||||
|
tmrTrace("timer[id=%lld] has been added to queue.", id);
|
||||||
head = next;
|
head = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +301,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
|
||||||
timer->ctrl = ctrl;
|
timer->ctrl = ctrl;
|
||||||
addTimer(timer);
|
addTimer(timer);
|
||||||
|
|
||||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] started";
|
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] started";
|
||||||
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
|
|
||||||
if (mseconds == 0) {
|
if (mseconds == 0) {
|
||||||
|
@ -318,7 +324,7 @@ tmr_h taosTmrStart(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle
|
||||||
|
|
||||||
tmr_obj_t* timer = (tmr_obj_t*)calloc(1, sizeof(tmr_obj_t));
|
tmr_obj_t* timer = (tmr_obj_t*)calloc(1, sizeof(tmr_obj_t));
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
tmrError("failed to allocated memory for new timer object.");
|
tmrError("%s failed to allocated memory for new timer object.", ctrl->label);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +395,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||||
// we cannot guarantee the thread safety of the timr in all other cases.
|
// we cannot guarantee the thread safety of the timr in all other cases.
|
||||||
reusable = true;
|
reusable = true;
|
||||||
}
|
}
|
||||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] is cancelled.";
|
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] is cancelled.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
} else if (state != TIMER_STATE_EXPIRED) {
|
} else if (state != TIMER_STATE_EXPIRED) {
|
||||||
// timer already stopped or cancelled, has nothing to do in this case
|
// timer already stopped or cancelled, has nothing to do in this case
|
||||||
|
@ -400,7 +406,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||||
} else {
|
} else {
|
||||||
assert(timer->executedBy != taosGetPthreadId());
|
assert(timer->executedBy != taosGetPthreadId());
|
||||||
|
|
||||||
const char* fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] fired, waiting...";
|
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] fired, waiting...";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
|
|
||||||
for (int i = 1; atomic_load_8(&timer->state) != TIMER_STATE_STOPPED; i++) {
|
for (int i = 1; atomic_load_8(&timer->state) != TIMER_STATE_STOPPED; i++) {
|
||||||
|
@ -409,7 +415,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt = "timer[label=%s, id=%lld, fp=%p, param=%p] stopped.";
|
fmt = "%s timer[id=%lld, fp=%p, param=%p] stopped.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +454,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
||||||
bool stopped = false;
|
bool stopped = false;
|
||||||
tmr_obj_t* timer = findTimer(id);
|
tmr_obj_t* timer = findTimer(id);
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
tmrTrace("timer[id=%lld] does not exist", id);
|
tmrTrace("%s timer[id=%lld] does not exist", ctrl->label, id);
|
||||||
} else {
|
} else {
|
||||||
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
uint8_t state = __sync_val_compare_and_swap_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
||||||
if (!doStopTimer(timer, state)) {
|
if (!doStopTimer(timer, state)) {
|
||||||
|
@ -463,7 +469,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
||||||
return stopped;
|
return stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrTrace("timer[id=%lld] is reused", timer->id);
|
tmrTrace("%s timer[id=%lld] is reused", ctrl->label, timer->id);
|
||||||
|
|
||||||
// wait until there's no other reference to this timer,
|
// wait until there's no other reference to this timer,
|
||||||
// so that we can reuse this timer safely.
|
// so that we can reuse this timer safely.
|
||||||
|
@ -481,7 +487,13 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosTmrModuleInit(void) {
|
static void taosTmrModuleInit(void) {
|
||||||
for (int i = 0; i < tListLen(tmrCtrls) - 1; ++i) {
|
tmrCtrls = malloc(sizeof(tmr_ctrl_t) * taosMaxTmrCtrl);
|
||||||
|
if (tmrCtrls == NULL) {
|
||||||
|
tmrError("failed to allocate memory for timer controllers.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < taosMaxTmrCtrl - 1; ++i) {
|
||||||
tmr_ctrl_t* ctrl = tmrCtrls + i;
|
tmr_ctrl_t* ctrl = tmrCtrls + i;
|
||||||
ctrl->next = ctrl + 1;
|
ctrl->next = ctrl + 1;
|
||||||
}
|
}
|
||||||
|
@ -526,17 +538,18 @@ void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* lab
|
||||||
tmr_ctrl_t* ctrl = unusedTmrCtrl;
|
tmr_ctrl_t* ctrl = unusedTmrCtrl;
|
||||||
if (ctrl != NULL) {
|
if (ctrl != NULL) {
|
||||||
unusedTmrCtrl = ctrl->next;
|
unusedTmrCtrl = ctrl->next;
|
||||||
|
numOfTmrCtrl++;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&tmrCtrlMutex);
|
pthread_mutex_unlock(&tmrCtrlMutex);
|
||||||
|
|
||||||
if (ctrl == NULL) {
|
if (ctrl == NULL) {
|
||||||
tmrError("too many timer controllers, failed to create timer controller[label=%s].", label);
|
tmrError("%s too many timer controllers, failed to create timer controller.", label);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ctrl->label, label, sizeof(ctrl->label));
|
strncpy(ctrl->label, label, sizeof(ctrl->label));
|
||||||
ctrl->label[sizeof(ctrl->label) - 1] = 0;
|
ctrl->label[sizeof(ctrl->label) - 1] = 0;
|
||||||
tmrTrace("timer controller[label=%s] is initialized.", label);
|
tmrTrace("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
|
||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,11 +557,12 @@ void taosTmrCleanUp(void* handle) {
|
||||||
tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle;
|
tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle;
|
||||||
assert(ctrl != NULL && ctrl->label[0] != 0);
|
assert(ctrl != NULL && ctrl->label[0] != 0);
|
||||||
|
|
||||||
tmrTrace("timer controller[label=%s] is cleaned up.", ctrl->label);
|
tmrTrace("%s timer controller is cleaned up.", ctrl->label);
|
||||||
ctrl->label[0] = 0;
|
ctrl->label[0] = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&tmrCtrlMutex);
|
pthread_mutex_lock(&tmrCtrlMutex);
|
||||||
ctrl->next = unusedTmrCtrl;
|
ctrl->next = unusedTmrCtrl;
|
||||||
|
numOfTmrCtrl--;
|
||||||
unusedTmrCtrl = ctrl;
|
unusedTmrCtrl = ctrl;
|
||||||
pthread_mutex_unlock(&tmrCtrlMutex);
|
pthread_mutex_unlock(&tmrCtrlMutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,13 +406,6 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
|
||||||
return rename(fullPath, *dstPath);
|
return rename(fullPath, *dstPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosCheckDbName(char *db, char *monitordb) {
|
|
||||||
char *pos = strchr(db, '.');
|
|
||||||
if (pos == NULL) return false;
|
|
||||||
|
|
||||||
return strncasecmp(pos + 1, monitordb, strlen(monitordb)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
|
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||||
#ifdef USE_LIBICONV
|
#ifdef USE_LIBICONV
|
||||||
iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
|
iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
|
||||||
|
|
Loading…
Reference in New Issue