Skip to content

Commit

Permalink
apply bareos-check-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri authored and arogge committed Mar 2, 2023
1 parent b04654b commit fd5f94c
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 311 deletions.
56 changes: 19 additions & 37 deletions core/src/dird/backup.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -442,27 +442,21 @@ static bool ConfigureTlsRequirementsPassiveClient(JobControlRecord* jcr)

static bool ConfigureMessageThread(JobControlRecord* jcr)
{
/*
* When the client is not in passive mode we can put the SD in
* listen mode for the FD connection.
*/
/* When the client is not in passive mode we can put the SD in
* listen mode for the FD connection. */
jcr->passive_client = jcr->dir_impl->res.client->passive;

if (!ConfigureTlsRequirementsPassiveClient(jcr)) { return false; }

/*
* Start the job prior to starting the message thread below
/* Start the job prior to starting the message thread below
* to avoid two threads from using the BareosSocket structure at
* the same time.
*/
* the same time. */
if (!jcr->store_bsock->fsend("run")) { return false; }

/*
* Now start a Storage daemon message thread. Note,
/* Now start a Storage daemon message thread. Note,
* this thread is used to provide the catalog services
* for the backup job, including inserting the attributes
* into the catalog. See CatalogUpdate() in catreq.c
*/
* into the catalog. See CatalogUpdate() in catreq.c */
if (!StartStorageDaemonMessageThread(jcr)) { return false; }

Dmsg0(150, "Storage daemon connection OK\n");
Expand Down Expand Up @@ -501,11 +495,9 @@ bool DoNativeBackup(JobControlRecord* jcr)
return false;
}

/*
* Open a message channel connection with the Storage
/* Open a message channel connection with the Storage
* daemon. This is to let him know that our client
* will be contacting him for a backup session.
*/
* will be contacting him for a backup session. */
Dmsg0(110, "Open connection with storage daemon\n");
jcr->setJobStatusWithPriorityCheck(JS_WaitSD);

Expand Down Expand Up @@ -577,26 +569,22 @@ bool DoNativeBackup(JobControlRecord* jcr)
return false;
}

/*
* We re-update the job start record so that the start
/* We re-update the job start record so that the start
* time is set after the run before job. This avoids
* that any files created by the run before job will
* be saved twice. They will be backed up in the current
* job, but not in the next one unless they are changed.
* Without this, they will be backed up in this job and
* in the next job run because in that case, their date
* is after the start of this run.
*/
* is after the start of this run. */
jcr->start_time = time(nullptr);
jcr->dir_impl->jr.StartTime = jcr->start_time;
if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->dir_impl->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}

/*
* If backup is in accurate mode, we send the list of
* all files to FD.
*/
/* If backup is in accurate mode, we send the list of
* all files to FD. */
if (!SendAccurateCurrentFiles(jcr)) {
TerminateBackupWithError(jcr);
return false; // error
Expand Down Expand Up @@ -624,10 +612,8 @@ bool DoNativeBackup(JobControlRecord* jcr)
Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror());
}

/*
* Check softquotas after job did run.
* If quota is exceeded now, set the GraceTime.
*/
/* Check softquotas after job did run.
* If quota is exceeded now, set the GraceTime. */
CheckSoftquotas(jcr);

if (status == JS_Terminated) {
Expand Down Expand Up @@ -694,10 +680,8 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout)
fd->signal(BNET_TERMINATE); /* tell Client we are terminating */
}

/*
* Force cancel in SD if failing, but not for Incomplete jobs so that we let
* the SD despool.
*/
/* Force cancel in SD if failing, but not for Incomplete jobs so that we let
* the SD despool. */
Dmsg5(100, "cancel=%d fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(),
fd_ok, jcr->dir_impl->FDJobStatus.load(), jcr->getJobStatus(),
jcr->dir_impl->SDJobStatus.load());
Expand Down Expand Up @@ -935,12 +919,10 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
}

if (!jcr->db->GetJobVolumeNames(jcr, jcr->dir_impl->jr.JobId, jcr->VolumeName)) {
/*
* Note, if the job has erred, most likely it did not write any
/* Note, if the job has erred, most likely it did not write any
* tape, so suppress this "error" message since in that case
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
* normal exit should we complain about this error. */
if (jcr->IsTerminatedOk() && jcr->dir_impl->jr.JobBytes) {
Jmsg(jcr, M_ERROR, 0, "%s", jcr->db->strerror());
}
Expand Down
20 changes: 7 additions & 13 deletions core/src/dird/fd_cmds.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -802,10 +802,8 @@ bool SendRestoreObjects(JobControlRecord* jcr, JobId_t JobId, bool send_global)
SendJobSpecificRestoreObjects(jcr, JobId, &octx);
}

/*
* Send to FD only if we have at least one restore object.
* This permits backward compatibility with older FDs.
*/
/* Send to FD only if we have at least one restore object.
* This permits backward compatibility with older FDs. */
if (octx.count > 0) {
fd = jcr->file_bsock;
fd->fsend(restoreobjectendcmd);
Expand Down Expand Up @@ -905,12 +903,10 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr)
} else if (CryptoDigestStreamType(stream) != CRYPTO_DIGEST_NONE) {
size_t length;

/*
* First, get STREAM_UNIX_ATTRIBUTES and fill AttributesDbRecord structure
/* First, get STREAM_UNIX_ATTRIBUTES and fill AttributesDbRecord structure
* Next, we CAN have a CRYPTO_DIGEST, so we fill AttributesDbRecord with
* it (or not) When we get a new STREAM_UNIX_ATTRIBUTES, we known that we
* can add file to the catalog At the end, we have to add the last file
*/
* can add file to the catalog At the end, we have to add the last file */
if (jcr->dir_impl->FileIndex != (uint32_t)file_index) {
Jmsg3(jcr, M_ERROR, 0, _("%s index %d not same as attributes %d\n"),
stream_to_ascii(stream), file_index, jcr->dir_impl->FileIndex);
Expand Down Expand Up @@ -1117,10 +1113,8 @@ void* HandleFiledConnection(ConnectionPool* connections,

RunOnIncomingConnectInterval(client_name).Run();

/*
* The connection is now kept in the connection_pool.
* This thread is no longer required and will end now.
*/
/* The connection is now kept in the connection_pool.
* This thread is no longer required and will end now. */
socket_guard.Release();
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/fd_cmds.h
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2019 Bareos GmbH & Co. KG
Copyright (C) 2018-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down
8 changes: 3 additions & 5 deletions core/src/dird/fd_sendfileset.cc
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2022-2022 Bareos GmbH & Co. KG
Copyright (C) 2023-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -124,11 +124,9 @@ static void SendFilesetOptions(JobControlRecord* jcr,
int l = 0;

for (int k = 0; file_option->opts[k] != '\0'; k++) {
/*
* Z compress option is followed by the single-digit compress level
/* Z compress option is followed by the single-digit compress level
* or 'o' For fastlz its Zf with a single char selecting the actual
* compression algo.
*/
* compression algo. */
if (file_option->opts[k] == 'Z' && file_option->opts[k + 1] == 'f') {
done = true;
k += 2; /* skip option */
Expand Down
27 changes: 24 additions & 3 deletions core/src/dird/fd_sendfileset.h
@@ -1,5 +1,26 @@
#ifndef FD_SENDFILESET_H
#define FD_SENDFILESET_H
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2023-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
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
Affero General Public License for more details.
You should have received a copy of the GNU Affero 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.
*/

#ifndef BAREOS_DIRD_FD_SENDFILESET_H_
#define BAREOS_DIRD_FD_SENDFILESET_H_

#include "include/jcr.h"
#include "dird/dird_globals.h"
Expand All @@ -11,4 +32,4 @@ bool SendIncludeExcludeItems(JobControlRecord* jcr, FilesetResource* fileset);

}

#endif // FD_SENDFILESET_H
#endif // BAREOS_DIRD_FD_SENDFILESET_H_

0 comments on commit fd5f94c

Please sign in to comment.