-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug/3162 registration destroys compound values #28
base: master
Are you sure you want to change the base?
Changes from all commits
c39c9a0
7b48129
3805d41
0077b94
b2ae235
fc56a87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,79 @@ using namespace orion; | |
|
||
|
||
|
||
typedef struct CompoundSave | ||
{ | ||
std::string name; | ||
ContextAttribute* aP; | ||
orion::CompoundValueNode* compoundP; | ||
ContextAttribute* aParentP; | ||
std::string state; | ||
} CompoundSave; | ||
|
||
static CompoundSave compoundSaveV[100]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 100 should be unhardwired to a #define (maybe in this same file, no need to include it in global.h in the case of a workaround) |
||
static int compoundSaveIx = 0; | ||
|
||
void compoundSaveInit(void) | ||
{ | ||
for (int ix = 0; ix < 100; ix++) | ||
compoundSaveV[ix].state = "unused"; | ||
} | ||
|
||
#if 0 | ||
void compoundSaveReport(void) | ||
{ | ||
LM_TMP(("%-20s %-10s %-10s %-10s %s", "name", "attrP", "compoundP", "from Attr", "state")); | ||
for (int ix = 0; ix < compoundSaveIx; ix++) | ||
{ | ||
LM_TMP(("%-20s 0x%08x 0x%08x 0x%08x %s", | ||
compoundSaveV[ix].name.c_str(), | ||
compoundSaveV[ix].aP, | ||
compoundSaveV[ix].compoundP, | ||
compoundSaveV[ix].aParentP, | ||
compoundSaveV[ix].state.c_str())); | ||
// if (compoundSaveV[ix].compoundP != NULL) | ||
// { | ||
// delete compoundSaveV[ix].compoundP; | ||
// compoundSaveV[ix].compoundP = NULL; | ||
// } | ||
} | ||
} | ||
#endif | ||
|
||
static void compoundSave(ContextAttribute* aP, ContextAttribute* aParentP) | ||
{ | ||
CompoundSave* csP = &compoundSaveV[compoundSaveIx]; | ||
|
||
csP->aP = aP; | ||
csP->name = aP->name; | ||
csP->compoundP = aP->compoundValueP; | ||
csP->aParentP = aParentP; | ||
csP->state = "used"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe an enum (instead of plain strings) should be used for states. |
||
|
||
++compoundSaveIx; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about if this index overpass 100 ? |
||
} | ||
|
||
static void compoundUnsave(ContextAttribute* aP) | ||
{ | ||
if (aP->compoundValueP != NULL) | ||
{ | ||
for (int ix = 0; ix < compoundSaveIx; ix++) | ||
{ | ||
if (aP->compoundValueP == compoundSaveV[ix].compoundP) | ||
{ | ||
if (compoundSaveV[ix].state == "used") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style:
(Pls review the PR, I have seen more of this in other places) |
||
compoundSaveV[ix].state = "usedAndFreed"; | ||
else if (compoundSaveV[ix].state == "unused") | ||
compoundSaveV[ix].state = "freedWhenUnused"; | ||
else | ||
compoundSaveV[ix].state = "freedWhen-" + compoundSaveV[ix].state; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
/* **************************************************************************** | ||
* | ||
* ContextAttribute::bsonAppendAttrValue - | ||
|
@@ -253,14 +326,22 @@ ContextAttribute::ContextAttribute(ContextAttribute* caP, bool useDefaultType) | |
stringValue = caP->stringValue; | ||
numberValue = caP->numberValue; | ||
boolValue = caP->boolValue; | ||
compoundValueP = caP->compoundValueP; | ||
caP->compoundValueP = NULL; | ||
found = caP->found; | ||
skip = false; | ||
typeGiven = caP->typeGiven; | ||
onlyValue = caP->onlyValue; | ||
previousValue = NULL; | ||
|
||
if (caP->compoundValueP != NULL) | ||
{ | ||
compoundValueP = caP->compoundValueP->clone(); | ||
compoundSave(this, caP); | ||
} | ||
else | ||
{ | ||
compoundValueP = NULL; | ||
} | ||
|
||
creDate = caP->creDate; | ||
modDate = caP->modDate; | ||
|
||
|
@@ -1189,6 +1270,7 @@ void ContextAttribute::present(const std::string& indent, int ix) | |
*/ | ||
void ContextAttribute::release(void) | ||
{ | ||
compoundUnsave(this); | ||
if (compoundValueP != NULL) | ||
{ | ||
delete compoundValueP; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -569,6 +569,8 @@ static void requestCompleted | |
std::string spath = (ciP->servicePathV.size() > 0)? ciP->servicePathV[0] : ""; | ||
struct timespec reqEndTime; | ||
|
||
// compoundSaveReport(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this comment is preserved at the end (seems to be a good idea), a FIXME mark citing telefonicaid#3162 should be included in the line above it. |
||
|
||
if ((ciP->payload != NULL) && (ciP->payload != static_buffer)) | ||
{ | ||
free(ciP->payload); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If at the end we go with the workaround implemented by this PR, an explanation of the workaround should be included in a comment in the code in order to guide for a definitive solution. The text in the PR body is a good starting point for that.
Issue telefonicaid#3162 would remain open until the definitive solution comes.