Skip to content

Commit

Permalink
fix bug: addtional introduced packages maybe cause core dump when sta…
Browse files Browse the repository at this point in the history
…rting pika in centos
  • Loading branch information
QlQlqiqi committed May 18, 2024
1 parent a583036 commit 43bd1ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/net/include/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@

#include <pthread.h>
#include <atomic>
#include <queue>
#include <string>

#include "net/include/net_define.h"
#include "net/include/random.h"
#include "pstd/include/pstd_mutex.h"

namespace net {

using TaskFunc = void (*)(void*);

struct Task {
Task() = default;
TaskFunc func = nullptr;
void* arg = nullptr;
Task(TaskFunc _func, void* _arg) : func(_func), arg(_arg) {}
};
// struct Task {
// Task() = default;
// TaskFunc func = nullptr;
// void* arg = nullptr;
// Task(TaskFunc _func, void* _arg) : func(_func), arg(_arg) {}
// };

struct TimeTask {
uint64_t exec_time;
Expand Down Expand Up @@ -122,15 +121,15 @@ class ThreadPool : public pstd::noncopyable {

size_t worker_num_;
std::string thread_pool_name_;
std::queue<Task> queue_;
std::priority_queue<TimeTask> time_queue_;
// std::queue<TimeTask> queue_;
// std::priority_queue<TimeTask> time_queue_;
std::vector<Worker*> workers_;
std::atomic<bool> running_;
std::atomic<bool> should_stop_;

pstd::Mutex mu_;
pstd::CondVar rsignal_;
pstd::CondVar wsignal_;
// pstd::CondVar wsignal_;
};

} // namespace net
Expand Down
2 changes: 1 addition & 1 deletion src/net/src/thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int ThreadPool::stop_thread_pool() {
if (running_.load()) {
should_stop_.store(true);
rsignal_.notify_all();
wsignal_.notify_all();
// wsignal_.notify_all();
for (const auto worker : workers_) {
res = worker->stop();
if (res != 0) {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/start_codis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ echo 'startup codis dashboard and codis proxy'
sleep 20

# if start failed, maybe for your struct/class that be defined NOT be used
# or addtional introduced packages
echo 'assign codis slots to groups and resync groups'
./bin/codis-admin --dashboard=$CODIS_DASHBOARD_ADDR --create-group --gid=1
./bin/codis-admin --dashboard=$CODIS_DASHBOARD_ADDR --create-group --gid=2
Expand Down

0 comments on commit 43bd1ab

Please sign in to comment.