Skip to content

Commit

Permalink
jcr: cleanup header file
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 7, 2019
1 parent 03e38b5 commit e42a508
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
50 changes: 19 additions & 31 deletions core/src/include/jcr.h
Expand Up @@ -39,43 +39,24 @@
#include <include/job_status.h>
#include <include/job_types.h>
#include "lib/tls_conf.h"

#ifdef DIRECTOR_DAEMON
#include "cats/cats.h"
#include "dird/client_connection_handshake_mode.h"
typedef struct s_tree_root TREE_ROOT;
#endif

#include "lib/alist.h"
#include "lib/volume_session_info.h"


#define JobTerminatedSuccessfully(jcr) \
(jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings)

#define JobCanceled(jcr) \
(jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated || \
jcr->JobStatus == JS_FatalError)

#define foreach_jcr(jcr) \
for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr)))

#define endeach_jcr(jcr) JcrWalkEnd(jcr)
#include "lib/tls_conf.h"

class dlist;
class JobControlRecord;
class BareosSocket;
class BareosDb;
class BareosSocket;
class dlist;
class htable;
class JobControlRecord;

struct AttributesDbRecord;
struct bpContext;
struct JobControlRecordPrivate;
struct VolumeSessionInfo;

#ifdef HAVE_WIN32
struct CopyThreadContext;
#endif

struct JobControlRecordPrivate;

/* clang-format off */
struct CompressionContext {
POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */
Expand All @@ -94,13 +75,20 @@ struct CompressionContext {
};
/* clang-format on */

struct job_callback_item {
void (*JobEndCb)(JobControlRecord* jcr, void*);
void* ctx{};
};

typedef void(JCR_free_HANDLER)(JobControlRecord* jcr);

#define JobTerminatedSuccessfully(jcr) \
(jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings)

#define JobCanceled(jcr) \
(jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated || \
jcr->JobStatus == JS_FatalError)

#define foreach_jcr(jcr) \
for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr)))

#define endeach_jcr(jcr) JcrWalkEnd(jcr)

/* clang-format off */
class JobControlRecord {
private:
Expand Down
6 changes: 6 additions & 0 deletions core/src/lib/jcr.cc
Expand Up @@ -54,6 +54,7 @@
#include "lib/bsock.h"
#include "lib/recent_job_results_list.h"
#include "lib/message_queue_item.h"
#include "lib/volume_session_info.h"
#include "lib/watchdog.h"

#include <algorithm>
Expand Down Expand Up @@ -150,6 +151,11 @@ bool JobControlRecord::JobReads()
return false;
}

struct job_callback_item {
void (*JobEndCb)(JobControlRecord* jcr, void*);
void* ctx{};
};

/*
* Push a job_callback_item onto the job end callback stack.
*/
Expand Down
1 change: 1 addition & 0 deletions core/src/tests/job_control_record.cc
Expand Up @@ -22,6 +22,7 @@
#include "gtest/gtest.h"
#include "include/bareos.h"
#include "include/jcr.h"
#include "lib/volume_session_info.h"

static bool callback_called_from_destructor = false;
static void callback(JobControlRecord* jcr)
Expand Down

0 comments on commit e42a508

Please sign in to comment.