• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / taos-tools / 12929468645

23 Jan 2025 12:45PM UTC coverage: 74.929% (-0.3%) from 75.249%
12929468645

Pull #839

github

web-flow
Merge a7d9348b5 into 84c50c54f
Pull Request #839: FIX mixed query mode no need calc thread

395 of 526 new or added lines in 4 files covered. (75.1%)

294 existing lines in 7 files now uncovered.

12430 of 16589 relevant lines covered (74.93%)

330258.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/benchLog.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the MIT license as published by the Free Software
6
 * Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12

13
#include "bench.h"
14
#include "benchLog.h"
15

16

17
//
18
// -----------  log -----------
19
//
20

21

22
// --------  OS IMPL
23
#ifdef WINDOWS
24
typedef CRITICAL_SECTION     TdThreadMutex;      // windows api
25
typedef HANDLE               TdThreadMutexAttr;  // windows api
26
#else
27
typedef pthread_mutex_t      TdThreadMutex;
28
typedef pthread_mutexattr_t  TdThreadMutexAttr;
29
#endif
30

31

32
int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) {
42,197✔
33
#ifdef WINDOWS
34
  /**
35
   * Windows Server 2003 and Windows XP:  In low memory situations, InitializeCriticalSection can raise a
36
   * STATUS_NO_MEMORY exception. Starting with Windows Vista, this exception was eliminated and
37
   * InitializeCriticalSection always succeeds, even in low memory situations.
38
   */
39
  InitializeCriticalSection(mutex);
40
  return 0;
41
#else
42
  int32_t code = pthread_mutex_init(mutex, attr);
42,197✔
43
  if (code) {
42,199✔
44
    terrno = TAOS_SYSTEM_ERROR(code);
73✔
45
    return terrno;
×
46
  }
47
  return code;
42,126✔
48
#endif
49
}
50

51
int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) {
40,011✔
52
#ifdef WINDOWS
53
  DeleteCriticalSection(mutex);
54
  return 0;
55
#else
56
  int32_t code = pthread_mutex_destroy(mutex);
40,011✔
57
  if (code) {
40,017✔
58
    terrno = TAOS_SYSTEM_ERROR(code);
7✔
59
    return terrno;
×
60
  }
61
  return code;
40,010✔
62
#endif
63
}
64

65

66
int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
1,293,929✔
67
#ifdef WINDOWS
68
  EnterCriticalSection(mutex);
69
  return 0;
70
#else
71
  int32_t code = pthread_mutex_lock(mutex);
1,293,929✔
72
  if (code) {
1,294,825✔
UNCOV
73
    terrno = TAOS_SYSTEM_ERROR(code);
×
74
    return terrno;
×
75
  }
76
  return code;
1,294,937✔
77
#endif
78
}
79

80
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) {
1,294,877✔
81
#ifdef WINDOWS
82
  LeaveCriticalSection(mutex);
83
  return 0;
84
#else
85
  int32_t code = pthread_mutex_unlock(mutex);
1,294,877✔
86
  if (code) {
1,294,864✔
87
    terrno = TAOS_SYSTEM_ERROR(code);
51✔
88
    return terrno;
×
89
  }
90
  return code;
1,294,813✔
91
#endif
92
}
93

94
//  ------- interface api ---------
95
TdThreadMutex mutexs[LOG_COUNT];
96

97
// init log
98
bool initLog() {
208✔
99
    for (int32_t i = 0; i < LOG_COUNT; i++) {
832✔
100
        if (taosThreadMutexInit(&mutexs[i], NULL) != 0) {
624✔
101
            printf("taosThreadMutexInit i=%d failed.\n", i);
×
102
        }
103
    }
104
    return true;
208✔
105
}
106

107
// exit log
108
void exitLog() {
204✔
109
    for (int32_t i = 0; i < LOG_COUNT; i++) {
816✔
110
        taosThreadMutexDestroy(&mutexs[i]);
612✔
111
    }
112
}
204✔
113

114
// lock
115
void lockLog(int8_t idx) {
8,834✔
116
    taosThreadMutexLock(&mutexs[idx]);
8,834✔
117
}
8,833✔
118
// unlock
119
void unlockLog(int8_t idx) {
8,834✔
120
    taosThreadMutexUnlock(&mutexs[idx]);
8,834✔
121
}
8,834✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc