Skip to content

Commit

Permalink
detach AutoPurge thread to avoid run out of virtual memory
Browse files Browse the repository at this point in the history
  • Loading branch information
flabby committed Mar 17, 2016
1 parent 4bd853a commit 08ea133
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ int log_filter_r(std::string path, uint32_t to, std::set<std::string> &files)
}

void* PikaServer::StartPurgeLogs(void* arg) {
int ret = 0;

if ((ret = pthread_detach(pthread_self())) != 0) {
LOG(WARNING) << "Detach thread failed, " << strerror(ret);
}

PikaServer* p = (PikaServer*)(((purge_args*)arg)->p);
uint32_t to = ((purge_args*)arg)->to;

Expand All @@ -589,7 +595,6 @@ void* PikaServer::StartPurgeLogs(void* arg) {
std::string prefix = log_path + "write2file";
*/
std::string filename;
int ret = 0;
std::set<std::string> files_to_del;
log_filter_r(log_path, to, files_to_del);
for (std::set<std::string>::iterator iter = files_to_del.begin(); iter != files_to_del.end(); iter++) {
Expand All @@ -608,7 +613,9 @@ void* PikaServer::StartPurgeLogs(void* arg) {
LOG(INFO) << "Purge thread reset purging_ to false";
}
delete (purge_args*)arg;
return NULL;

pthread_exit(NULL);
//return NULL;
}

void PikaServer::InfoKeySpace() {
Expand Down

0 comments on commit 08ea133

Please sign in to comment.