diff options
author | Ingo Huerner <ingo_huerner@mentor.com> | 2017-02-16 13:10:55 +0100 |
---|---|---|
committer | Ingo Huerner <ingo_huerner@mentor.com> | 2017-02-16 13:10:55 +0100 |
commit | 3a5cfb462ae05793b748532daf585d12f3390ad5 (patch) | |
tree | 3a1c62f4e07ce5d2277e823314b76e1f475af406 /src/persistence_client_library_file.c | |
parent | 5f1f922696076a3f9e5a894a1c4bbc29dafa30e6 (diff) | |
download | persistence-client-library-3a5cfb462ae05793b748532daf585d12f3390ad5.tar.gz |
Replaced file handle array by simple linked list
Diffstat (limited to 'src/persistence_client_library_file.c')
-rw-r--r-- | src/persistence_client_library_file.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index 8c77a4b..d73e066 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -121,8 +121,6 @@ int pclFileClose(int fd) DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclFileClose - csum remove failed!"), DLT_STRING(strerror(errno)) ); } } - if(fd < MaxPersHandle) - __sync_fetch_and_sub(&gOpenFdArray[fd], FileClosed); // set closed flag // remove form file tree; if(remove_file_handle_data(fd) != 1) @@ -144,6 +142,7 @@ int pclFileClose(int fd) fsync(fd); rval = close(fd); #endif + list_item_remove(&gOpenFdList, fd); } else { @@ -392,7 +391,7 @@ int pclFileOpenRegular(PersistenceInfo_s* dbContext, const char* resource_id, ch if(set_file_handle_data(handle, dbContext->configKey.permission, backupPath, csumPath, NULL) != -1) { set_file_backup_status(handle, wantBackup); - __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag + list_item_insert(&gOpenFdList, handle); } else { @@ -430,7 +429,7 @@ int pclFileOpenRegular(PersistenceInfo_s* dbContext, const char* resource_id, ch if(set_file_handle_data(handle, PersistencePermission_ReadWrite, backupPath, csumPath, NULL) != -1) { set_file_backup_status(handle, 1); - __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag + list_item_insert(&gOpenFdList, handle); } else { @@ -942,9 +941,9 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int close(handle); // don't need the open file } } - __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag - set_ossfile_handle_data(handle, dbContext.configKey.permission, 0/*backupCreated*/, backupPath, csumPath, *path); + + list_item_insert(&gCPOpenFdList, handle); // remember open fd } else { @@ -973,7 +972,7 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int snprintf(backupPath, PERS_ORG_MAX_LENGTH_PATH_FILENAME, "%s%s", dbPath, gBackupPostfix); snprintf(csumPath, PERS_ORG_MAX_LENGTH_PATH_FILENAME, "%s%s", dbPath, gBackupCsPostfix); - __sync_fetch_and_add(&gOpenHandleArray[handle], FileOpen); // set open flag + list_item_insert(&gCPOpenFdList, handle); // remember open fd set_ossfile_handle_data(handle, PersistencePermission_ReadWrite, 0/*backupCreated*/, backupPath, csumPath, NULL); } @@ -1037,12 +1036,12 @@ int pclFileReleasePath(int pathHandle) } free(get_ossfile_file_path(pathHandle)); - __sync_fetch_and_sub(&gOpenHandleArray[pathHandle], FileClosed); // set closed flag - set_persistence_handle_close_idx(pathHandle); set_ossfile_file_path(pathHandle, NULL); + list_item_remove(&gCPOpenFdList, pathHandle); // remove open fd form list + if(remove_ossfile_handle_data(pathHandle) != 1) { DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclFileReleasePath - Failed to remove from tree!"), DLT_INT(pathHandle) ); |