X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Ffd_cmds.c;h=e06a6c437e32429a93206941af2b2e1fffac799f;hb=225546018b76820eec2005e861c7908d0cec9642;hp=6e491361a784e7e2770269a0986526b674dc0e6c;hpb=4f7896c56213a88d17777db9041a9643ae541c5f;p=bacula%2Fbacula diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index 6e491361a7..e06a6c437e 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -13,19 +13,32 @@ * */ /* - Copyright (C) 2000-2006 Kern Sibbald + Bacula® - The Network Backup Solution - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. - */ + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ #include "bacula.h" #include "stored.h" @@ -82,7 +95,6 @@ static char NOT_opened[] = "3902 Error session not opened\n"; static char OK_end[] = "3000 OK end\n"; static char OK_close[] = "3000 OK close Status = %d\n"; static char OK_open[] = "3000 OK open ticket = %d\n"; -static char OK_append[] = "3000 OK append data\n"; static char ERROR_append[] = "3903 Error append data\n"; static char OK_bootstrap[] = "3000 OK bootstrap\n"; static char ERROR_bootstrap[] = "3904 Error bootstrap\n"; @@ -94,6 +106,7 @@ char Job_end[] = /* * Run a File daemon Job -- File daemon already authorized + * Director sends us this command. * * Basic task here is: * - Read a command from the File daemon @@ -102,21 +115,37 @@ char Job_end[] = */ void run_job(JCR *jcr) { - int i; - bool found, quit; - BSOCK *fd = jcr->file_bsock; BSOCK *dir = jcr->dir_bsock; char ec1[30]; - - fd->jcr = jcr; - dir->jcr = jcr; + dir->set_jcr(jcr); Dmsg1(120, "Start run Job=%s\n", jcr->Job); bnet_fsend(dir, Job_start, jcr->Job); jcr->start_time = time(NULL); jcr->run_time = jcr->start_time; set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); /* update director */ + do_fd_commands(jcr); + jcr->end_time = time(NULL); + dequeue_messages(jcr); /* send any queued messages */ + set_jcr_job_status(jcr, JS_Terminated); + generate_daemon_event(jcr, "JobEnd"); + bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, + edit_uint64(jcr->JobBytes, ec1)); + bnet_sig(dir, BNET_EOD); /* send EOD to Director daemon */ + return; +} + +/* + * Now talk to the FD and do what he says + */ +void do_fd_commands(JCR *jcr) +{ + int i; + bool found, quit; + BSOCK *fd = jcr->file_bsock; + + fd->set_jcr(jcr); for (quit=false; !quit;) { int stat; @@ -147,17 +176,8 @@ void run_job(JCR *jcr) } } bnet_sig(fd, BNET_TERMINATE); /* signal to FD job is done */ - jcr->end_time = time(NULL); - dequeue_messages(jcr); /* send any queued messages */ - set_jcr_job_status(jcr, JS_Terminated); - generate_daemon_event(jcr, "JobEnd"); - bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, - edit_uint64(jcr->JobBytes, ec1)); - bnet_sig(dir, BNET_EOD); /* send EOD to Director daemon */ - return; } - /* * Append Data command * Open Data Channel and receive Data for archiving @@ -172,7 +192,7 @@ static bool append_data_cmd(JCR *jcr) Dmsg1(110, "msg); jcr->JobType = JT_BACKUP; if (do_append_data(jcr)) { - return bnet_fsend(fd, OK_append); + return true; } else { bnet_suppress_error_messages(fd, 1); /* ignore errors at this point */ bnet_fsend(fd, ERROR_append); @@ -336,17 +356,19 @@ bool get_bootstrap_file(JCR *jcr, BSOCK *sock) jcr->RestoreBootstrap, strerror(errno)); goto bail_out; } + Dmsg0(10, "=== Bootstrap file ===\n"); while (bnet_recv(sock) >= 0) { - Dmsg1(400, "storedmsg); + Dmsg1(10, "%s", sock->msg); fputs(sock->msg, bs); } fclose(bs); + Dmsg0(10, "=== end bootstrap file ===\n"); jcr->bsr = parse_bsr(jcr, jcr->RestoreBootstrap); if (!jcr->bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } - if (debug_level > 20) { + if (debug_level >= 10) { dump_bsr(jcr->bsr, true); } ok = true;