durable_rules 2.0.15 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/rules/events.c +9 -8
- data/src/rules/state.c +30 -27
- data/src/rules/state.h +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf45128fee07cc96208c6acf6ad9145efdf26a42
|
4
|
+
data.tar.gz: c6ee78e78cc7cf95feb99d325e1afb382a9d49c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f85c1d8a6d9afad3489c151e0af655649c5f5f43c4b33ed7c65e73c1bba31e1a3421bd2a901589c14839fedf80a645f98f07bd2be818be7d1a60f7f6d21aec9
|
7
|
+
data.tar.gz: 767a9be4effd44052779b0fd568fa9f70c5c8da482ffb6022c23fcfa497c6a725d5d923ce7a375f78dc121999b93da19fd70d3b2d51084c3fc1fa994c6f0f09e
|
data/src/rules/events.c
CHANGED
@@ -2236,8 +2236,10 @@ unsigned int startActionForState(unsigned int handle,
|
|
2236
2236
|
unsigned int actionStateIndex;
|
2237
2237
|
unsigned int resultCount;
|
2238
2238
|
unsigned int resultFrameOffset;
|
2239
|
+
time_t currentTime = time(NULL);
|
2239
2240
|
|
2240
2241
|
CHECK_RESULT(getNextResultInState(tree,
|
2242
|
+
currentTime,
|
2241
2243
|
resultState,
|
2242
2244
|
&actionStateIndex,
|
2243
2245
|
&resultCount,
|
@@ -2256,7 +2258,7 @@ unsigned int startActionForState(unsigned int handle,
|
|
2256
2258
|
resultState->context.actionStateIndex = actionStateIndex;
|
2257
2259
|
resultState->context.resultCount = resultCount;
|
2258
2260
|
resultState->context.resultFrameOffset = resultFrameOffset;
|
2259
|
-
resultState->lockExpireTime =
|
2261
|
+
resultState->lockExpireTime = currentTime + STATE_LEASE_TIME;
|
2260
2262
|
*messages = resultState->context.messages;
|
2261
2263
|
*stateFact = resultState->context.stateFact;
|
2262
2264
|
|
@@ -2302,6 +2304,7 @@ static unsigned int deleteCurrentAction(ruleset *tree,
|
|
2302
2304
|
|
2303
2305
|
mid[midProperty->valueLength] = '\0';
|
2304
2306
|
|
2307
|
+
|
2305
2308
|
CHECK_RESULT(handleDeleteMessage(tree,
|
2306
2309
|
state,
|
2307
2310
|
mid,
|
@@ -2311,10 +2314,7 @@ static unsigned int deleteCurrentAction(ruleset *tree,
|
|
2311
2314
|
}
|
2312
2315
|
|
2313
2316
|
resultFrameOffset = resultFrame->nextOffset;
|
2314
|
-
|
2315
|
-
if (result != RULES_OK) {
|
2316
|
-
return result;
|
2317
|
-
}
|
2317
|
+
CHECK_RESULT(deleteDispatchingActionFrame(state, resultLocation));
|
2318
2318
|
}
|
2319
2319
|
|
2320
2320
|
return RULES_OK;
|
@@ -2345,16 +2345,17 @@ unsigned int completeAndStartAction(unsigned int handle,
|
|
2345
2345
|
resultState->context.actionStateIndex,
|
2346
2346
|
resultState->context.resultCount,
|
2347
2347
|
resultState->context.resultFrameOffset));
|
2348
|
-
|
2349
|
-
|
2348
|
+
|
2350
2349
|
freeActionContext(resultState);
|
2351
2350
|
|
2352
2351
|
actionStateNode *resultAction;
|
2353
2352
|
unsigned int actionStateIndex;
|
2354
2353
|
unsigned int resultCount;
|
2355
2354
|
unsigned int resultFrameOffset;
|
2355
|
+
time_t currentTime = time(NULL);
|
2356
2356
|
|
2357
2357
|
CHECK_RESULT(getNextResultInState(tree,
|
2358
|
+
currentTime,
|
2358
2359
|
resultState,
|
2359
2360
|
&actionStateIndex,
|
2360
2361
|
&resultCount,
|
@@ -2370,7 +2371,7 @@ unsigned int completeAndStartAction(unsigned int handle,
|
|
2370
2371
|
resultState->context.actionStateIndex = actionStateIndex;
|
2371
2372
|
resultState->context.resultCount = resultCount;
|
2372
2373
|
resultState->context.resultFrameOffset = resultFrameOffset;
|
2373
|
-
resultState->lockExpireTime =
|
2374
|
+
resultState->lockExpireTime = currentTime + STATE_LEASE_TIME;
|
2374
2375
|
*messages = resultState->context.messages;
|
2375
2376
|
return RULES_OK;
|
2376
2377
|
}
|
data/src/rules/state.c
CHANGED
@@ -1126,6 +1126,7 @@ unsigned int serializeState(stateNode *state,
|
|
1126
1126
|
}
|
1127
1127
|
|
1128
1128
|
unsigned int getNextResultInState(void *tree,
|
1129
|
+
time_t currentTime,
|
1129
1130
|
stateNode *state,
|
1130
1131
|
unsigned int *actionStateIndex,
|
1131
1132
|
unsigned int *resultCount,
|
@@ -1134,23 +1135,25 @@ unsigned int getNextResultInState(void *tree,
|
|
1134
1135
|
|
1135
1136
|
ruleset *rulesetTree = (ruleset*)tree;
|
1136
1137
|
*resultAction = NULL;
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
if (
|
1141
|
-
(actionNode->reteNode->value.c.
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1138
|
+
if (currentTime - state->lockExpireTime > STATE_LEASE_TIME) {
|
1139
|
+
for (unsigned int index = 0; index < rulesetTree->actionCount; ++index) {
|
1140
|
+
actionStateNode *actionNode = &state->actionState[index];
|
1141
|
+
if (actionNode->reteNode) {
|
1142
|
+
if ((actionNode->reteNode->value.c.cap && actionNode->resultPool.count) ||
|
1143
|
+
(actionNode->reteNode->value.c.count && actionNode->resultPool.count >= actionNode->reteNode->value.c.count)) {
|
1144
|
+
*resultAction = actionNode;
|
1145
|
+
*actionStateIndex = index;
|
1146
|
+
*resultFrameOffset = actionNode->resultIndex[0];
|
1147
|
+
if (actionNode->reteNode->value.c.count) {
|
1148
|
+
*resultCount = actionNode->reteNode->value.c.count;
|
1149
|
+
} else {
|
1150
|
+
*resultCount = (actionNode->reteNode->value.c.cap > actionNode->resultPool.count ?
|
1151
|
+
actionNode->resultPool.count :
|
1152
|
+
actionNode->reteNode->value.c.cap);
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
return RULES_OK;
|
1151
1156
|
}
|
1152
|
-
|
1153
|
-
return RULES_OK;
|
1154
1157
|
}
|
1155
1158
|
}
|
1156
1159
|
}
|
@@ -1177,18 +1180,18 @@ unsigned int getNextResult(void *tree,
|
|
1177
1180
|
while (count < rulesetTree->statePool.count && !*resultAction) {
|
1178
1181
|
unsigned int nodeOffset = rulesetTree->reverseStateIndex[rulesetTree->currentStateIndex];
|
1179
1182
|
*resultState = STATE_NODE(tree, nodeOffset);
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1183
|
+
|
1184
|
+
unsigned int result = getNextResultInState(tree,
|
1185
|
+
currentTime,
|
1186
|
+
*resultState,
|
1187
|
+
actionStateIndex,
|
1188
|
+
resultCount,
|
1189
|
+
resultFrameOffset,
|
1190
|
+
resultAction);
|
1191
|
+
if (result != ERR_NO_ACTION_AVAILABLE) {
|
1192
|
+
return result;
|
1190
1193
|
}
|
1191
|
-
|
1194
|
+
|
1192
1195
|
rulesetTree->currentStateIndex = (rulesetTree->currentStateIndex + 1) % rulesetTree->statePool.count;
|
1193
1196
|
++count;
|
1194
1197
|
}
|
data/src/rules/state.h
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesus Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|