Skip to content

Commit 7a38387

Browse files
authored
Add destroying pthread locks and cond. (#1761)
* Add destroying pthread locks and cond. * Add memory check on FreeBSD.
1 parent fd3c014 commit 7a38387

File tree

7 files changed

+19
-2
lines changed

7 files changed

+19
-2
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
run: |
1818
sudo apt-get update
1919
sudo apt-get install -y cmake g++ libgtest-dev make libssl-dev
20-
sudo apt-get install -y redis valgrind
20+
sudo apt-get install -y valgrind
2121
sudo apt-get install -y libsnappy-dev libzstd-dev liblz4-dev
2222
- uses: actions/checkout@v2
2323
- name: make
@@ -40,7 +40,7 @@ jobs:
4040
run: |
4141
sudo dnf -y update
4242
sudo dnf install -y cmake gcc-c++ gtest-devel make
43-
sudo dnf install -y openssl-devel redis valgrind
43+
sudo dnf install -y openssl-devel valgrind
4444
sudo dnf install -y snappy-devel libzstd-devel lz4-devel zlib-devel
4545
- name: make
4646
run: make KAFKA=y
@@ -63,6 +63,7 @@ jobs:
6363
prepare: |
6464
pkg update -f
6565
pkg install -y cmake gmake gcc pkgconf openssl devel/googletest
66+
pkg install -y valgrind
6667
pkg install -y snappy zstd liblz4
6768
run: |
6869
freebsd-version

src/kernel/thrdpool.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ static void __thrdpool_terminate(int in_pool, thrdpool_t *pool)
112112
pthread_mutex_unlock(&pool->mutex);
113113
if (!pthread_equal(pool->tid, __zero_tid))
114114
pthread_join(pool->tid, NULL);
115+
116+
pthread_cond_destroy(&term);
115117
}
116118

117119
static int __thrdpool_create_threads(size_t nthreads, thrdpool_t *pool)

src/manager/UpstreamManager.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class __UpstreamManager
4949
{
5050
for (UPSGroupPolicy *policy : this->upstream_policies)
5151
delete policy;
52+
53+
pthread_mutex_destroy(&mutex);
5254
}
5355

5456
pthread_mutex_t mutex;

src/manager/WFGlobal.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ class __ExecManager
461461
kv.second->deinit();
462462
delete kv.second;
463463
}
464+
465+
pthread_rwlock_destroy(&rwlock_);
464466
}
465467

466468
private:

src/nameservice/UpstreamPolicies.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class EndpointGroup
3838
this->weight = 0;
3939
}
4040

41+
~EndpointGroup()
42+
{
43+
pthread_mutex_destroy(&this->mutex);
44+
}
45+
4146
EndpointAddress *get_one(WFNSTracing *tracing);
4247
EndpointAddress *get_one_backup(WFNSTracing *tracing);
4348

src/nameservice/WFNameService.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,7 @@ WFNameService::~WFNameService()
141141
rb_erase(&entry->rb, &this->root);
142142
free(entry);
143143
}
144+
145+
pthread_rwlock_destroy(&this->rwlock);
144146
}
145147

src/nameservice/WFServiceGovernance.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ WFServiceGovernance::~WFServiceGovernance()
5252
{
5353
for (EndpointAddress *addr : this->servers)
5454
delete addr;
55+
56+
pthread_rwlock_destroy(&this->rwlock);
57+
pthread_mutex_destroy(&this->breaker_lock);
5558
}
5659

5760
PolicyAddrParams::PolicyAddrParams()

0 commit comments

Comments
 (0)