diff options
author | Ingo Huerner <ingo.huerner@xse.de> | 2014-05-06 11:24:28 +0200 |
---|---|---|
committer | Ingo Huerner <ingo.huerner@xse.de> | 2014-05-06 11:24:28 +0200 |
commit | 5d04ae9d019b1072612e935eb13e198834a23b0f (patch) | |
tree | 17101e888b1aba5d643558a96b7a237e7c7a1884 /src | |
parent | 2cb97c5860b58b12bac1789ebb0f93513f91fade (diff) | |
download | persistence-client-library-5d04ae9d019b1072612e935eb13e198834a23b0f.tar.gz |
Fixed a problem with default file data
Diffstat (limited to 'src')
-rw-r--r-- | src/persistence_client_library.c | 8 | ||||
-rw-r--r-- | src/persistence_client_library_backup_filelist.c | 9 | ||||
-rw-r--r-- | src/persistence_client_library_file.c | 18 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 42a1c5c..c439976 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -66,18 +66,14 @@ int pclInitLibrary(const char* appName, int shutdownMode) const char *pBlacklistPath = getenv("PERS_BLACKLIST_PATH"); #if USE_FILECACHE - printf("* * * * * * Using the filecache! * * * * * * * * *\n"); - + DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Using the filecache!!!")); pfcInitCache(appName); -#else - printf("* * * * * * N O T using the filecache! * * * * * *\n"); #endif + #if USE_PASINTERFACE == 1 - //printf("* ADMIN INTERFACE is - e n a b l e d - \n"); DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("PAS interface is enabled!!")); #else - //printf("* ADMIN INTERFACE is - d i s a b l e d - enable with \"./configure --enable-pasinterface\"\n"); DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("PAS interface is not enabled, enable with \"./configure --enable-pasinterface\"")); #endif diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c index 8c98898..9f6e768 100644 --- a/src/persistence_client_library_backup_filelist.c +++ b/src/persistence_client_library_backup_filelist.c @@ -24,6 +24,11 @@ #include "persistence_client_library_data_organization.h" +#if USE_FILECACHE + #include <persistence_file_cache.h> +#endif + + #include <sys/mman.h> #include <sys/stat.h> #include <errno.h> @@ -369,7 +374,11 @@ int pclCreateFile(const char* path) // finally create the file strncat(createPath, "/", DbPathMaxLen-1); strncat(createPath, tokenArray[i], DbPathMaxLen-1); +#if USE_FILECACHE + handle = pfcOpenFile(createPath, CreateFile); +#else handle = open(createPath, O_CREAT|O_RDWR |O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); +#endif } else { diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index ab8f7b2..d1ab60b 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -207,7 +207,7 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n close(handle); } - handle = pfcOpenFile(dbPath); + handle = pfcOpenFile(dbPath, DontCreateFile); #else if(handle <= 0) // check if open is needed or already done in verifyConsistency { @@ -224,10 +224,9 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n } else { - if(pclFileGetDefaultData(handle, resource_id, dbContext.configKey.policy) == -1) // try to get default data { - printf("pclFileOpen => No default data!!\n"); + DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclFileOpen: no default data available: "), DLT_STRING(resource_id)); } } } @@ -530,7 +529,7 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int { if(pclFileGetDefaultData(handle, resource_id, dbContext.configKey.policy) == -1) // try to get default data { - printf("pclFileCreatePath => No default data!!\n"); + DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclFileCreatePath => no default data available: "), DLT_STRING(resource_id)); } } close(handle); // don't need the open file @@ -647,7 +646,16 @@ int pclFileGetDefaultData(int handle, const char* resource_id, int policy) memset(&buf, 0, sizeof(buf)); fstat(defaultHandle, &buf); - sendfile(handle, defaultHandle, 0, buf.st_size); + rval = sendfile(handle, defaultHandle, 0, buf.st_size); + if(rval != -1) + { + rval = lseek(handle, 0, SEEK_SET); // set fd back to beginning of the file + } + else + { + DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclFileGetDefaultData => failed to copy file "), DLT_STRING(strerror(errno))); + } + close(defaultHandle); } else |