Skip to content

Commit

Permalink
jcr.h: rename attributes to match standard
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri authored and pstorz committed May 30, 2023
1 parent f281c12 commit e16b67d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
41 changes: 20 additions & 21 deletions core/src/include/jcr.h
Expand Up @@ -46,7 +46,6 @@
#include "lib/dlink.h"
#include "lib/path_list.h"

#include <unordered_set>
#include <atomic>

struct job_callback_item;
Expand Down Expand Up @@ -76,13 +75,13 @@ typedef void(JCR_free_HANDLER)(JobControlRecord* jcr);
/* clang-format off */
class JobControlRecord {
private:
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /**< Jcr mutex */
std::atomic<int32_t> _use_count{}; /**< Use count */
std::atomic<int32_t> JobStatus{}; /**< ready, running, blocked, terminated */
pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; /**< Jcr mutex */
std::atomic<int32_t> use_count_{}; /**< Use count */
std::atomic<int32_t> JobStatus_{}; /**< ready, running, blocked, terminated */
int32_t JobType_{}; /**< Backup, restore, verify ... */
int32_t JobLevel_{}; /**< Job level */
int32_t Protocol_{}; /**< Backup Protocol */
bool my_thread_killable{};
bool my_thread_killable_{};
public:
JobControlRecord();
~JobControlRecord();
Expand All @@ -91,36 +90,36 @@ class JobControlRecord {
JobControlRecord& operator=(const JobControlRecord& other) = delete;
JobControlRecord& operator=(const JobControlRecord&& other) = delete;

void lock() { lock_mutex(mutex); }
void unlock() { unlock_mutex(mutex); }
void lock() { lock_mutex(mutex_); }
void unlock() { unlock_mutex(mutex_); }
void IncUseCount(void)
{
++_use_count;
++use_count_;
}
void DecUseCount(void)
{
--_use_count;
--use_count_;
}
int32_t UseCount() const { return _use_count; }
void InitMutex(void) { pthread_mutex_init(&mutex, NULL); }
void DestroyMutex(void) { pthread_mutex_destroy(&mutex); }
bool IsJobCanceled() { return JobStatus == JS_Canceled
|| JobStatus == JS_ErrorTerminated
|| JobStatus == JS_FatalError; }
int32_t UseCount() const { return use_count_; }
void InitMutex(void) { pthread_mutex_init(&mutex_, NULL); }
void DestroyMutex(void) { pthread_mutex_destroy(&mutex_); }
bool IsJobCanceled() { return JobStatus_ == JS_Canceled
|| JobStatus_ == JS_ErrorTerminated
|| JobStatus_ == JS_FatalError; }

bool IsTerminatedOk() { return JobStatus == JS_Terminated || JobStatus == JS_Warnings; }
bool IsIncomplete() { return JobStatus == JS_Incomplete; }
bool IsTerminatedOk() { return JobStatus_ == JS_Terminated || JobStatus_ == JS_Warnings; }
bool IsIncomplete() { return JobStatus_ == JS_Incomplete; }
bool is_JobLevel(int32_t JobLevel) { return JobLevel == JobLevel_; }
bool is_JobType(int32_t JobType) { return JobType == JobType_; }
bool is_JobStatus(int32_t aJobStatus) { return aJobStatus == JobStatus; }
bool is_JobStatus(int32_t aJobStatus) { return aJobStatus == JobStatus_; }
void setJobLevel(int32_t JobLevel) { JobLevel_ = JobLevel; }
void setJobType(int32_t JobType) { JobType_ = JobType; }
void setJobProtocol(int32_t JobProtocol) { Protocol_ = JobProtocol; }
void setJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; }
void setJobStatus(int32_t aJobStatus) { JobStatus_ = aJobStatus; }
void setJobStarted();
int32_t getJobType() const { return JobType_; }
int32_t getJobLevel() const { return JobLevel_; }
int32_t getJobStatus() const { return JobStatus; }
int32_t getJobStatus() const { return JobStatus_; }
int32_t getJobProtocol() const { return Protocol_; }
bool NoClientUsed() const
{
Expand All @@ -136,7 +135,7 @@ class JobControlRecord {
bool JobReads(); /**< in lib/jcr.c */
void MyThreadSendSignal(int sig); /**< in lib/jcr.c */
void SetKillable(bool killable); /**< in lib/jcr.c */
bool IsKillable() const { return my_thread_killable; }
bool IsKillable() const { return my_thread_killable_; }

dlink<JobControlRecord> link; /**< JobControlRecord chain link */
pthread_t my_thread_id{}; /**< Id of thread controlling jcr */
Expand Down
8 changes: 4 additions & 4 deletions core/src/lib/jcr.cc
Expand Up @@ -412,7 +412,7 @@ void JobControlRecord::SetKillable(bool killable)
{
lock();

my_thread_killable = killable;
my_thread_killable_ = killable;
if (killable) {
my_thread_id = pthread_self();
} else {
Expand Down Expand Up @@ -744,7 +744,7 @@ void JobControlRecord::setJobStarted()
void JobControlRecord::setJobStatusWithPriorityCheck(int newJobStatus)
{
int priority;
int oldJobStatus = JobStatus;
int oldJobStatus = JobStatus_;
int old_priority = GetStatusPriority(oldJobStatus);

priority = GetStatusPriority(newJobStatus);
Expand All @@ -770,10 +770,10 @@ void JobControlRecord::setJobStatusWithPriorityCheck(int newJobStatus)
if (priority > old_priority || (priority == 0 && old_priority == 0)) {
Dmsg4(800, "Set new stat. old: %c,%d new: %c,%d\n", oldJobStatus,
old_priority, newJobStatus, priority);
JobStatus.compare_exchange_strong(oldJobStatus, newJobStatus);
JobStatus_.compare_exchange_strong(oldJobStatus, newJobStatus);
}

if (oldJobStatus != JobStatus) {
if (oldJobStatus != JobStatus_) {
Dmsg2(800, "leave setJobStatus old=%c new=%c\n", oldJobStatus,
newJobStatus);
// GeneratePluginEvent(this, bEventStatusChange, nullptr);
Expand Down

0 comments on commit e16b67d

Please sign in to comment.