diff options
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 8db1569379..b6c86d7ddb 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -277,17 +277,16 @@ static struct tcramcache | |||
277 | { | 277 | { |
278 | struct ramcache_header *hdr; /* allocated ramcache_header */ | 278 | struct ramcache_header *hdr; /* allocated ramcache_header */ |
279 | int handle; /* buffer handle */ | 279 | int handle; /* buffer handle */ |
280 | int move_lock; | ||
281 | } tcramcache; | 280 | } tcramcache; |
282 | 281 | ||
283 | static inline void tcrc_buffer_lock(void) | 282 | static inline void tcrc_buffer_lock(void) |
284 | { | 283 | { |
285 | tcramcache.move_lock++; | 284 | core_pin(tcramcache.handle); |
286 | } | 285 | } |
287 | 286 | ||
288 | static inline void tcrc_buffer_unlock(void) | 287 | static inline void tcrc_buffer_unlock(void) |
289 | { | 288 | { |
290 | tcramcache.move_lock--; | 289 | core_unpin(tcramcache.handle); |
291 | } | 290 | } |
292 | 291 | ||
293 | #else /* ndef HAVE_TC_RAMCACHE */ | 292 | #else /* ndef HAVE_TC_RAMCACHE */ |
@@ -3861,10 +3860,9 @@ static bool delete_entry(long idx_id) | |||
3861 | struct tagfile_entry *tfe; | 3860 | struct tagfile_entry *tfe; |
3862 | int32_t *seek = &tcramcache.hdr->indices[idx_id].tag_seek[tag]; | 3861 | int32_t *seek = &tcramcache.hdr->indices[idx_id].tag_seek[tag]; |
3863 | 3862 | ||
3863 | /* crc_32 is assumed not to yield (why would it...?) */ | ||
3864 | tfe = (struct tagfile_entry *)&tcramcache.hdr->tags[tag][*seek]; | 3864 | tfe = (struct tagfile_entry *)&tcramcache.hdr->tags[tag][*seek]; |
3865 | tcrc_buffer_lock(); /* protect tfe and seek if crc_32() yield()s */ | ||
3866 | *seek = crc_32(tfe->tag_data, strlen(tfe->tag_data), 0xffffffff); | 3865 | *seek = crc_32(tfe->tag_data, strlen(tfe->tag_data), 0xffffffff); |
3867 | tcrc_buffer_unlock(); | ||
3868 | myidx.tag_seek[tag] = *seek; | 3866 | myidx.tag_seek[tag] = *seek; |
3869 | } | 3867 | } |
3870 | else | 3868 | else |
@@ -4005,9 +4003,6 @@ static void fix_ramcache(void* old_addr, void* new_addr) | |||
4005 | static int move_cb(int handle, void* current, void* new) | 4003 | static int move_cb(int handle, void* current, void* new) |
4006 | { | 4004 | { |
4007 | (void)handle; | 4005 | (void)handle; |
4008 | if (tcramcache.move_lock > 0) | ||
4009 | return BUFLIB_CB_CANNOT_MOVE; | ||
4010 | |||
4011 | fix_ramcache(current, new); | 4006 | fix_ramcache(current, new); |
4012 | tcramcache.hdr = new; | 4007 | tcramcache.hdr = new; |
4013 | return BUFLIB_CB_OK; | 4008 | return BUFLIB_CB_OK; |
@@ -4092,8 +4087,8 @@ static bool tagcache_dumpload(void) | |||
4092 | return false; | 4087 | return false; |
4093 | } | 4088 | } |
4094 | 4089 | ||
4095 | tcrc_buffer_lock(); | ||
4096 | tcramcache.handle = handle; | 4090 | tcramcache.handle = handle; |
4091 | tcrc_buffer_lock(); | ||
4097 | tcramcache.hdr = core_get_data(handle); | 4092 | tcramcache.hdr = core_get_data(handle); |
4098 | rc = read(fd, tcramcache.hdr, shdr.tc_stat.ramcache_allocated); | 4093 | rc = read(fd, tcramcache.hdr, shdr.tc_stat.ramcache_allocated); |
4099 | tcrc_buffer_unlock(); | 4094 | tcrc_buffer_unlock(); |