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

taosdata / TDengine / #4720

08 Sep 2025 08:43AM UTC coverage: 58.139% (-0.6%) from 58.762%
#4720

push

travis-ci

web-flow
Merge pull request #32881 from taosdata/enh/add-new-windows-ci

fix(ci): update workflow reference to use new Windows CI YAML

133181 of 292179 branches covered (45.58%)

Branch coverage included in aggregate %.

201691 of 283811 relevant lines covered (71.07%)

5442780.71 hits per line

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

81.13
/tools/taos-tools/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) {
59,091✔
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);
59,091✔
43
  if (code) {
59,096!
44
    terrno = TAOS_SYSTEM_ERROR(code);
×
45
    return terrno;
×
46
  }
47
  return code;
59,110✔
48
#endif
49
}
50

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

65

66
int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
2,866,861✔
67
#ifdef WINDOWS
68
  EnterCriticalSection(mutex);
69
  return 0;
70
#else
71
  int32_t code = pthread_mutex_lock(mutex);
2,866,861✔
72
  if (code) {
2,870,576✔
73
    terrno = TAOS_SYSTEM_ERROR(code);
466✔
74
    return terrno;
×
75
  }
76
  return code;
2,870,110✔
77
#endif
78
}
79

80
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) {
2,868,074✔
81
#ifdef WINDOWS
82
  LeaveCriticalSection(mutex);
83
  return 0;
84
#else
85
  int32_t code = pthread_mutex_unlock(mutex);
2,868,074✔
86
  if (code) {
2,870,730✔
87
    terrno = TAOS_SYSTEM_ERROR(code);
604✔
88
    return terrno;
×
89
  }
90
  return code;
2,870,126✔
91
#endif
92
}
93

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

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

107
// exit log
108
void exitLog() {
252✔
109
    for (int32_t i = 0; i < LOG_COUNT; i++) {
1,008✔
110
        taosThreadMutexDestroy(&mutexs[i]);
756✔
111
    }
112
}
252✔
113

114
// lock
115
void lockLog(int8_t idx) {
441,690✔
116
    taosThreadMutexLock(&mutexs[idx]);
441,690✔
117
}
441,692✔
118
// unlock
119
void unlockLog(int8_t idx) {
441,693✔
120
    taosThreadMutexUnlock(&mutexs[idx]);
441,693✔
121
}
441,691✔
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

© 2025 Coveralls, Inc