durable_rules 0.34.03 → 0.34.04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2140bced1252c9b280451f9fc98d586b88af859
4
- data.tar.gz: 28c6962e51f7d51d22f26aaa374c5f079e46a91c
3
+ metadata.gz: c83fbc15f95b38c2777cd335acae30e82d862919
4
+ data.tar.gz: c03de9b4e41d27382d1edfe54e7ceb61e9d6c489
5
5
  SHA512:
6
- metadata.gz: c462a03d557ec58f26df72d5c81b6f3026348fa606f75590882a29ef35a4da226337aebff6315695e27dac7d4251937497a7eac778822972ce70a375cfe868bd
7
- data.tar.gz: 229e8f7d619835b4c9902f764798b7099fbf0ebe6c5442c36fd4f5aca136a0be488b65c187273dbf2f18b14e88ff821ef48007499fa41a67e71145f19feb8c3f
6
+ metadata.gz: 001c07ac0b59a773a2b90028c2fd62d5e048747075e7ec00f08c8d7b2bd6e44f1d85cc052fb5ca6b64414219a970bdc614e2af704d3c267ff1c14cbb3d7c81b2
7
+ data.tar.gz: cef74ba36f48e2492177f03dc41adad33482b3ebaa5139f0775f7d800241c06d55f8e827a7c4be38769217567a9d9d77991a8c4376b4ee1dfbd4d7a97f3406d8
data/src/rules/events.c CHANGED
@@ -1076,7 +1076,6 @@ static unsigned int handleMessageCore(ruleset *tree,
1076
1076
  commands[*commandCount] = storeCommand;
1077
1077
  ++*commandCount;
1078
1078
  }
1079
-
1080
1079
  char *removeCommand = NULL;
1081
1080
  char *addKeys[MAX_ADD_COUNT];
1082
1081
  unsigned int addCount = 0;
data/src/rules/net.c CHANGED
@@ -397,7 +397,7 @@ static unsigned int loadTimerCommand(ruleset *tree, binding *rulesBinding) {
397
397
  if (asprintf(&lua,
398
398
  "local timer_key = \"%s!t\"\n"
399
399
  "local timestamp = tonumber(ARGV[1])\n"
400
- "local res = redis.call(\"zrangebyscore\", timer_key, 0, timestamp, \"limit\", 0, 10)\n"
400
+ "local res = redis.call(\"zrangebyscore\", timer_key, 0, timestamp, \"limit\", 0, 50)\n"
401
401
  "if #res > 0 then\n"
402
402
  " for i = 0, #res, 1 do\n"
403
403
  " redis.call(\"zincrby\", timer_key, 10, res[i])\n"
@@ -1755,6 +1755,10 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1755
1755
  " end\n"
1756
1756
  " result = result + count\n"
1757
1757
  " if not is_pure_fact(frame, index) then\n"
1758
+ // the mid list might not be cleaned up if the first mid is always valid.
1759
+ " if (#new_mids %% 10) == 0 then\n"
1760
+ " cleanup = true\n"
1761
+ " end\n"
1758
1762
  " break\n"
1759
1763
  " end\n"
1760
1764
  " end\n"
data/src/rules/state.c CHANGED
@@ -40,6 +40,10 @@ static unsigned int evictEntry(ruleset *tree) {
40
40
 
41
41
  free(current->sid);
42
42
  current->sid = NULL;
43
+ current->sidHash = 0;
44
+ current->bindingIndex = 0;
45
+ current->lastRefresh = 0;
46
+ current->propertiesLength = 0;
43
47
  found = 1;
44
48
  }
45
49
  }
@@ -95,6 +99,7 @@ static unsigned char ensureEntry(ruleset *tree, char *sid, unsigned int sidHash,
95
99
  unsigned int offset = tree->stateBuckets[bucket];
96
100
  stateEntry *current = NULL;
97
101
  unsigned char found = 0;
102
+ // find state entry by sid in hash table
98
103
  while (offset != UNDEFINED_HASH_OFFSET) {
99
104
  current = &tree->state[offset];
100
105
  if (current->sidHash == sidHash) {
@@ -106,28 +111,38 @@ static unsigned char ensureEntry(ruleset *tree, char *sid, unsigned int sidHash,
106
111
 
107
112
  offset = current->nextHashOffset;
108
113
  }
114
+
115
+ // create entry if not found
109
116
  if (offset == UNDEFINED_HASH_OFFSET) {
110
117
  offset = addEntry(tree, sid, sidHash);
111
118
  current = &tree->state[offset];
112
119
  }
113
120
 
121
+ // remove entry from lru double linked list
114
122
  if (current->prevLruOffset != UNDEFINED_HASH_OFFSET) {
115
123
  tree->state[current->prevLruOffset].nextLruOffset = current->nextLruOffset;
124
+ if (tree->mruStateOffset == offset) {
125
+ tree->mruStateOffset = current->prevLruOffset;
126
+ }
116
127
  }
117
128
 
118
129
  if (current->nextLruOffset != UNDEFINED_HASH_OFFSET) {
119
130
  tree->state[current->nextLruOffset].prevLruOffset = current->prevLruOffset;
131
+ if (tree->lruStateOffset == offset) {
132
+ tree->lruStateOffset = current->nextLruOffset;
133
+ }
120
134
  }
121
135
 
122
- current->prevLruOffset = tree->mruStateOffset;
136
+ // attach entry to end of linked list
123
137
  current->nextLruOffset = UNDEFINED_HASH_OFFSET;
138
+ current->prevLruOffset = tree->mruStateOffset;
124
139
  if (tree->mruStateOffset == UNDEFINED_HASH_OFFSET) {
125
140
  tree->lruStateOffset = offset;
126
141
  } else {
127
142
  tree->state[tree->mruStateOffset].nextLruOffset = offset;
128
143
  }
129
-
130
144
  tree->mruStateOffset = offset;
145
+
131
146
  *result = current;
132
147
  return found;
133
148
  }
@@ -317,7 +332,7 @@ static unsigned int resolveBindingAndEntry(ruleset *tree,
317
332
 
318
333
  unsigned int resolveBinding(void *handle,
319
334
  char *sid,
320
- void **rulesBinding) {
335
+ void **rulesBinding) {
321
336
  stateEntry *entry = NULL;
322
337
  return resolveBindingAndEntry(handle, sid, &entry, rulesBinding);
323
338
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durable_rules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.03
4
+ version: 0.34.04
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake