extern dlist store_globals;
extern dlist job_globals;
extern dlist sched_globals;
-extern dlist *daemon_msg_queue;
-extern pthread_mutex_t daemon_msg_queue_mutex;
extern RES_ITEM job_items[];
#if defined(_MSC_VER)
extern "C" { // work around visual compiler mangling variables
bool no_signals = false;
char *uid = NULL;
char *gid = NULL;
- MQUEUE_ITEM *item = NULL;
/* DELETE ME when bugs in MA1512, MA1632 MA1639 are fixed */
MA1512_reload_job_end_cb = reload_job_end_cb;
init_msg(NULL, NULL); /* initialize message handler */
init_reload();
daemon_start_time = time(NULL);
- /* Setup daemon message queue */
- daemon_msg_queue = New(dlist(item, &item->link));
+ setup_daemon_message_queue();
console_command = run_console_command;
while ((ch = getopt(argc, argv, "c:d:fg:mr:stu:v?T")) != -1) {
term_msg(); /* terminate message handler */
cleanup_crypto();
- P(daemon_msg_queue_mutex);
- daemon_msg_queue->destroy();
- free(daemon_msg_queue);
- V(daemon_msg_queue_mutex);
+ free_daemon_message_queue();
if (reload_table) {
free(reload_table);
bool no_signals = false;
void *start_heap;
extern struct s_cmds cmds[];
-extern dlist *daemon_msg_queue;
-extern pthread_mutex_t daemon_msg_queue_mutex;
-
#ifndef CONFIG_FILE /* Might be overwritten */
#define CONFIG_FILE "bacula-fd.conf" /* default config file */
bool keep_readall_caps = false;
char *uid = NULL;
char *gid = NULL;
- MQUEUE_ITEM *item = NULL;
start_heap = sbrk(0);
setlocale(LC_ALL, "");
my_name_is(argc, argv, PROG_NAME);
init_msg(NULL, NULL);
daemon_start_time = time(NULL);
- /* Setup daemon message queue */
- daemon_msg_queue = New(dlist(item, &item->link));
+ setup_daemon_message_queue();
while ((ch = getopt(argc, argv, "c:d:fg:kmstTu:v?D:")) != -1) {
switch (ch) {
generate_daemon_event(NULL, "Exit");
unload_plugins();
- P(daemon_msg_queue_mutex);
- daemon_msg_queue->destroy();
- free(daemon_msg_queue);
- V(daemon_msg_queue_mutex);
+ free_daemon_message_queue();
if (!test_config) {
write_state_file(me->working_directory,
}
int generate_daemon_event(JCR *jcr, const char *event) { return 0; }
+
+void setup_daemon_message_queue()
+{
+ static MQUEUE_ITEM *item = NULL;
+ daemon_msg_queue = New(dlist(item, &item->link));
+}
+
+void free_daemon_message_queue()
+{
+ P(daemon_msg_queue_mutex);
+ daemon_msg_queue->destroy();
+ free(daemon_msg_queue);
+ V(daemon_msg_queue_mutex);
+}
bool handle_hangup_blowup (JCR *jcr, uint32_t file_count, uint64_t byte_count);
void set_assert_msg (const char *file, int line, const char *msg);
void register_message_callback(void msg_callback(int type, char *msg));
+void setup_daemon_message_queue();
+void free_daemon_message_queue();
/* bnet_server.c */
void bnet_thread_server(dlist *addr_list, int max_clients,
#ifndef _ALIGNED_DEV_H_
#define _ALIGNED_DEV_H_
-inline const char *DEVICE::aligned_name() const { return adev_name; }
-
class aligned_dev : public file_dev {
public:
if (ok || dev->can_write()) {
if (!dev->flush_before_eos(dcr)) {
/* Print only if ok and not cancelled to avoid spurious messages */
- if (!jcr->is_job_canceled()) {
+ if (ok && !jcr->is_job_canceled()) {
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
void free_block(DEV_BLOCK *block)
{
if (block) {
- Dmsg1(999, "free_block block=%p\n", block);
+ Dmsg1(999, "free_block buffer=%p\n", block->buf);
if (block->buf) {
free_memory(block->buf);
}
}
free_record(rec);
Dmsg0(900, "=== free_blocks\n");
- dcr->dev->free_dcr_blocks(dcr);
+ free_block(dcr->block);
dcr->block = save_block; /* restore block to dcr */
Dsm_check(200);
}
bool must_load() const { return m_load; };
const char *strerror() const;
const char *archive_name() const;
- const char *aligned_name() const;
const char *name() const;
const char *print_name() const; /* Name for display purposes */
void set_ateot(); /* in dev.c */
int try_autolabel(bool opened);
bool find_a_volume();
bool is_suitable_volume_mounted();
- bool is_eod_valid();
int check_volume_label(bool &ask, bool &autochanger);
void release_volume();
void do_swapping(bool is_writing);
bstrncpy(PrevVolName, dev->getVolCatName(), sizeof(PrevVolName));
bstrncpy(dev->VolHdr.PrevVolumeName, PrevVolName, sizeof(dev->VolHdr.PrevVolumeName));
+ /* create temporary block, that will be released at the end, current blocks
+ * have been saved in local DEV_BLOCK above and will be restored before to
+ * leave the function
+ */
dev->new_dcr_blocks(dcr);
/* Inform User about end of medium */
pm_strcpy(dcr->jcr->errmsg, errmsg);
}
}
- Dmsg1(100, "open dev: disk fd=%d opened, aligned=%d\n", m_fd);
+ Dmsg1(100, "open dev: disk fd=%d opened\n", m_fd);
state |= preserve; /* reset any important state info */
Leave(dbglvl);
break;
}
- /* Do truncate for 1 or 2 devices */
Dmsg2(100, "Truncate adata=%d fd=%d\n", dev->adata, dev->m_fd);
if (ftruncate(dev->m_fd, 0) != 0) {
berrno be;
goto bail_out;
}
- /* Not aligned data */
- if (dev->weof(dcr, 1)) {
- dev->set_labeled();
- }
+ if (!dev->is_aligned()) {
+ /* Not aligned data */
+ if (dev->weof(dcr, 1)) {
+ dev->set_labeled();
+ }
- if (chk_dbglvl(100)) {
- dev->dump_volume_label();
- }
- Dmsg0(50, "Call reserve_volume\n");
- /**** ***FIXME*** if dev changes, dcr must be updated */
- if (reserve_volume(dcr, VolName) == NULL) {
- if (!dcr->jcr->errmsg[0]) {
- Mmsg3(dcr->jcr->errmsg, _("Could not reserve volume %s on %s device %s\n"),
- dev->VolHdr.VolumeName, dev->print_type(), dev->print_name());
+ if (chk_dbglvl(100)) {
+ dev->dump_volume_label();
}
- Dmsg1(50, "%s", dcr->jcr->errmsg);
- goto bail_out;
+ Dmsg0(50, "Call reserve_volume\n");
+ /**** ***FIXME*** if dev changes, dcr must be updated */
+ if (reserve_volume(dcr, VolName) == NULL) {
+ if (!dcr->jcr->errmsg[0]) {
+ Mmsg3(dcr->jcr->errmsg, _("Could not reserve volume %s on %s device %s\n"),
+ dev->VolHdr.VolumeName, dev->print_type(), dev->print_name());
+ }
+ Dmsg1(50, "%s", dcr->jcr->errmsg);
+ goto bail_out;
+ }
+ dev = dcr->dev; /* may have changed in reserve_volume */
}
- dev = dcr->dev; /* may have changed in reserve_volume */
dev->clear_append(); /* remove append since this is PRE_LABEL */
Leave(100);
return true;
/* Imported functions and variables */
extern bool parse_sd_config(CONFIG *config, const char *configfile, int exit_code);
-extern dlist *daemon_msg_queue;
-extern pthread_mutex_t daemon_msg_queue_mutex;
-
-
/* Forward referenced functions */
void terminate_stored(int sig);
static int check_resources();
pthread_t thid;
char *uid = NULL;
char *gid = NULL;
- MQUEUE_ITEM *item = NULL;
start_heap = sbrk(0);
setlocale(LC_ALL, "");
my_name_is(argc, argv, "bacula-sd");
init_msg(NULL, NULL);
daemon_start_time = time(NULL);
- /* Setup daemon message queue */
- daemon_msg_queue = New(dlist(item, &item->link));
+ setup_daemon_message_queue();
/* Sanity checks */
if (TAPE_BSIZE % B_DEV_BSIZE != 0 || TAPE_BSIZE / B_DEV_BSIZE == 0) {
unload_plugins();
free_volume_lists();
- P(daemon_msg_queue_mutex);
- daemon_msg_queue->destroy();
- free(daemon_msg_queue);
- V(daemon_msg_queue_mutex);
+ free_daemon_message_queue();
foreach_res(device, R_DEVICE) {
Dmsg2(10, "Term device %s %s\n", device->hdr.name, device->device_name);
'truncate client_group_member;',
'update Media set LocationId=0;',
'truncate location;',
- '');
+ '',
+ 'quit');
run_bconsole();
return $ret;
}
print FP "\@echo File generated by scripts::function::check_part()\n";
print FP "sql\n";
print FP "SELECT 'Name', VolumeName, Storage.Name FROM Media JOIN Storage USING (StorageId) WHERE VolType = 14;\n";
+ print FP "\nquit\n";
close(FP);
unlink("$tmp/check_parts.out");
print FP "SELECT 'Index', JobId, FirstIndex, LastIndex, JobMediaId FROM JobMedia ORDER BY JobId, JobMediaId;\n";
print FP "SELECT 'Block', JobId, MediaId, StartFile, EndFile, StartBlock, EndBlock, JobMediaId FROM JobMedia ORDER BY JobId, JobMediaId;\n";
print FP "SELECT 'ERROR StartAddress > EndAddress (JobMediaId)', JobMediaId from JobMedia where ((CAST(StartFile AS bigint)<<32) + StartBlock) > ((CAST (EndFile AS bigint) <<32) + EndBlock);\n";
+ print FP "\nquit\n";
close(FP);
my $tempfile = "$tmp/check_jobmedia.$$";