"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/server/protocol2/backup_phase4.c" between
burp-2.3.14.tar.bz2 and burp-2.3.20.tar.bz2

About: Burp is a backup and restore program using librsync and also VSS (for Windows clients). Latest version.

backup_phase4.c  (burp-2.3.14.tar.bz2):backup_phase4.c  (burp-2.3.20.tar.bz2)
#include "../../burp.h" #include "../../burp.h"
#include "../../alloc.h" #include "../../alloc.h"
#include "../../bu.h" #include "../../bu.h"
#include "../../cmd.h" #include "../../cmd.h"
#include "../../cstat.h"
#include "../../fsops.h" #include "../../fsops.h"
#include "../../fzp.h" #include "../../fzp.h"
#include "../../lock.h" #include "../../lock.h"
#include "../../log.h" #include "../../log.h"
#include "../../prepend.h" #include "../../prepend.h"
#include "../../protocol2/blk.h" #include "../../protocol2/blk.h"
#include "../../sbuf.h" #include "../../sbuf.h"
#include "../../strlist.h" #include "../../strlist.h"
#include "../../server/bu_get.h" #include "../../server/bu_get.h"
#include "../../server/manio.h" #include "../../server/manio.h"
#include "../../server/sdirs.h" #include "../../server/sdirs.h"
#include "champ_chooser/champ_chooser.h" #include "champ_chooser/champ_chooser.h"
#include "backup_phase4.h" #include "backup_phase4.h"
#include "clist.h"
#include "sparse_min.h"
static int hookscmp(struct hooks *a, struct hooks *b) static int hookscmp(struct hooks *a, struct hooks *b)
{ {
size_t i; size_t i;
uint64_t *af=a->fingerprints; uint64_t *af=a->fingerprints;
uint64_t *bf=b->fingerprints; uint64_t *bf=b->fingerprints;
for(i=0; i<a->len && i<b->len; i++) for(i=0; i<a->len && i<b->len; i++)
{ {
if(af[i]>bf[i]) return 1; if(af[i]>bf[i]) return 1;
if(af[i]<bf[i]) return -1; if(af[i]<bf[i]) return -1;
skipping to change at line 383 skipping to change at line 386
free_v((void **)&anew); free_v((void **)&anew);
free_v((void **)&bnew); free_v((void **)&bnew);
return ret; return ret;
} }
static char *get_global_sparse_tmp(const char *global) static char *get_global_sparse_tmp(const char *global)
{ {
return prepend_n(global, "tmp", strlen("tmp"), "."); return prepend_n(global, "tmp", strlen("tmp"), ".");
} }
int merge_into_global_sparse(const char *sparse, const char *global, int merge_into_global_sparse(
struct lock *lock) const char *sparse,
{ const char *global_sparse,
struct lock *lock
) {
int ret=-1; int ret=-1;
struct stat statp; struct stat statp;
char *tmpfile=NULL; char *tmpfile=NULL;
const char *globalsrc=NULL; const char *globalsrc=NULL;
if(lock->status!=GET_LOCK_GOT) if(lock->status!=GET_LOCK_GOT)
{ {
logp("Attempt to merge into sparse index without a lock!\n"); logp("Attempt to merge into sparse index without a lock!\n");
goto end; goto end;
} }
if(!(tmpfile=get_global_sparse_tmp(global))) if(!(tmpfile=get_global_sparse_tmp(global_sparse)))
goto end; goto end;
if(!lstat(global, &statp)) globalsrc=global; if(!lstat(global_sparse, &statp)) globalsrc=global_sparse;
if(merge_sparse_indexes(tmpfile, globalsrc, sparse)) if(merge_sparse_indexes(tmpfile, globalsrc, sparse))
goto end; goto end;
// FIX THIS: nasty race condition needs to be recoverable. // FIX THIS: nasty race condition needs to be recoverable.
if(do_rename(tmpfile, global)) if(do_rename(tmpfile, global_sparse))
goto end; goto end;
ret=0; ret=0;
end: end:
free_w(&tmpfile); free_w(&tmpfile);
return ret; return ret;
} }
static int lock_and_merge_into_global_sparse(const char *sparse, static int lock_and_merge_into_global_sparse(
const char *global) const char *sparse,
{ const char *global_sparse,
struct conf **conf,
struct sdirs *sdirs
) {
int ret=-1; int ret=-1;
struct lock *lock=NULL; struct lock *lock=NULL;
struct cstat *clist=NULL;
if(!(lock=try_to_get_sparse_lock(global_sparse)))
goto end;
if(!(lock=try_to_get_sparse_lock(global))) if(merge_into_global_sparse(sparse, global_sparse, lock))
goto end; goto end;
if(merge_into_global_sparse(sparse, global, lock)) if(get_client_list(&clist, sdirs->clients, conf))
goto end;
if(sparse_minimise(conf, sdirs->global_sparse, lock, clist))
goto end; goto end;
ret=0; ret=0;
end: end:
lock_release(lock); lock_release(lock);
lock_free(&lock); lock_free(&lock);
clist_free(&clist);
return ret; return ret;
} }
int merge_files_in_dir(const char *final, const char *fmanifest, int merge_files_in_dir(const char *final, const char *fmanifest,
const char *srcdir, uint64_t fcount, const char *srcdir, uint64_t fcount,
int merge(const char *dst, const char *srca, const char *srcb)) int merge(const char *dst, const char *srca, const char *srcb))
{ {
int ret=-1; int ret=-1;
uint64_t i=0; uint64_t i=0;
uint64_t pass=0; uint64_t pass=0;
skipping to change at line 629 skipping to change at line 645
if(merge_files_in_dir(dfiles, fmanifest, "dindex", if(merge_files_in_dir(dfiles, fmanifest, "dindex",
newmanio->offset->fcount, newmanio->offset->fcount,
merge_dindexes)) merge_dindexes))
goto end; goto end;
if(merge_files_in_dir(sparse, fmanifest, "hooks", if(merge_files_in_dir(sparse, fmanifest, "hooks",
newmanio->offset->fcount, newmanio->offset->fcount,
merge_sparse_indexes)) merge_sparse_indexes))
goto end; goto end;
if(lock_and_merge_into_global_sparse(sparse, sdirs->global_sparse)) if(lock_and_merge_into_global_sparse(sparse,
goto end; sdirs->global_sparse, confs, sdirs))
goto end;
logp("End phase4 (sparse generation)\n"); logp("End phase4 (sparse generation)\n");
ret=0; ret=0;
end: end:
manio_close(&newmanio); manio_close(&newmanio);
free_w(&sparse); free_w(&sparse);
free_w(&logpath); free_w(&logpath);
free_w(&fmanifest); free_w(&fmanifest);
return ret; return ret;
skipping to change at line 746 skipping to change at line 763
ret=0; ret=0;
end: end:
bu_list_free(&bu_list); bu_list_free(&bu_list);
free_w(&dfiles_new); free_w(&dfiles_new);
free_w(&dfiles_regenerating); free_w(&dfiles_regenerating);
free_w(&newpath); free_w(&newpath);
free_w(&oldpath); free_w(&oldpath);
return ret; return ret;
} }
int remove_from_global_sparse(const char *global_sparse, int remove_backup_from_global_sparse(const char *global_sparse,
const char *candidate_str) const char *candidate_str)
{ {
int ret=-1; int ret=-1;
struct lock *lock=NULL; struct lock *lock=NULL;
struct sbuf *asb=NULL; struct sbuf *asb=NULL;
uint64_t *afingerprints=NULL; uint64_t *afingerprints=NULL;
size_t aflen=0; size_t aflen=0;
size_t clen=0; size_t clen=0;
struct fzp *azp=NULL; struct fzp *azp=NULL;
struct fzp *dzp=NULL; struct fzp *dzp=NULL;
skipping to change at line 799 skipping to change at line 816
hooks_free(&anew); hooks_free(&anew);
} }
if(fzp_close(&dzp)) if(fzp_close(&dzp))
{ {
logp("Error closing %s in %s\n", tmpfile, __func__); logp("Error closing %s in %s\n", tmpfile, __func__);
goto end; goto end;
} }
// FIX THIS: nasty race condition needs to be recoverable. // FIX THIS: nasty race condition needs to be recoverable.
if(do_rename(tmpfile, global_sparse)) goto end; if(do_rename(tmpfile, global_sparse))
goto end;
ret=0; ret=0;
end: end:
fzp_close(&azp); fzp_close(&azp);
fzp_close(&dzp); fzp_close(&dzp);
lock_release(lock); lock_release(lock);
lock_free(&lock); lock_free(&lock);
sbuf_free(&asb); sbuf_free(&asb);
hooks_free(&anew); hooks_free(&anew);
free_v((void **)&afingerprints); free_v((void **)&afingerprints);
 End of changes. 14 change blocks. 
15 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)