提交 3eb4dff0 编写于 作者: S Shengliang Guan

taoserror

上级 1929e5b6
此差异已折叠。
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "taoserror.h"
#define TAOS_ERROR_C #define TAOS_ERROR_C
...@@ -22,16 +24,12 @@ typedef struct { ...@@ -22,16 +24,12 @@ typedef struct {
const char* str; const char* str;
} STaosError; } STaosError;
#include "os.h"
#include "taoserror.h"
static threadlocal int32_t tsErrno; static threadlocal int32_t tsErrno;
int32_t* taosGetErrno() {
return &tsErrno; int32_t* taosGetErrno() { return &tsErrno; }
}
#ifdef TAOS_ERROR_C #ifdef TAOS_ERROR_C
#define TAOS_DEFINE_ERROR(name, msg) {.val = (name), .str=(msg)}, #define TAOS_DEFINE_ERROR(name, msg) {.val = (name), .str = (msg)},
#else #else
#define TAOS_DEFINE_ERROR(name, mod, code, msg) static const int32_t name = TAOS_DEF_ERROR_CODE(mod, code); #define TAOS_DEFINE_ERROR(name, mod, code, msg) static const int32_t name = TAOS_DEF_ERROR_CODE(mod, code);
#endif #endif
...@@ -374,8 +372,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_MSG_ERROR, "Task message error") ...@@ -374,8 +372,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_MSG_ERROR, "Task message error")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JOB_FREED, "Job already freed") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JOB_FREED, "Job already freed")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_STATUS_ERROR, "Task status error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_STATUS_ERROR, "Task status error")
// grant // grant
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, "DNode creation limited by licence") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, "DNode creation limited by licence")
...@@ -432,12 +428,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_CTG_OUT_OF_SERVICE, "catalog is out of ser ...@@ -432,12 +428,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_CTG_OUT_OF_SERVICE, "catalog is out of ser
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_STATUS_ERROR, "scheduler status error") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_STATUS_ERROR, "scheduler status error")
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal error") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal error")
#ifdef TAOS_ERROR_C #ifdef TAOS_ERROR_C
}; };
#endif #endif
static int tsCompareTaosError(const void* a, const void* b) { static int32_t taosCompareTaosError(const void* a, const void* b) {
const STaosError* x = (const STaosError*)a; const STaosError* x = (const STaosError*)a;
const STaosError* y = (const STaosError*)b; const STaosError* y = (const STaosError*)b;
if (x->val < y->val) { if (x->val < y->val) {
...@@ -450,11 +445,11 @@ static int tsCompareTaosError(const void* a, const void* b) { ...@@ -450,11 +445,11 @@ static int tsCompareTaosError(const void* a, const void* b) {
} }
static pthread_once_t tsErrorInit = PTHREAD_ONCE_INIT; static pthread_once_t tsErrorInit = PTHREAD_ONCE_INIT;
static void tsSortError(void) { static void tsSortError(void) {
qsort(errors, sizeof(errors)/sizeof(errors[0]), sizeof(errors[0]), tsCompareTaosError); qsort(errors, sizeof(errors) / sizeof(errors[0]), sizeof(errors[0]), taosCompareTaosError);
} }
const char* tstrerror(int32_t err) { const char* tstrerror(int32_t err) {
pthread_once(&tsErrorInit, tsSortError); pthread_once(&tsErrorInit, tsSortError);
...@@ -463,9 +458,11 @@ const char* tstrerror(int32_t err) { ...@@ -463,9 +458,11 @@ const char* tstrerror(int32_t err) {
return strerror(err & 0x0000ffff); return strerror(err & 0x0000ffff);
} }
size_t s = 0, e = sizeof(errors)/sizeof(errors[0]); int32_t s = 0;
int32_t e = sizeof(errors) / sizeof(errors[0]);
while (s < e) { while (s < e) {
size_t mid = (s + e) / 2; int32_t mid = (s + e) / 2;
int32_t val = errors[mid].val; int32_t val = errors[mid].val;
if (err > val) { if (err > val) {
s = mid + 1; s = mid + 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册