Skip to content

Commit

Permalink
jcr_private: add res_head_container shared pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and alaaeddineelamri committed Aug 4, 2022
1 parent dad0ea1 commit 8451355
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
10 changes: 9 additions & 1 deletion core/src/dird/jcr_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
#ifndef BAREOS_DIRD_JCR_PRIVATE_H_
#define BAREOS_DIRD_JCR_PRIVATE_H_

#include <iostream>
#include "cats/cats.h"
#include "dird/client_connection_handshake_mode.h"
#include "dird/job_trigger.h"

typedef struct s_tree_root TREE_ROOT;

class ResHeadContainer;

namespace directordaemon {
class JobResource;
class StorageResource;
Expand Down Expand Up @@ -93,9 +96,14 @@ struct Resources {
};

struct JobControlRecordPrivate {
JobControlRecordPrivate() {
JobControlRecordPrivate( std::shared_ptr<ResHeadContainer> res_head_container) {
job_res_head_container_ = res_head_container;
RestoreJobId = 0; MigrateJobId = 0; VerifyJobId = 0;
}
~JobControlRecordPrivate() {
job_res_head_container_ = nullptr;
}
std::shared_ptr<ResHeadContainer> job_res_head_container_;
pthread_t SD_msg_chan{}; /**< Message channel thread id */
bool SD_msg_chan_started{}; /**< Message channel thread started */
pthread_cond_t term_wait = PTHREAD_COND_INITIALIZER; /**< Wait for job termination */
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ void GetJobStorage(UnifiedStorageResource* store,
JobControlRecord* NewDirectorJcr()
{
JobControlRecord* jcr = new_jcr(DirdFreeJcr);
jcr->impl = new JobControlRecordPrivate;
jcr->impl = new JobControlRecordPrivate(my_config->res_head_container_);
return jcr;
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/dird/ua_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ void ListDirStatusHeader(UaContext* ua)
kBareosVersionStrings.GetOsInfo());
bstrftime_nc(dt, sizeof(dt), daemon_start_time);
ua->SendMsg(_("Daemon started %s. Jobs: run=%d, running=%d db:postgresql, %s "
"binary\n"),
dt, num_jobs_run, JobCount(), kBareosVersionStrings.BinaryInfo);
"binary %d shared_count\n"),
dt, num_jobs_run, JobCount(), kBareosVersionStrings.BinaryInfo,
my_config->res_head_container_.use_count());

if (me->secure_erase_cmdline) {
ua->SendMsg(_(" secure erase command='%s'\n"), me->secure_erase_cmdline);
Expand Down
13 changes: 4 additions & 9 deletions core/src/lib/parse_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ struct ResHeadContainer {
{
res_head_ = res_head;
config_ = config;
printf("ResHeadContainer::ResHeadContainer : res_head_ is at %p\n",
res_head_);
Dmsg1(100, "ResHeadContainer::ResHeadContainer : res_head_ is at %p\n",
res_head_);
}

~ResHeadContainer()
Expand All @@ -434,13 +434,8 @@ struct ResHeadContainer {
config_->FreeResourceCb_(res_head_[j], j);
res_head_[j] = nullptr;
}
printf("ResHeadContainer::~ResHeadContainer : feeing restable at %p\n",
res_head_);
// free(res_head_);
printf("ResHeadContainer::~ResHeadContainer : freed restable at %p\n",
res_head_);
// Dmsg0(100, "ResHeadContainer::~ResHeadContainer : freed restable at
// %p\n", res_head_);
Dmsg1(100, "ResHeadContainer::~ResHeadContainer : freed restable at %p\n",
res_head_);
}
};

Expand Down

0 comments on commit 8451355

Please sign in to comment.