Skip to content

Commit

Permalink
Fix cache entry validation check
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangwenyuan committed Mar 12, 2018
1 parent 2e92a02 commit cbcaf23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Nuster Changelog

## 1.7.9.7 - 2018-03-11
## 1.7.9.7 - 2018-03-12

### Added
- Purge all cache
Expand Down
17 changes: 9 additions & 8 deletions src/cache/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,19 +1078,19 @@ static void cache_manager_handler(struct appctx *appctx) {
struct stream_interface *si = appctx->owner;
struct channel *res = si_ic(si);
struct stream *s = si_strm(si);
int max = 1000;
struct cache_entry *entry = NULL;
uint64_t start = get_current_timestamp();
struct cache_entry *entry = NULL;
int max = 1000;
uint64_t start = get_current_timestamp();

while(1) {
nuster_shctx_lock(&cache->dict[0]);
while(appctx->st2 < cache->dict[0].size && max--) {
entry = cache->dict[0].entry[appctx->st2];
while(entry) {
if(appctx->st0 == NUSTER_CACHE_PURGE_MODE_NAME_ALL ||
if(entry->state == CACHE_ENTRY_STATE_VALID &&
(appctx->st0 == NUSTER_CACHE_PURGE_MODE_NAME_ALL ||
(appctx->st0 == NUSTER_CACHE_PURGE_MODE_NAME_PROXY && entry->pid == appctx->st1) ||
(entry->state == CACHE_ENTRY_STATE_VALID && entry->rule->id == appctx->st1)
) {
fprintf(stderr, "purge %d\n", entry->rule->id);
entry->rule->id == appctx->st1)) {
entry->state = CACHE_ENTRY_STATE_INVALID;
entry->data->invalid = 1;
entry->data = NULL;
Expand All @@ -1100,7 +1100,8 @@ static void cache_manager_handler(struct appctx *appctx) {
}
appctx->st2++;
}
if (get_current_timestamp() - start > 1) break;
nuster_shctx_unlock(&cache->dict[0]);
if(get_current_timestamp() - start > 1) break;
max = 1000;
}
task_wakeup(s->task, TASK_WOKEN_OTHER);
Expand Down

0 comments on commit cbcaf23

Please sign in to comment.