mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 15:53:55 +00:00
Updated, so if database is locked, and installer is being run, db will open in cache only mode
This commit is contained in:
@@ -3958,11 +3958,6 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
{
|
{
|
||||||
int len = (int)strnlen_s(param[ri], 4096);
|
int len = (int)strnlen_s(param[ri], 4096);
|
||||||
int ix;
|
int ix;
|
||||||
if ((ix=ILibString_IndexOf(param[ri], len, "=", 1)) > 2 && strncmp(param[ri], "--", 2)==0)
|
|
||||||
{
|
|
||||||
if (agentHost->masterDb != NULL) { ILibSimpleDataStore_Cached(agentHost->masterDb, param[ri] + 2, ix - 2, param[ri] + ix + 1, len - (ix + 1)); }
|
|
||||||
++ixr;
|
|
||||||
}
|
|
||||||
if (strcmp("-finstall", param[ri]) == 0 || strcmp("-fullinstall", param[ri]) == 0)
|
if (strcmp("-finstall", param[ri]) == 0 || strcmp("-fullinstall", param[ri]) == 0)
|
||||||
{
|
{
|
||||||
installFlag = 1;
|
installFlag = 1;
|
||||||
@@ -3988,6 +3983,13 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
{
|
{
|
||||||
installFlag = 2;
|
installFlag = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (agentHost->masterDb == NULL && installFlag != 0) { agentHost->masterDb = ILibSimpleDataStore_CreateCachedOnly(); }
|
||||||
|
if ((ix = ILibString_IndexOf(param[ri], len, "=", 1)) > 2 && strncmp(param[ri], "--", 2) == 0)
|
||||||
|
{
|
||||||
|
if (agentHost->masterDb != NULL) { ILibSimpleDataStore_Cached(agentHost->masterDb, param[ri] + 2, ix - 2, param[ri] + ix + 1, len - (ix + 1)); }
|
||||||
|
++ixr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paramLen -= ixr;
|
paramLen -= ixr;
|
||||||
if (installFlag != 0)
|
if (installFlag != 0)
|
||||||
|
|||||||
@@ -557,18 +557,21 @@ __EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath,
|
|||||||
{
|
{
|
||||||
ILibSimpleDataStore_Root* retVal = (ILibSimpleDataStore_Root*)ILibMemory_Allocate(ILibMemory_SimpleDataStore_CONTAINERSIZE, userExtraMemorySize, NULL, NULL);
|
ILibSimpleDataStore_Root* retVal = (ILibSimpleDataStore_Root*)ILibMemory_Allocate(ILibMemory_SimpleDataStore_CONTAINERSIZE, userExtraMemorySize, NULL, NULL);
|
||||||
|
|
||||||
retVal->filePath = ILibString_Copy(filePath, (int)strnlen_s(filePath, ILibSimpleDataStore_MaxFilePath));
|
if (filePath != NULL)
|
||||||
retVal->dataFile = ILibSimpleDataStore_OpenFileEx2(retVal->filePath, 0, readonly);
|
|
||||||
|
|
||||||
if (retVal->dataFile == NULL)
|
|
||||||
{
|
{
|
||||||
free(retVal->filePath);
|
retVal->filePath = ILibString_Copy(filePath, (int)strnlen_s(filePath, ILibSimpleDataStore_MaxFilePath));
|
||||||
free(retVal);
|
retVal->dataFile = ILibSimpleDataStore_OpenFileEx2(retVal->filePath, 0, readonly);
|
||||||
return NULL;
|
|
||||||
|
if (retVal->dataFile == NULL)
|
||||||
|
{
|
||||||
|
free(retVal->filePath);
|
||||||
|
free(retVal);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal->keyTable = ILibHashtable_Create();
|
retVal->keyTable = ILibHashtable_Create();
|
||||||
ILibSimpleDataStore_RebuildKeyTable(retVal);
|
if (retVal->dataFile != NULL) { ILibSimpleDataStore_RebuildKeyTable(retVal); }
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,13 +595,15 @@ __EXPORT_TYPE void ILibSimpleDataStore_Close(ILibSimpleDataStore dataStore)
|
|||||||
ILibHashtable_DestroyEx(root->keyTable, ILibSimpleDataStore_TableClear_Sink, root);
|
ILibHashtable_DestroyEx(root->keyTable, ILibSimpleDataStore_TableClear_Sink, root);
|
||||||
if (root->cacheTable != NULL) { ILibHashtable_DestroyEx(root->cacheTable, ILibSimpleDataStore_CacheClear_Sink, NULL); }
|
if (root->cacheTable != NULL) { ILibHashtable_DestroyEx(root->cacheTable, ILibSimpleDataStore_CacheClear_Sink, NULL); }
|
||||||
|
|
||||||
free(root->filePath);
|
if (root->filePath != NULL)
|
||||||
|
{
|
||||||
|
free(root->filePath);
|
||||||
#ifdef _POSIX
|
#ifdef _POSIX
|
||||||
flock(fileno(root->dataFile), LOCK_UN);
|
flock(fileno(root->dataFile), LOCK_UN);
|
||||||
#endif
|
#endif
|
||||||
|
fclose(root->dataFile);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(root->dataFile);
|
|
||||||
free(root);
|
free(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ typedef void(*ILibSimpleDataStore_SizeWarningHandler)(ILibSimpleDataStore sender
|
|||||||
__EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath, int userExtraMemorySize, int readonly);
|
__EXPORT_TYPE ILibSimpleDataStore ILibSimpleDataStore_CreateEx2(char* filePath, int userExtraMemorySize, int readonly);
|
||||||
#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)
|
||||||
|
|
||||||
// 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