Skip to content

Commit

Permalink
Revert "Backport some obvious fixes for the core from Bacula 7."
Browse files Browse the repository at this point in the history
This reverts commit 56560ce.
  • Loading branch information
pstorz committed Sep 30, 2014
1 parent e4d36a1 commit 1339225
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 76 deletions.
3 changes: 1 addition & 2 deletions src/console/console.c
Expand Up @@ -1605,9 +1605,8 @@ static int execcmd(FILE *input, BSOCK *UA_sock)
status = close_bpipe(bpipe);
if (status != 0) {
berrno be;

be.set_errno(status);
senditf(_("@exec error: ERR=%s\n"), be.bstrerror());
senditf(_("Autochanger error: ERR=%s\n"), be.bstrerror());
}
return 1;
}
Expand Down
1 change: 0 additions & 1 deletion src/dird/fd_cmds.c
Expand Up @@ -452,7 +452,6 @@ static bool send_list_item(JCR *jcr, const char *code, char *item, BSOCK *fd)
fd->msglen = Mmsg(fd->msg, "%s", buf);
Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
if (!bnet_send(fd)) {
close_bpipe(bpipe);
Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/filed/dir_cmd.c
Expand Up @@ -658,8 +658,8 @@ static bool cancel_cmd(JCR *jcr)
if (cjcr->store_bsock) {
cjcr->store_bsock->set_timed_out();
cjcr->store_bsock->set_terminated();
cjcr->my_thread_send_signal(TIMEOUT_SIGNAL);
}
cjcr->my_thread_send_signal(TIMEOUT_SIGNAL);
free_jcr(cjcr);
dir->fsend(_("2001 Job %s marked to be canceled.\n"), Job);
}
Expand Down
10 changes: 3 additions & 7 deletions src/filed/heartbeat.c
Expand Up @@ -117,7 +117,7 @@ void start_heartbeat_monitor(JCR *jcr)
* it gives a constant stream of TIMEOUT_SIGNAL signals that
* make debugging impossible.
*/
if (!no_signals && (me->heartbeat_interval > 0)) {
if (!no_signals) {
jcr->hb_bsock = NULL;
jcr->hb_started = false;
jcr->hb_dir_bsock = NULL;
Expand Down Expand Up @@ -207,10 +207,6 @@ extern "C" void *dir_heartbeat_thread(void *arg)
}
last_heartbeat = now;
}
/* This should never happen, but it might ... */
if (next <= 0) {
next = 1;
}
bmicrosleep(next, 0);
}
dir->close();
Expand All @@ -225,15 +221,15 @@ extern "C" void *dir_heartbeat_thread(void *arg)
*/
void start_dir_heartbeat(JCR *jcr)
{
if (!no_signals && (me->heartbeat_interval > 0)) {
if (me->heartbeat_interval) {
jcr->dir_bsock->set_locking();
pthread_create(&jcr->heartbeat_id, NULL, dir_heartbeat_thread, (void *)jcr);
}
}

void stop_dir_heartbeat(JCR *jcr)
{
if (me->heartbeat_interval > 0) {
if (me->heartbeat_interval) {
stop_heartbeat_monitor(jcr);
}
}
35 changes: 13 additions & 22 deletions src/lib/address_conf.c
Expand Up @@ -66,7 +66,7 @@ IPADDR::IPADDR(int af) : type(R_EMPTY)
saddr4->sin_port = 0xffff;
}
#ifdef HAVE_IPV6
else if (af == AF_INET6) {
else {
saddr6->sin6_port = 0xffff;
}
#endif
Expand Down Expand Up @@ -97,11 +97,11 @@ unsigned short IPADDR::get_port_net_order() const
port = saddr4->sin_port;
}
#ifdef HAVE_IPV6
else if (saddr->sa_family == AF_INET6) {
else {
port = saddr6->sin6_port;
}
#endif
return port;
return port;
}

void IPADDR::set_port_net(unsigned short port)
Expand All @@ -110,7 +110,7 @@ void IPADDR::set_port_net(unsigned short port)
saddr4->sin_port = port;
}
#ifdef HAVE_IPV6
else if (saddr->sa_family == AF_INET6) {
else {
saddr6->sin6_port = port;
}
#endif
Expand Down Expand Up @@ -208,24 +208,15 @@ const char *IPADDR::build_config_str(char *buf, int blen)
const char *IPADDR::build_address_str(char *buf, int blen, bool print_port/*=true*/)
{
char tmp[1024];

*buf = 0;
if (print_port) {
if (get_family() == AF_INET) {
bsnprintf(buf, blen, "host[ipv4;%s;%hu] ",
get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
} else if (get_family() == AF_INET6) {
bsnprintf(buf, blen, "host[ipv6;%s;%hu] ",
get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
}
bsnprintf(buf, blen, "host[%s;%s;%hu] ",
get_family() == AF_INET ? "ipv4" : "ipv6",
get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
} else {
if (get_family() == AF_INET) {
bsnprintf(buf, blen, "host[ipv4;%s] ",
get_address(tmp, sizeof(tmp) - 1));
} else if (get_family() == AF_INET6) {
bsnprintf(buf, blen, "host[ipv6;%s] ",
get_address(tmp, sizeof(tmp) - 1));
}
bsnprintf(buf, blen, "host[%s;%s] ",
get_family() == AF_INET ? "ipv4" : "ipv6",
get_address(tmp, sizeof(tmp) - 1));

}
return buf;
}
Expand Down Expand Up @@ -399,7 +390,7 @@ int sockaddr_get_port_net_order(const struct sockaddr *client_addr)
return ((struct sockaddr_in *)client_addr)->sin_port;
}
#ifdef HAVE_IPV6
else if (client_addr->sa_family == AF_INET6) {
else {
return ((struct sockaddr_in6 *)client_addr)->sin6_port;
}
#endif
Expand All @@ -412,7 +403,7 @@ int sockaddr_get_port(const struct sockaddr *client_addr)
return ntohs(((struct sockaddr_in *)client_addr)->sin_port);
}
#ifdef HAVE_IPV6
else if (client_addr->sa_family == AF_INET6) {
else {
return ntohs(((struct sockaddr_in6 *)client_addr)->sin6_port);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib/berrno.c
Expand Up @@ -74,7 +74,7 @@ const char *berrno::bstrerror()
}
#endif
/* Normal errno */
if (b_strerror(m_berrno, m_buf, sizeof_pool_memory(m_buf)) < 0) {
if (b_strerror(m_berrno, m_buf, 1024) < 0) {
return _("Invalid errno. No error message possible.");
}
return m_buf;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/jcr.c
Expand Up @@ -388,7 +388,6 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)

jcr = (JCR *)malloc(size);
memset(jcr, 0, size);
jcr->my_thread_id = pthread_self();
jcr->msg_queue = New(dlist(item, &item->link));
if ((status = pthread_mutex_init(&jcr->msg_queue_mutex, NULL)) != 0) {
berrno be;
Expand Down Expand Up @@ -440,6 +439,7 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
return jcr;
}


/*
* Remove a JCR from the chain
*
Expand Down
12 changes: 2 additions & 10 deletions src/lib/lex.c
Expand Up @@ -48,10 +48,6 @@ void scan_to_eol(LEX *lc)
lex_unget_char(lc);
return;
}

if (token == T_EOF) {
return;
}
}
}

Expand Down Expand Up @@ -187,7 +183,7 @@ LEX *lex_close_file(LEX *lf)
if (lf->bpipe) {
close_bpipe(lf->bpipe);
lf->bpipe = NULL;
} else if (lf->fd) {
} else {
fclose(lf->fd);
}
Dmsg1(dbglvl, "Close cfg file %s\n", lf->fname);
Expand All @@ -203,11 +199,7 @@ LEX *lex_close_file(LEX *lf)
of = lf;
lf = NULL;
}

if (of) {
free(of);
}

free(of);
return lf;
}

Expand Down
4 changes: 2 additions & 2 deletions src/stored/bls.c
Expand Up @@ -295,7 +295,7 @@ static void do_blocks(char *infname)
char buf1[100], buf2[100];
for ( ;; ) {
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
Dmsg1(100, "!read_block(): ERR=%s\n", dev->print_errmsg());
Dmsg1(100, "!read_block(): ERR=%s\n", dev->bstrerror());
if (dev->at_eot()) {
if (!mount_next_read_volume(dcr)) {
Jmsg(jcr, M_INFO, 0, _("Got EOM at file %u on device %s, Volume \"%s\"\n"),
Expand All @@ -316,7 +316,7 @@ static void do_blocks(char *infname)
Dmsg0(20, "read_record got eof. try again\n");
continue;
} else if (dev->is_short_block()) {
Jmsg(jcr, M_INFO, 0, "%s", dev->print_errmsg());
Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
continue;
} else {
/* I/O error */
Expand Down
25 changes: 14 additions & 11 deletions src/stored/btape.c
Expand Up @@ -473,7 +473,7 @@ static bool open_the_device()
dev->rLock();
Dmsg1(200, "Opening device %s\n", dcr->VolumeName);
if (!dev->open(dcr, OPEN_READ_WRITE)) {
Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->print_errmsg());
Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
ok = false;
goto bail_out;
}
Expand Down Expand Up @@ -861,7 +861,8 @@ static bool re_read_block_test()
}
Pmsg0(0, _("Backspace record OK.\n"));
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(0, _("Read block failed! ERR=%s\n"), dev->print_errmsg());
berrno be;
Pmsg1(0, _("Read block failed! ERR=%s\n"), be.bstrerror(dev->dev_errno));
goto bail_out;
}
memset(rec->data, 0, rec->data_len);
Expand Down Expand Up @@ -1230,13 +1231,14 @@ static bool write_read_test()
for (i=1; i<=2*num_recs; i++) {
read_again:
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
berrno be;
if (dev->at_eof()) {
Pmsg0(-1, _("Got EOF on tape.\n"));
if (i == num_recs+1) {
goto read_again;
}
}
Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, dev->print_errmsg());
Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.bstrerror(dev->dev_errno));
goto bail_out;
}
memset(rec->data, 0, rec->data_len);
Expand Down Expand Up @@ -1348,6 +1350,7 @@ static bool position_test()
}
read_again:
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
berrno be;
if (dev->at_eof()) {
Pmsg0(-1, _("Got EOF on tape.\n"));
if (!got_eof) {
Expand All @@ -1356,7 +1359,7 @@ static bool position_test()
}
}
Pmsg4(0, _("Read block %d failed! file=%d blk=%d. ERR=%s\n\n"),
recno, file, blk, dev->print_errmsg());
recno, file, blk, be.bstrerror(dev->dev_errno));
Pmsg0(0, _("This may be because the tape drive block size is not\n"
" set to variable blocking as normally used by Bareos.\n"
" Please see the Tape Testing chapter in the manual and \n"
Expand Down Expand Up @@ -2097,7 +2100,7 @@ static void scan_blocks()
printf(_("Short block read.\n"));
continue;
}
printf(_("Error reading block. ERR=%s\n"), dev->print_errmsg());
printf(_("Error reading block. ERR=%s\n"), dev->bstrerror());
goto bail_out;
}
if (block->block_len != block_size) {
Expand Down Expand Up @@ -2537,7 +2540,7 @@ static bool do_unfill()
dev->close(dcr);
dev->num_writers = 0;
if (!acquire_device_for_read(dcr)) {
Pmsg1(-1, "%s", dev->print_errmsg());
Pmsg1(-1, "%s", dev->errmsg);
goto bail_out;
}
/*
Expand All @@ -2562,7 +2565,7 @@ static bool do_unfill()
}
Pmsg1(-1, _("Reading block %u.\n"), last_block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
goto bail_out;
}
if (compare_blocks(last_block, block)) {
Expand Down Expand Up @@ -2600,7 +2603,7 @@ static bool do_unfill()

dev->clear_read();
if (!acquire_device_for_read(dcr)) {
Pmsg1(-1, "%s", dev->print_errmsg());
Pmsg1(-1, "%s", dev->errmsg);
goto bail_out;
}

Expand All @@ -2614,7 +2617,7 @@ static bool do_unfill()
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
goto bail_out;
}
if (compare_blocks(first_block, block)) {
Expand All @@ -2630,7 +2633,7 @@ static bool do_unfill()
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
goto bail_out;
}
if (compare_blocks(last_block, block)) {
Expand Down Expand Up @@ -3037,7 +3040,7 @@ bool BTAPE_DCR::dir_ask_sysop_to_mount_volume(int mode)
if (VolumeName[0] == 0) {
return dir_ask_sysop_to_create_appendable_volume();
}
Pmsg1(-1, "%s", dev->print_errmsg()); /* print reason */
Pmsg1(-1, "%s", dev->errmsg); /* print reason */

if (VolumeName[0] == 0 || bstrcmp(VolumeName, "TestVolume2")) {
fprintf(stderr,
Expand Down
1 change: 0 additions & 1 deletion src/stored/dir_cmd.c
Expand Up @@ -510,7 +510,6 @@ static bool cancel_cmd(JCR *cjcr)
Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId);
release_device_cond();
}
jcr->my_thread_send_signal(TIMEOUT_SIGNAL);

/*
* See if the Job has a certain protocol.
Expand Down

0 comments on commit 1339225

Please sign in to comment.