mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 15:53:55 +00:00
Fixed db retry logic
This commit is contained in:
@@ -4028,7 +4028,7 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (agentHost->masterDb == NULL)
|
if (agentHost->masterDb == NULL || ILibSimpleDataStore_IsCacheOnly(agentHost->masterDb))
|
||||||
{
|
{
|
||||||
void **data = (void**)ILibMemory_SmartAllocate(4 * sizeof(void*));
|
void **data = (void**)ILibMemory_SmartAllocate(4 * sizeof(void*));
|
||||||
data[0] = agentHost;
|
data[0] = agentHost;
|
||||||
@@ -4036,6 +4036,12 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
data[2] = param;
|
data[2] = param;
|
||||||
data[3] = (void*)(uintptr_t)parseCommands;
|
data[3] = (void*)(uintptr_t)parseCommands;
|
||||||
|
|
||||||
|
if (agentHost->masterDb != NULL)
|
||||||
|
{
|
||||||
|
ILibSimpleDataStore_Close(agentHost->masterDb);
|
||||||
|
agentHost->masterDb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
switch (agentHost->dbRetryCount)
|
switch (agentHost->dbRetryCount)
|
||||||
{
|
{
|
||||||
case 10:
|
case 10:
|
||||||
|
|||||||
@@ -615,7 +615,13 @@ __EXPORT_TYPE int ILibSimpleDataStore_PutEx(ILibSimpleDataStore dataStore, char*
|
|||||||
ILibSimpleDataStore_Root *root = (ILibSimpleDataStore_Root*)dataStore;
|
ILibSimpleDataStore_Root *root = (ILibSimpleDataStore_Root*)dataStore;
|
||||||
ILibSimpleDataStore_TableEntry *entry;
|
ILibSimpleDataStore_TableEntry *entry;
|
||||||
|
|
||||||
if (root == NULL) return 0;
|
if (root == NULL) { return 0; }
|
||||||
|
if (root->dataFile == NULL)
|
||||||
|
{
|
||||||
|
ILibSimpleDataStore_Cached(dataStore, key, keyLen, value, valueLen);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (keyLen > 1 && key[keyLen - 1] == 0) { keyLen -= 1; }
|
if (keyLen > 1 && key[keyLen - 1] == 0) { keyLen -= 1; }
|
||||||
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
entry = (ILibSimpleDataStore_TableEntry*)ILibHashtable_Get(root->keyTable, NULL, key, keyLen);
|
||||||
ILibSimpleDataStore_SHA384(value, valueLen, hash); // Hash the value
|
ILibSimpleDataStore_SHA384(value, valueLen, hash); // Hash the value
|
||||||
@@ -878,3 +884,8 @@ __EXPORT_TYPE int ILibSimpleDataStore_Compact(ILibSimpleDataStore dataStore)
|
|||||||
free(tmp); // Free the temporary file name
|
free(tmp); // Free the temporary file name
|
||||||
return retVal; // Return 1 if we got an error, 0 if everything finished correctly
|
return retVal; // Return 1 if we got an error, 0 if everything finished correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ILibSimpleDataStore_IsCacheOnly(ILibSimpleDataStore ds)
|
||||||
|
{
|
||||||
|
return(((ILibSimpleDataStore_Root*)ds)->dataFile == NULL ? 1 : 0);
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ __EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath,
|
|||||||
#define ILibSimpleDataStore_Create(filePath) ILibSimpleDataStore_CreateEx2(filePath, 0, 0)
|
#define ILibSimpleDataStore_Create(filePath) ILibSimpleDataStore_CreateEx2(filePath, 0, 0)
|
||||||
#define ILibSimpleDataStore_CreateEx(filePath, userExtraMemorySize) ILibSimpleDataStore_CreateEx2(filePath, userExtraMemorySize, 0)
|
#define ILibSimpleDataStore_CreateEx(filePath, userExtraMemorySize) ILibSimpleDataStore_CreateEx2(filePath, userExtraMemorySize, 0)
|
||||||
#define ILibSimpleDataStore_CreateCachedOnly() ILibSimpleDataStore_Create(NULL)
|
#define ILibSimpleDataStore_CreateCachedOnly() ILibSimpleDataStore_Create(NULL)
|
||||||
|
int ILibSimpleDataStore_IsCacheOnly(ILibSimpleDataStore ds);
|
||||||
|
|
||||||
// Check if the data store exists
|
// Check if the data store exists
|
||||||
int ILibSimpleDataStore_Exists(char *filePath);
|
int ILibSimpleDataStore_Exists(char *filePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user