Skip to content

Commit

Permalink
extract_manager: make use of _lru_touch_value()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Aug 15, 2024
1 parent 2133c34 commit 99539f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions libsqsh/src/extract/extract_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ sqsh__extract_manager_uncompress(
const struct CxBuffer **target) {
int rv = 0;
bool locked = false;
struct CxBuffer *buffer = NULL;

rv = sqsh__mutex_lock(&manager->lock);
if (rv < 0) {
Expand All @@ -178,17 +179,17 @@ sqsh__extract_manager_uncompress(

const uint64_t address = sqsh__map_reader_address(reader);

*target = cx_rc_radix_tree_retain(&manager->cache, address);
buffer = cx_rc_radix_tree_retain(&manager->cache, address);

if (*target == NULL) {
struct CxBuffer buffer = {0};
if (buffer == NULL) {
struct CxBuffer tmp_buffer = {0};
rv = sqsh__mutex_unlock(&manager->lock);
if (rv < 0) {
goto out;
}
locked = false;

rv = extract(manager, reader, &buffer);
rv = extract(manager, reader, &tmp_buffer);
if (rv < 0) {
goto out;
}
Expand All @@ -199,9 +200,10 @@ sqsh__extract_manager_uncompress(
}
locked = true;

*target = cx_rc_radix_tree_put(&manager->cache, address, &buffer);
buffer = cx_rc_radix_tree_put(&manager->cache, address, &tmp_buffer);
}
rv = cx_lru_touch(&manager->lru, address);
rv = cx_lru_touch_value(&manager->lru, address, buffer);
*target = buffer;

out:
if (locked) {
Expand Down
2 changes: 1 addition & 1 deletion subprojects/cextras.wrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[wrap-git]
directory = cextras
revision = 393f89745bb306855b3f8dab2c9b268e8feddbae
revision = b9d8c14575287ddcf87abcbf8889caf42574f253
url = https://github.com/Gottox/cextras.git
depth = 1

Expand Down

0 comments on commit 99539f7

Please sign in to comment.