]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/accurate-rblist.patch
ebl cleanup
[bacula/bacula] / bacula / patches / testing / accurate-rblist.patch
1 Index: src/filed/accurate.c
2 ===================================================================
3 --- src/filed/accurate.c        (revision 7619)
4 +++ src/filed/accurate.c        (working copy)
5 @@ -36,25 +36,17 @@
6  static int dbglvl=200;
7  
8  typedef struct PrivateCurFile {
9 -   rblink link;
10 +   hlink link;
11     char *fname;
12     time_t ctime;
13     time_t mtime;
14     bool seen;
15  } CurFile;
16  
17 -static int my_cmp(void *item1, void *item2)
18 -{
19 -   CurFile *elt1, *elt2;
20 -   elt1 = (CurFile *) item1;
21 -   elt2 = (CurFile *) item2;
22 -   return strcmp(elt1->fname, elt2->fname);
23 -}
24 -
25  static bool accurate_mark_file_as_seen(JCR *jcr, CurFile *elt)
26  {
27     /* TODO: just use elt->seen = 1 */
28 -   CurFile *temp = (CurFile *)jcr->file_list->search(elt, my_cmp);
29 +   CurFile *temp = (CurFile *)jcr->file_list->lookup(elt->fname);
30     if (temp) {
31        temp->seen = 1;              /* records are in memory */
32     }
33 @@ -66,9 +58,7 @@
34     bool found=false;
35     ret->seen = 0;
36  
37 -   CurFile search;
38 -   search.fname = fname;
39 -   CurFile *temp = (CurFile *)jcr->file_list->search(&search, my_cmp);
40 +   CurFile *temp = (CurFile *)jcr->file_list->lookup(fname);
41     if (temp) {
42        memcpy(ret, temp, sizeof(CurFile));
43        found=true;
44 @@ -81,7 +71,8 @@
45  static bool accurate_init(JCR *jcr, int nbfile)
46  {
47     CurFile *elt = NULL;
48 -   jcr->file_list = New(rblist(elt, &elt->link));
49 +   jcr->file_list = (htable *)malloc(sizeof(htable));
50 +   jcr->file_list->init(elt, &elt->link, nbfile);
51     return true;
52  }
53  
54 @@ -106,7 +97,7 @@
55     ff_pkt = init_find_files();
56     ff_pkt->type = FT_DELETED;
57  
58 -   foreach_rblist(elt, jcr->file_list) {
59 +   foreach_htable(elt, jcr->file_list) {
60        if (!elt->seen) { /* already seen */
61  //         Dmsg2(dbglvl, "deleted fname=%s seen=%i\n", elt->fname, elt->seen);
62           ff_pkt->fname = elt->fname;
63 @@ -121,7 +112,8 @@
64  bail_out:
65     /* TODO: clean htable when this function is not reached ? */
66     if (jcr->file_list) {
67 -      delete jcr->file_list;
68 +      jcr->file_list->destroy();
69 +      free(jcr->file_list);
70        jcr->file_list = NULL;
71     }
72     return true;
73 @@ -140,11 +132,11 @@
74  
75     CurFile *item;
76     /* we store CurFile, fname and ctime/mtime in the same chunk */
77 -   item = (CurFile *)malloc(sizeof(CurFile)+strlen(fname)+1);
78 +   item = (CurFile *)jcr->file_list->hash_malloc(sizeof(CurFile)+strlen(fname)+1);
79     memcpy(item, &elt, sizeof(CurFile));
80     item->fname  = (char *)item+sizeof(CurFile);
81     strcpy(item->fname, fname);
82 -   jcr->file_list->insert(item, my_cmp); 
83 +   jcr->file_list->insert(item->fname, item); 
84  
85  //   Dmsg2(dbglvl, "add fname=<%s> lstat=%s\n", fname, lstat);
86     return ret;
87 Index: src/jcr.h
88 ===================================================================
89 --- src/jcr.h   (revision 7619)
90 +++ src/jcr.h   (working copy)
91 @@ -350,7 +350,7 @@
92     CRYPTO_CTX crypto;                 /* Crypto ctx */
93     DIRRES* director;                  /* Director resource */
94     bool VSS;                          /* VSS used by FD */
95 -   rblist *file_list;                 /* Previous file list (accurate mode) */
96 +   htable *file_list;                 /* Previous file list (accurate mode) */
97  #endif /* FILE_DAEMON */
98  
99