comparison src/filecache.c @ 1498:5f49f305a6b6

improved debug messages
author nadvornik
date Tue, 31 Mar 2009 20:05:16 +0000
parents cf4029d10d38
children 956aab097ea7
comparison
equal deleted inserted replaced
1497:2c54f3f71634 1498:5f49f305a6b6
58 { 58 {
59 FileCacheEntry *fce = work->data; 59 FileCacheEntry *fce = work->data;
60 if (fce->fd == fd) 60 if (fce->fd == fd)
61 { 61 {
62 /* entry exists */ 62 /* entry exists */
63 DEBUG_1("cache hit: fc=%p %s", fc, fd->path); 63 DEBUG_2("cache hit: fc=%p %s", fc, fd->path);
64 if (work == fc->list) return TRUE; /* already at the beginning */ 64 if (work == fc->list) return TRUE; /* already at the beginning */
65 /* move it to the beginning */ 65 /* move it to the beginning */
66 DEBUG_1("cache move to front: fc=%p %s", fc, fd->path); 66 DEBUG_2("cache move to front: fc=%p %s", fc, fd->path);
67 fc->list = g_list_remove_link(fc->list, work); 67 fc->list = g_list_remove_link(fc->list, work);
68 fc->list = g_list_concat(work, fc->list); 68 fc->list = g_list_concat(work, fc->list);
69 69
70 if (file_data_check_changed_files(fd)) /* this will eventually remove changed files from cache via file_cache_notify_cb */ 70 if (file_data_check_changed_files(fd)) /* this will eventually remove changed files from cache via file_cache_notify_cb */
71 return FALSE; 71 return FALSE;
73 if (debug_file_cache) file_cache_dump(fc); 73 if (debug_file_cache) file_cache_dump(fc);
74 return TRUE; 74 return TRUE;
75 } 75 }
76 work = work->next; 76 work = work->next;
77 } 77 }
78 DEBUG_1("cache miss: fc=%p %s", fc, fd->path); 78 DEBUG_2("cache miss: fc=%p %s", fc, fd->path);
79 return FALSE; 79 return FALSE;
80 } 80 }
81 81
82 void file_cache_set_size(FileCacheData *fc, gulong size) 82 void file_cache_set_size(FileCacheData *fc, gulong size)
83 { 83 {
93 last_fe = work->data; 93 last_fe = work->data;
94 prev = work->prev; 94 prev = work->prev;
95 fc->list = g_list_delete_link(fc->list, work); 95 fc->list = g_list_delete_link(fc->list, work);
96 work = prev; 96 work = prev;
97 97
98 DEBUG_1("file changed - cache remove: fc=%p %s", fc, last_fe->fd->path); 98 DEBUG_2("file changed - cache remove: fc=%p %s", fc, last_fe->fd->path);
99 fc->size -= last_fe->size; 99 fc->size -= last_fe->size;
100 fc->release(last_fe->fd); 100 fc->release(last_fe->fd);
101 file_data_unref(last_fe->fd); 101 file_data_unref(last_fe->fd);
102 g_free(last_fe); 102 g_free(last_fe);
103 } 103 }
107 { 107 {
108 FileCacheEntry *fe; 108 FileCacheEntry *fe;
109 109
110 if (file_cache_get(fc, fd)) return; 110 if (file_cache_get(fc, fd)) return;
111 111
112 DEBUG_1("cache add: fc=%p %s", fc, fd->path); 112 DEBUG_2("cache add: fc=%p %s", fc, fd->path);
113 fe = g_new(FileCacheEntry, 1); 113 fe = g_new(FileCacheEntry, 1);
114 fe->fd = file_data_ref(fd); 114 fe->fd = file_data_ref(fd);
115 fe->size = size; 115 fe->size = size;
116 fc->list = g_list_prepend(fc->list, fe); 116 fc->list = g_list_prepend(fc->list, fe);
117 fc->size += size; 117 fc->size += size;
181 { 181 {
182 FileCacheData *fc = data; 182 FileCacheData *fc = data;
183 183
184 if (type & (NOTIFY_REREAD | NOTIFY_CHANGE)) /* invalidate the entry on each file change */ 184 if (type & (NOTIFY_REREAD | NOTIFY_CHANGE)) /* invalidate the entry on each file change */
185 { 185 {
186 DEBUG_1("Notify cache: %s %04x", fd->path, type);
186 file_cache_remove_fd(fc, fd); 187 file_cache_remove_fd(fc, fd);
187 } 188 }
188 } 189 }
189 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 190 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */