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

taosdata / TDengine / #3831

02 Apr 2025 01:14AM UTC coverage: 34.081% (-0.02%) from 34.097%
#3831

push

travis-ci

happyguoxy
test:alter gcda dir

148596 of 599532 branches covered (24.79%)

Branch coverage included in aggregate %.

222550 of 489473 relevant lines covered (45.47%)

1589752.67 hits per line

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

0.0
/source/util/src/tthread.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 GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software 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
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#define _DEFAULT_SOURCE
17
#include "tthread.h"
18

19
TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) {
×
20
  TdThread* pthread = (TdThread*)taosMemoryMalloc(sizeof(TdThread));
×
21
  if (pthread == NULL) {
×
22
    terrno = TSDB_CODE_OUT_OF_MEMORY;
×
23
    return NULL;
×
24
  }
25

26
  TdThreadAttr thattr;
27
  (void)taosThreadAttrInit(&thattr);
×
28
  (void)taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE);
×
29
  int32_t ret = taosThreadCreate(pthread, &thattr, __start_routine, param);
×
30
  (void)taosThreadAttrDestroy(&thattr);
×
31

32
  if (ret != 0) {
×
33
    taosMemoryFree(pthread);
×
34
    terrno = TAOS_SYSTEM_ERROR(ret);
×
35
    return NULL;
×
36
  }
37
  return pthread;
×
38
}
39

40
bool taosDestroyThread(TdThread* pthread) {
×
41
  if (pthread == NULL) return false;
×
42
  if (taosThreadRunning(pthread)) {
×
43
    (void)taosThreadCancel(*pthread);
×
44
    (void)taosThreadJoin(*pthread, NULL);
×
45
  }
46

47
  taosMemoryFree(pthread);
×
48
  return true;
×
49
}
50

51
bool taosThreadRunning(TdThread* pthread) {
×
52
  if (pthread == NULL) return false;
×
53
  int32_t ret = taosThreadKill(*pthread, 0);
×
54
  if (ret == ESRCH) return false;
×
55
  if (ret == EINVAL) return false;
×
56
  // alive
57
  return true;
×
58
}
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