[td-10564] refactor and add test cases.

This commit is contained in:
Haojun Liao 2021-12-10 16:12:28 +08:00
parent 770e03318a
commit cfc632893a
18 changed files with 360 additions and 304 deletions

View File

@ -185,7 +185,7 @@ extern SDiskCfg tsDiskCfg[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
void taosInitGlobalCfg(); void taosInitGlobalCfg();
int32_t taosCheckGlobalCfg(); int32_t taosCheckAndPrintCfg();
int32_t taosCfgDynamicOptions(char *msg); int32_t taosCfgDynamicOptions(char *msg);
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId); bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
void taosAddDataDir(int index, char *v1, int level, int primary); void taosAddDataDir(int index, char *v1, int level, int primary);

View File

@ -57,7 +57,7 @@ int64_t taosGetPthreadId(pthread_t thread);
void taosResetPthread(pthread_t* thread); void taosResetPthread(pthread_t* thread);
bool taosComparePthread(pthread_t first, pthread_t second); bool taosComparePthread(pthread_t first, pthread_t second);
int32_t taosGetPId(); int32_t taosGetPId();
int32_t taosGetCurrentAPPName(char* name, int32_t* len); int32_t taosGetAppName(char* name, int32_t* len);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -20,7 +20,7 @@
extern "C" { extern "C" {
#endif #endif
#define TSDB_CFG_MAX_NUM 123 #define TSDB_CFG_MAX_NUM 119
#define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41 #define TSDB_CFG_VALUE_LEN 41
@ -83,11 +83,11 @@ extern int32_t tsGlobalConfigNum;
extern char * tsCfgStatusStr[]; extern char * tsCfgStatusStr[];
void taosReadGlobalLogCfg(); void taosReadGlobalLogCfg();
int32_t taosReadGlobalCfg(); int32_t taosReadCfgFromFile();
void taosPrintGlobalCfg(); void taosPrintCfg();
void taosDumpGlobalCfg(); void taosDumpGlobalCfg();
void taosInitConfigOption(SGlobalCfg cfg); void taosAddConfigOption(SGlobalCfg cfg);
SGlobalCfg *taosGetConfigOption(const char *option); SGlobalCfg *taosGetConfigOption(const char *option);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -10,3 +10,5 @@ target_link_libraries(
INTERFACE api INTERFACE api
PRIVATE os util common transport parser PRIVATE os util common transport parser
) )
ADD_SUBDIRECTORY(test)

View File

@ -61,7 +61,7 @@ typedef struct SAppInstInfo {
typedef struct SAppInfo { typedef struct SAppInfo {
int64_t startTime; int64_t startTime;
char appName[TSDB_APPNAME_LEN]; char appName[TSDB_APP_NAME_LEN];
char *ep; char *ep;
int32_t pid; int32_t pid;
int32_t numOfThreads; int32_t numOfThreads;
@ -102,11 +102,23 @@ typedef struct SRequestObj {
void *pInfo; // sql parse info, generated by parser module void *pInfo; // sql parse info, generated by parser module
} SRequestObj; } SRequestObj;
extern int32_t tscReqRef;
extern void *tscQhandle;
extern int32_t tscConnRef;
extern void *tscRpcCache;
extern pthread_mutex_t rpcObjMutex;
void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t port); void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t port);
void destroyTscObj(void* pTscObj); void destroyTscObj(void* pTscObj);
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
void destroyRequest(void* p);
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port); TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
void taos_init_imp(void);
int taos_options_imp(TSDB_OPTION option, const char *pStr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -13,11 +13,52 @@
* 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 "taos.h" #include "os.h"
#include "tdef.h"
//TAOS_RES *taos_query(TAOS *taos, const char *sql) { #include "tglobal.h"
// #include "clientInt.h"
//} #include "tscLog.h"
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
int32_t p = (port != 0)? port:tsServerPort;
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
if (user == NULL) {
user = TSDB_DEFAULT_USER;
}
if (pass == NULL) {
pass = TSDB_DEFAULT_PASS;
}
return taos_connect_internal(ip, user, pass, NULL, db, p);
}
TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port) {
tscDebug("try to connect to %s:%u by auth, user:%s db:%s", ip, port, user, db);
if (user == NULL) {
user = TSDB_DEFAULT_USER;
}
if (auth == NULL) {
tscError("No auth info is given, failed to connect to server");
return NULL;
}
return taos_connect_internal(ip, user, NULL, auth, db, port);
}
TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen, const char *db, int dbLen, uint16_t port) {
char ipStr[TSDB_EP_LEN] = {0};
char dbStr[TSDB_DB_NAME_LEN] = {0};
char userStr[TSDB_USER_LEN] = {0};
char passStr[TSDB_KEY_LEN] = {0};
strncpy(ipStr, ip, MIN(TSDB_EP_LEN - 1, ipLen));
strncpy(userStr, user, MIN(TSDB_USER_LEN - 1, userLen));
strncpy(passStr, pass, MIN(TSDB_KEY_LEN - 1, passLen));
strncpy(dbStr, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
return taos_connect(ipStr, userStr, passStr, dbStr, port);
}
int taos_init() { return 0; }
void taos_cleanup(void) {}

View File

@ -33,11 +33,9 @@ static bool validateDbName(const char* db) {
return stringLengthCheck(db, TSDB_DB_NAME_LEN - 1); return stringLengthCheck(db, TSDB_DB_NAME_LEN - 1);
} }
static SRequestObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param); static STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param);
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port) { TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port) {
STscObj *pObj = NULL;
if (!validateUserName(user)) { if (!validateUserName(user)) {
terrno = TSDB_CODE_TSC_INVALID_USER_LENGTH; terrno = TSDB_CODE_TSC_INVALID_USER_LENGTH;
return NULL; return NULL;
@ -81,34 +79,7 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
} }
} }
SRequestObj *pRequest = taosConnectImpl(ip, user, auth, db, port, NULL, NULL); return taosConnectImpl(ip, user, auth, db, port, NULL, NULL);
if (pRequest != NULL) {
pObj = pRequest->pTscObj;
pRequest->body.fp = NULL;
pRequest->body.param = pRequest;
// tscBuildAndSendRequest(pRequest, NULL);
tsem_wait(&pRequest->body.rspSem);
if (pRequest->code != TSDB_CODE_SUCCESS) {
if (pRequest->code == TSDB_CODE_RPC_FQDN_ERROR) {
printf("taos connect failed, reason: %s\n\n", taos_errstr(pRequest));
} else {
printf("taos connect failed, reason: %s.\n\n", tstrerror(terrno));
}
taos_free_result(pRequest);
taos_close(pObj);
return NULL;
}
// tscDebug("%p DB connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj, pObj->pRpcObj->pDnodeConn);
taos_free_result(pRequest);
return pObj;
}
return NULL;
} }
int initEpSetFromCfg(const char *firstEp, const char *secondEp, SRpcCorEpSet *pEpSet) { int initEpSetFromCfg(const char *firstEp, const char *secondEp, SRpcCorEpSet *pEpSet) {
@ -147,7 +118,7 @@ int initEpSetFromCfg(const char *firstEp, const char *secondEp, SRpcCorEpSet *pE
return 0; return 0;
} }
SRequestObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param) { STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param) {
if (taos_init() != TSDB_CODE_SUCCESS) { if (taos_init() != TSDB_CODE_SUCCESS) {
return NULL; return NULL;
} }
@ -155,36 +126,40 @@ SRequestObj* taosConnectImpl(const char *ip, const char *user, const char *auth,
STscObj *pObj = createTscObj(user, auth, ip, port); STscObj *pObj = createTscObj(user, auth, ip, port);
if (NULL == pObj) { if (NULL == pObj) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return pObj;
} }
SRequestObj *pRequest = (SRequestObj *)calloc(1, sizeof(SRequestObj)); // void *pRpcObj = NULL;
if (NULL == pRequest) { //
// char rpcKey[512] = {0};
// snprintf(rpcKey, sizeof(rpcKey), "%s:%s:%s:%d", user, auth, ip, port);
// if (tscAcquireRpc(rpcKey, user, auth, &pRpcObj) != 0) {
// terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
// return NULL;
// }
SRequestObj *pRequest = createRequest(pObj, fp, param, TSDB_SQL_CONNECT);
if (pRequest == NULL) {
destroyTscObj(pObj);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
free(pObj); }
// tscBuildAndSendRequest(pRequest, NULL);
// tsem_wait(&pRequest->body.rspSem);
if (pRequest->code != TSDB_CODE_SUCCESS) {
const char *errorMsg = (pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)
? taos_errstr(pRequest)
: tstrerror(terrno);
printf("connect failed, reason: %s\n\n", errorMsg);
taos_free_result(pRequest);
taos_close(pObj);
return NULL; return NULL;
} }
void *pRpcObj = NULL; // tscDebug("0x%"PRIx64" connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj,
// pObj->pRpcObj->pDnodeConn);
char rpcKey[512] = {0}; destroyRequest(pRequest);
snprintf(rpcKey, sizeof(rpcKey), "%s:%s:%s:%d", user, auth, ip, port); return pObj;
if (tscAcquireRpc(rpcKey, user, auth, &pRpcObj) != 0) {
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return NULL;
}
pObj->pRpcObj = (SRpcObj *)pRpcObj;
pRequest->pTscObj = pObj;
pRequest->body.fp = fp;
pRequest->body.param = param;
pRequest->type = TSDB_SQL_CONNECT;
tsem_init(&pRequest->body.rspSem, 0, 0);
pObj->id = taosAddRef(tscConn, pObj);
registerSqlObj(pRequest);
return pRequest;
} }

View File

@ -31,14 +31,12 @@
#define TSC_VAR_RELEASED 0 #define TSC_VAR_RELEASED 0
SAppInfo appInfo; SAppInfo appInfo;
int32_t sentinel = TSC_VAR_NOT_RELEASE;
int32_t tscReqRef = -1; int32_t tscReqRef = -1;
void *tscQhandle; void *tscQhandle;
int32_t tscConnRef = -1; int32_t tscConnRef = -1;
void *tscRpcCache; // TODO removed from here. void *tscRpcCache; // TODO removed from here.
static pthread_mutex_t rpcObjMutex; // mutex to protect open the rpc obj concurrently pthread_mutex_t rpcObjMutex; // mutex to protect open the rpc obj concurrently
static pthread_once_t tscinit = PTHREAD_ONCE_INIT; static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
static pthread_mutex_t setConfMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t setConfMutex = PTHREAD_MUTEX_INITIALIZER;
@ -104,7 +102,6 @@ void* tscAcquireRpc(const char *key, const char *user, const char *secretEncrypt
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
return pRpcObj; return pRpcObj;
#endif #endif
} }
void destroyTscObj(void *pTscObj) { void destroyTscObj(void *pTscObj) {
@ -139,6 +136,72 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
tstrncpy(pObj->pass, auth, len); tstrncpy(pObj->pass, auth, len);
pthread_mutex_init(&pObj->mutex, NULL); pthread_mutex_init(&pObj->mutex, NULL);
pObj->id = taosAddRef(tscConnRef, pObj);
}
static void registerRequest(SRequestObj* pRequest) {
STscObj*pTscObj = (STscObj*) taosAcquireRef(tscConnRef, pRequest->pTscObj->id);
assert(pTscObj != NULL);
// connection has been released already, abort creating request.
pRequest->self = taosAddRef(tscReqRef, pRequest);
int32_t num = atomic_add_fetch_32(&pTscObj->numOfReqs, 1);
SInstanceActivity* pActivity = &pTscObj->pAppInfo->summary;
int32_t total = atomic_add_fetch_32(&pActivity->totalRequests, 1);
int32_t currentInst = atomic_add_fetch_32(&pActivity->currentRequests, 1);
tscDebug("0x%"PRIx64" new Request from 0x%"PRIx64", current:%d, app current:%d, total:%d", pRequest->self, pRequest->pTscObj->id, num, currentInst, total);
}
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type) {
assert(pObj != NULL);
SRequestObj *pRequest = (SRequestObj *)calloc(1, sizeof(SRequestObj));
if (NULL == pRequest) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL;
}
// TODO generated request uuid
pRequest->requestId = 0;
pRequest->type = type;
pRequest->pTscObj = pObj;
pRequest->body.fp = fp;
pRequest->body.param = param;
tsem_init(&pRequest->body.rspSem, 0, 0);
registerRequest(pRequest);
}
static void deregisterRequest(SRequestObj* pRequest) {
assert(pRequest != NULL);
STscObj* pTscObj = pRequest->pTscObj;
SInstanceActivity* pActivity = &pTscObj->pAppInfo->summary;
taosReleaseRef(tscReqRef, pRequest->self);
int32_t currentInst = atomic_sub_fetch_32(&pActivity->currentRequests, 1);
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
tscDebug("0x%"PRIx64" free Request from 0x%"PRIx64", current:%d, app current:%d", pRequest->self, pTscObj->id, num, currentInst);
taosReleaseRef(tscConnRef, pTscObj->id);
}
void destroyRequest(void* p) {
assert(p != NULL);
SRequestObj* pRequest = *(SRequestObj**)p;
assert(RID_VALID(pRequest->self));
tfree(pRequest->msgBuf);
tfree(pRequest->sqlstr);
tfree(pRequest->pInfo);
deregisterRequest(pRequest);
} }
static void tscInitLogFile() { static void tscInitLogFile() {
@ -167,11 +230,10 @@ void taos_init_imp(void) {
deltaToUtcInitOnce(); deltaToUtcInitOnce();
taosInitGlobalCfg(); taosInitGlobalCfg();
taosReadGlobalCfg(); taosReadCfgFromFile();
tscInitLogFile(); tscInitLogFile();
if (taosCheckAndPrintCfg()) {
if (taosCheckGlobalCfg()) {
tscInitRes = -1; tscInitRes = -1;
return; return;
} }
@ -179,8 +241,7 @@ void taos_init_imp(void) {
taosInitNotes(); taosInitNotes();
rpcInit(); rpcInit();
tscDebug("starting to initialize TAOS client ..."); tscDebug("starting to initialize TAOS client ...\nLocal End Point is:%s", tsLocalEp);
tscDebug("Local End Point is:%s", tsLocalEp);
taosSetCoreDump(true); taosSetCoreDump(true);
@ -202,55 +263,16 @@ void taos_init_imp(void) {
pthread_mutex_init(&rpcObjMutex, NULL); pthread_mutex_init(&rpcObjMutex, NULL);
tscConnRef = taosOpenRef(200, destroyTscObj); tscConnRef = taosOpenRef(200, destroyTscObj);
tscReqRef = taosOpenRef(40960, tscFreeRegisteredSqlObj); tscReqRef = taosOpenRef(40960, destroyRequest);
taosGetCurrentAPPName(appInfo.appName, NULL); taosGetAppName(appInfo.appName, NULL);
appInfo.pid = taosGetPId(); appInfo.pid = taosGetPId();
appInfo.startTime = taosGetTimestampMs(); appInfo.startTime = taosGetTimestampMs();
tscDebug("client is initialized successfully"); tscDebug("client is initialized successfully");
} }
int taos_init() { int taos_options_imp(TSDB_OPTION option, const char *pStr) {
pthread_once(&tscinit, taos_init_imp);
return tscInitRes;
}
// this function may be called by user or system, or by both simultaneously.
void taos_cleanup(void) {
tscDebug("start to cleanup client environment");
if (atomic_val_compare_exchange_32(&sentinel, TSC_VAR_NOT_RELEASE, TSC_VAR_RELEASED) != TSC_VAR_NOT_RELEASE) {
return;
}
int32_t id = tscReqRef;
tscReqRef = -1;
taosCloseRef(id);
void* p = tscQhandle;
tscQhandle = NULL;
taosCleanUpScheduler(p);
id = tscConnRef;
tscConnRef = -1;
taosCloseRef(id);
p = tscRpcCache;
tscRpcCache = NULL;
if (p != NULL) {
taosCacheCleanup(p);
pthread_mutex_destroy(&rpcObjMutex);
}
pthread_mutex_destroy(&setConfMutex);
rpcCleanup();
taosCloseLog();
}
static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
SGlobalCfg *cfg = NULL; SGlobalCfg *cfg = NULL;
switch (option) { switch (option) {
@ -405,22 +427,6 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
return 0; return 0;
} }
int taos_options(TSDB_OPTION option, const void *arg, ...) {
static int32_t lock = 0;
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
if (i % 1000 == 0) {
tscInfo("haven't acquire lock after spin %d times.", i);
sched_yield();
}
}
int ret = taos_options_imp(option, (const char*)arg);
atomic_store_32(&lock, 0);
return ret;
}
#if 0 #if 0
#include "cJSON.h" #include "cJSON.h"
static setConfRet taos_set_config_imp(const char *config){ static setConfRet taos_set_config_imp(const char *config){

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* 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/>.
*/
#include <gtest/gtest.h>
#include <iostream>
#include "tglobal.h"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "taos.h"
namespace {
} // namespace
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(testCase, driverInit_Test) {
taos_init();
}

View File

@ -1,4 +1,6 @@
#include "os.h"
#include "tep.h"
#include "tglobal.h"
int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) { int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) {
*port = 0; *port = 0;

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,7 @@ int dmnReadConfig(const char *path) {
return -1; return -1;
} }
if (taosCheckGlobalCfg() != 0) { if (taosCheckAndPrintCfg() != 0) {
uError("failed to check global config"); uError("failed to check global config");
return -1; return -1;
} }

View File

@ -42,7 +42,7 @@ bool taosComparePthread(pthread_t first, pthread_t second) { return first.p == s
int32_t taosGetPId() { return GetCurrentProcessId(); } int32_t taosGetPId() { return GetCurrentProcessId(); }
int32_t taosGetCurrentAPPName(char* name, int32_t* len) { int32_t taosGetAppName(char* name, int32_t* len) {
char filepath[1024] = {0}; char filepath[1024] = {0};
GetModuleFileName(NULL, filepath, MAX_PATH); GetModuleFileName(NULL, filepath, MAX_PATH);
@ -358,7 +358,7 @@ bool taosComparePthread(pthread_t first, pthread_t second) { return pthread_equa
int32_t taosGetPId() { return (int32_t)getpid(); } int32_t taosGetPId() { return (int32_t)getpid(); }
int32_t taosGetCurrentAPPName(char *name, int32_t *len) { int32_t taosGetAppName(char *name, int32_t *len) {
char buf[PATH_MAX + 1]; char buf[PATH_MAX + 1];
buf[0] = '\0'; buf[0] = '\0';
proc_name(getpid(), buf, sizeof(buf) - 1); proc_name(getpid(), buf, sizeof(buf) - 1);
@ -392,7 +392,7 @@ void taosResetPthread(pthread_t* thread) { *thread = 0; }
bool taosComparePthread(pthread_t first, pthread_t second) { return first == second; } bool taosComparePthread(pthread_t first, pthread_t second) { return first == second; }
int32_t taosGetPId() { return getpid(); } int32_t taosGetPId() { return getpid(); }
int32_t taosGetCurrentAPPName(char* name, int32_t* len) { int32_t taosGetAppName(char* name, int32_t* len) {
const char* self = "/proc/self/exe"; const char* self = "/proc/self/exe";
char path[PATH_MAX] = {0}; char path[PATH_MAX] = {0};

View File

@ -714,7 +714,7 @@ static void taosGetSystemLocale() { // get and set default locale
//printf("locale not configured, set to system default:%s", tsLocale); //printf("locale not configured, set to system default:%s", tsLocale);
} }
/* if user does not specify the charset, extract it from locale */ // if user does not specify the charset, extract it from locale
char *str = strrchr(tsLocale, sep); char *str = strrchr(tsLocale, sep);
if (str != NULL) { if (str != NULL) {
str++; str++;
@ -1118,13 +1118,13 @@ char *taosGetCmdlineByPID(int pid) {
SysNameInfo taosGetSysNameInfo() { SysNameInfo taosGetSysNameInfo() {
SysNameInfo info = {0}; SysNameInfo info = {0};
struct utsname buf; struct utsname uts;
if (!uname(&buf)) { if (!uname(&uts)) {
info.sysname = buf.sysname; info.sysname = strdup(uts.sysname);
info.sysname == buf.nodename; info.nodename = strdup(uts.nodename);
info.sysname = buf.release; info.release = strdup(uts.release);
info.sysname = buf.version; info.version = strdup(uts.version);
info.sysname = buf.machine; info.machine = strdup(uts.machine);
} }
return info; return info;

View File

@ -282,7 +282,7 @@ static void taosReadConfigOption(const char *option, char *value, char *value2,
} }
} }
void taosInitConfigOption(SGlobalCfg cfg) { void taosAddConfigOption(SGlobalCfg cfg) {
tsGlobalConfig[tsGlobalConfigNum++] = cfg; tsGlobalConfig[tsGlobalConfigNum++] = cfg;
} }
@ -335,7 +335,7 @@ void taosReadGlobalLogCfg() {
fclose(fp); fclose(fp);
} }
int32_t taosReadGlobalCfg() { int32_t taosReadCfgFromFile() {
char * line, *option, *value, *value2, *value3; char * line, *option, *value, *value2, *value3;
int olen, vlen, vlen2, vlen3; int olen, vlen, vlen2, vlen3;
char fileName[PATH_MAX] = {0}; char fileName[PATH_MAX] = {0};
@ -396,7 +396,7 @@ int32_t taosReadGlobalCfg() {
return 0; return 0;
} }
void taosPrintGlobalCfg() { void taosPrintCfg() {
uInfo(" taos config & system info:"); uInfo(" taos config & system info:");
uInfo("=================================="); uInfo("==================================");
@ -443,7 +443,6 @@ void taosPrintGlobalCfg() {
} }
taosPrintOsInfo(); taosPrintOsInfo();
// taosPrintDataDirCfg();
uInfo("=================================="); uInfo("==================================");
} }

View File

@ -112,7 +112,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen
static SLogBuff *taosLogBuffNew(int32_t bufSize); static SLogBuff *taosLogBuffNew(int32_t bufSize);
static void taosCloseLogByFd(int32_t oldFd); static void taosCloseLogByFd(int32_t oldFd);
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum); static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
extern void taosPrintGlobalCfg(); extern void taosPrintCfg();
static int32_t taosCompressFile(char *srcFileName, char *destFileName); static int32_t taosCompressFile(char *srcFileName, char *destFileName);
static int32_t taosStartLog() { static int32_t taosStartLog() {
@ -222,7 +222,7 @@ static void *taosThreadToOpenNewFile(void *param) {
uInfo(" new log file:%d is opened", tsLogObj.flag); uInfo(" new log file:%d is opened", tsLogObj.flag);
uInfo("=================================="); uInfo("==================================");
taosPrintGlobalCfg(); taosPrintCfg();
taosKeepOldLog(keepName); taosKeepOldLog(keepName);
return NULL; return NULL;

View File

@ -20,12 +20,10 @@
#include "tutil.h" #include "tutil.h"
#include "taoserror.h" #include "taoserror.h"
extern int8_t tscEmbedded; #define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }} #define tmrWarn(...) { if (tmrDebugFlag & DEBUG_WARN) { taosPrintLog("TMR WARN ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }} #define tmrInfo(...) { if (tmrDebugFlag & DEBUG_INFO) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrWarn(...) { if (tmrDebugFlag & DEBUG_WARN) { taosPrintLog("TMR WARN ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrInfo(...) { if (tmrDebugFlag & DEBUG_INFO) { taosPrintLog("TMR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
#define tmrDebug(...) { if (tmrDebugFlag & DEBUG_DEBUG) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }} #define tmrDebug(...) { if (tmrDebugFlag & DEBUG_DEBUG) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}
#define tmrTrace(...) { if (tmrDebugFlag & DEBUG_TRACE) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }} #define tmrTrace(...) { if (tmrDebugFlag & DEBUG_TRACE) { taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); }}