bool send_level_command(JCR *jcr)
{
BSOCK *fd = jcr->file_bsock;
- const char *accurate=jcr->job->accurate?"accurate_":"";
- const char *not_accurate="";
+ const char *accurate = jcr->job->accurate?"accurate_":"";
+ const char *not_accurate = "";
/*
* Send Level command to File daemon
*/
Switzerland, email:ftf@fsfeurope.org.
*/
/*
- * Version $Id$
+ * Version $Id $
*
*/
static bool accurate_init(JCR *jcr, int nbfile)
{
- CurFile *elt=NULL;
+ CurFile *elt = NULL;
jcr->file_list = (htable *)malloc(sizeof(htable));
jcr->file_list->init(elt, &elt->link, nbfile);
return true;
ff_pkt = init_find_files();
ff_pkt->type = FT_DELETED;
- foreach_htable (elt, jcr->file_list) {
+ foreach_htable(elt, jcr->file_list) {
if (!elt->seen) { /* already seen */
Dmsg2(dbglvl, "deleted fname=%s seen=%i\n", elt->fname, elt->seen);
ff_pkt->fname = elt->fname;
}
/*
- * TODO: use bigbuffer from htable
+ * TODO: use big buffer from htable
*/
int accurate_cmd(JCR *jcr)
{
edit_uint64_with_commas(sm_max_bytes, b3),
edit_uint64_with_commas(sm_buffers, b4),
edit_uint64_with_commas(sm_max_buffers, b5));
-
#endif
return true;
{"RunBeforeJob", runbefore_cmd, 0},
{"RunAfterJob", runafter_cmd, 0},
{"Run", runscript_cmd, 0},
- {"accurate", accurate_cmd, 0},
+ {"accurate", accurate_cmd, 0},
{NULL, NULL} /* list terminator */
};
int mtime_only;
level = get_memory(dir->msglen+1);
- Dmsg1(110, "level_cmd: %s", dir->msg);
+ Dmsg1(100, "level_cmd: %s", dir->msg);
if (strstr(dir->msg, "accurate")) {
jcr->accurate = true;
}
/*
* This subroutine gets a big buffer.
*/
-void htable::malloc_buf(int size)
+void htable::malloc_big_buf(int size)
{
struct h_mem *hmem;
hmem = (struct h_mem *)malloc(size);
total_size += size;
blocks++;
- hmem->next = this->mem;
- this->mem = hmem;
- hmem->mem = mem->first;
+ hmem->next = mem_block;
+ mem_block = hmem;
+ hmem->mem = mem_block->first;
hmem->rem = (char *)hmem + size - hmem->mem;
- Dmsg2(200, "malloc buf size=%d rem=%d\n", size, hmem->rem);
+ Dmsg3(100, "malloc buf=%p size=%d rem=%d\n", hmem, size, hmem->rem);
}
/* This routine frees the whole tree */
-void htable::hash_free()
+void htable::hash_big_free()
{
struct h_mem *hmem, *rel;
- for (hmem=mem; hmem; ) {
+ for (hmem=mem_block; hmem; ) {
rel = hmem;
hmem = hmem->next;
+ Dmsg1(100, "free malloc buf=%p\n", rel);
free(rel);
}
}
#endif
+/*
+ * Normal hash malloc routine that gets a
+ * "small" buffer from the big buffer
+ */
char *htable::hash_malloc(int size)
{
#ifdef BIG_MALLOC
char *buf;
int asize = BALIGN(size);
- if (mem->rem < asize) {
+ if (mem_block->rem < asize) {
uint32_t mb_size;
if (total_size >= 1000000) {
mb_size = 1000000;
} else {
mb_size = 100000;
}
- malloc_buf(mb_size);
+ malloc_big_buf(mb_size);
}
- mem->rem -= asize;
- buf = mem->mem;
- mem->mem += asize;
+ mem_block->rem -= asize;
+ buf = mem_block->mem;
+ mem_block->mem += asize;
return buf;
#else
total_size += size;
{
int pwr;
+ memset(this, 0, sizeof(htable));
if (tsize < 31) {
tsize = 31;
}
loffset = (char *)link - (char *)item;
mask = ~((~0)<<pwr); /* 3 bits => table size = 8 */
rshift = 30 - pwr; /* start using bits 28, 29, 30 */
- num_items = 0; /* number of entries in table */
buckets = 1<<pwr; /* hash table size -- power of two */
max_items = buckets * 4; /* allow average 4 entries per chain */
table = (hlink **)malloc(buckets * sizeof(hlink *));
memset(table, 0, buckets * sizeof(hlink *));
- walkptr = NULL;
- walk_index = 0;
- total_size = 0;
- blocks = 0;
#ifdef BIG_MALLOC
- mem = NULL;
- malloc_buf(1000000); /* ***FIXME*** need variable or some estimate */
+ malloc_big_buf(1000000); /* ***FIXME*** need variable or some estimate */
#endif
}
void htable::destroy()
{
#ifdef BIG_MALLOC
- hash_free();
+ hash_big_free();
#else
void *ni;
void *li = first();
struct h_mem {
struct h_mem *next; /* next buffer */
- int rem; /* remaining bytes */
+ int32_t rem; /* remaining bytes in big_buffer */
char *mem; /* memory pointer */
char first[1]; /* first byte */
};
uint32_t total_size; /* total bytes malloced */
uint32_t blocks; /* blocks malloced */
#ifdef BIG_MALLOC
- struct h_mem *mem; /* malloced memory blocks */
- void malloc_buf(int size); /* Get a bit buffer */
+ struct h_mem *mem_block; /* malloc'ed memory block chain */
+ void malloc_big_buf(int size); /* Get a big buffer */
#endif
void hash_index(char *key); /* produce hash key,index */
void grow_table(); /* grow the table */
uint32_t size(); /* return size of table */
char *hash_malloc(int size); /* malloc bytes for a hash entry */
#ifdef BIG_MALLOC
- void hash_free(); /* free all hash allocated bytes */
+ void hash_big_free(); /* free all hash allocated big buffers */
#endif
};
#undef VERSION
#define VERSION "2.5.3"
-#define BDATE "14 September 2008"
-#define LSMDATE "14Sep08"
+#define BDATE "16 September 2008"
+#define LSMDATE "16Sep08"
#define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
#define BYEAR "2008" /* year for copyright messages in progs */
remove reader/writer in FOPTS????
General:
+16Sep08
+kes Tweaks to htable code to improved debugging and make names
+ a bit more meaningful.
15Sep08
ebl Remove time_t from update_stats()
14Sep08