From d4955ce50d9e3742103e21d9377b3567399aa9ef Mon Sep 17 00:00:00 2001 From: Ingo Huerner Date: Fri, 3 May 2013 09:15:10 +0200 Subject: Added dlt messages; removed setting of comipler flags in configure.ac --- configure.ac | 2 +- .../persistence_client_library_data_organization.h | 5 + src/persistence_client_library.c | 30 +++-- src/persistence_client_library_backup_filelist.c | 10 +- src/persistence_client_library_custom_loader.c | 42 ++++--- src/persistence_client_library_data_organization.c | 2 + src/persistence_client_library_db_access.c | 96 ++++++++++----- src/persistence_client_library_dbus_service.c | 87 +++++++------- src/persistence_client_library_file.c | 64 +++++++--- src/persistence_client_library_handle.c | 2 +- src/persistence_client_library_key.c | 36 ++++++ src/persistence_client_library_lc_interface.c | 132 +++++++++++---------- src/persistence_client_library_pas_interface.c | 57 ++++----- src/persistence_client_library_prct_access.c | 5 +- test/persistence_client_library_test.c | 3 + 15 files changed, 343 insertions(+), 230 deletions(-) diff --git a/configure.ac b/configure.ac index b1dbcf8..a93eeb3 100644 --- a/configure.ac +++ b/configure.ac @@ -29,7 +29,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Overwrite the build in defaults -CFLAGS="-Wall -O2" +#CFLAGS="-Wall -O2" # Checks for programs. AC_PROG_CC diff --git a/include_protected/persistence_client_library_data_organization.h b/include_protected/persistence_client_library_data_organization.h index c3e305a..4bec5bf 100644 --- a/include_protected/persistence_client_library_data_organization.h +++ b/include_protected/persistence_client_library_data_organization.h @@ -29,6 +29,8 @@ extern "C" { #include "../include/persistence_client_library_error_def.h" #include "../include/persistence_client_library_key.h" +#include +#include #include #include @@ -139,6 +141,9 @@ extern char gAppId[MaxAppNameLen]; /// max key value data size extern int gMaxKeyValDataSize; +// the DLT context +extern DltContext gDLTContext; + /** * @brief definition of change callback function diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 2fbae64..eb4a9c2 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -34,13 +34,12 @@ #include - #define ENABLE_DBUS_INTERFACE 1 extern char* __progname; /// debug log and trace (DLT) setup -DLT_DECLARE_CONTEXT(persClientLibCtx); +DLT_DECLARE_CONTEXT(gDLTContext); /** * @brief itialize client library @@ -48,7 +47,7 @@ DLT_DECLARE_CONTEXT(persClientLibCtx); * @param shutdown mode NSM_SHUTDOWN_TYPE_FAST or NSM_SHUTDOWN_TYPE_NORMAL * */ -void pclInit(int shutdownMode); +void pclInit(const char* appname, int shutdownMode); @@ -64,7 +63,12 @@ void pclDeinit(int shutdownMode); void pclLibraryConstructor(void) { int shutdownReg = NSM_SHUTDOWN_TYPE_FAST | NSM_SHUTDOWN_TYPE_NORMAL; - pclInit(shutdownReg); + + DLT_REGISTER_APP("test","tests the persistence client library"); + /// debug log and trace (DLT) setup + + printf("A p p l i c a t i o n n a m e => %s \n", __progname /*program_invocation_short_name*/); + pclInit(__progname, shutdownReg); } @@ -76,15 +80,13 @@ void pclLibraryDestructor(void) -void pclInit(int shutdownMode) +void pclInit(const char* appName, int shutdownMode) { int status = 0; int i = 0; - DLT_REGISTER_APP("Persistence Client Library","persClientLib"); - DLT_REGISTER_CONTEXT(persClientLibCtx,"persClientLib","Context for Logging"); - - DLT_LOG(persClientLibCtx, DLT_LOG_ERROR, DLT_STRING("Initialize Persistence Client Library!!!!")); + DLT_REGISTER_CONTEXT(gDLTContext,"pers","Context for persistence client library logging"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("Initialize Persistence Client Library!!!!")); /// environment variable for on demand loading of custom libraries const char *pOnDemandLoad = getenv("PERS_CUSTOM_LIB_LOAD_ON_DEMAND"); @@ -149,10 +151,12 @@ void pclInit(int shutdownMode) } } - printf("A p p l i c a t i o n n a m e => %s \n", __progname /*program_invocation_short_name*/); // TODO: only temp solution for application name - strncpy(gAppId, __progname, MaxAppNameLen); + // assign application name + strncpy(gAppId, appName, MaxAppNameLen); gAppId[MaxAppNameLen-1] = '\0'; + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclInit -> initialized client library:"), DLT_STRING(gAppId) ); + // destory mutex pthread_mutex_destroy(&gDbusInitializedMtx); pthread_cond_destroy(&gDbusInitializedCond); @@ -169,7 +173,9 @@ void pclDeinit(int shutdownMode) unregister_pers_admin_service(); #endif - DLT_UNREGISTER_CONTEXT(persClientLibCtx); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclDeinit -> deinit client library:"), DLT_STRING(gAppId)); + + DLT_UNREGISTER_CONTEXT(gDLTContext); DLT_UNREGISTER_APP(); dlt_free(); } diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c index eae4425..a193fb2 100644 --- a/src/persistence_client_library_backup_filelist.c +++ b/src/persistence_client_library_backup_filelist.c @@ -19,6 +19,7 @@ #include "persistence_client_library_backup_filelist.h" #include "rbtree.h" #include "../include_protected/crc32.h" +#include "../include_protected/persistence_client_library_data_organization.h" #include @@ -166,15 +167,17 @@ int readBlacklistConfigFile(const char* filename) if (fd == -1) { printf("configReader::readConfigFile ==> Error file open: %s | error: %s \n", filename, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file open"), DLT_STRING(filename), DLT_STRING(strerror(errno)) ); return -1; } - // check for empty file if(gConfigFileSize == 0) { - printf("configReader::readConfigFile ==> Error file size is 0: %s | buffer.st_size: %d \n", filename, (int)buffer.st_size); + printf("configReader::readConfigFile ==> Error file size is 0: %s \n", filename); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file size is 0:"), DLT_STRING(filename)); + close(fd); return -1; } @@ -187,6 +190,8 @@ int readBlacklistConfigFile(const char* filename) gpConfigFileMap = 0; close(fd); printf("configReader::readConfigFile ==> Error mapping the file: %s | error: %s \n", filename, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error mapping the file:"), DLT_STRING(filename), DLT_STRING(strerror(errno)) ); + return -1; } @@ -237,6 +242,7 @@ int need_backup_key(unsigned int key) rval = -1; printf("need_backup_key ==> item or gRb_tree_bl is NULL\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("need_backup_key ==> item or gRb_tree_bl is NULL")); } return rval; diff --git a/src/persistence_client_library_custom_loader.c b/src/persistence_client_library_custom_loader.c index d1f8a8d..6d1dce6 100644 --- a/src/persistence_client_library_custom_loader.c +++ b/src/persistence_client_library_custom_loader.c @@ -74,7 +74,7 @@ PersistenceCustomLibs_e custom_client_name_to_id(const char* lib_name, int subst } else { - printf("custom_libname_to_id - error - id not found for lib: %s \n", lib_name); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("custom_libname_to_id - error - id not found for lib:"), DLT_STRING(lib_name)); } } else @@ -217,20 +217,20 @@ int get_custom_libraries() else { rval = EPERS_CONFIGMAPFAILED; - printf("load config file error - mapping of file failed"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load config file error - mapping of file failed")); } close(fd); } else { rval = EPERS_CONFIGNOTAVAILABLE; - printf("load config file error - no file with plugins available -> filename: %s | error: %s \n", filename, strerror(errno) ); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load config file error - no file with plugins available:"), DLT_STRING(filename), DLT_STRING(strerror(errno))); } } else { rval = EPERS_CONFIGNOSTAT; - printf("load config file error - can't stat config file: %s | %s \n", filename, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("lload config file error - can't stat config file:"), DLT_STRING(filename), DLT_STRING(strerror(errno))); } return rval; } @@ -254,99 +254,97 @@ int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s *(void **) (&customFuncts->custom_plugin_handle_close) = dlsym(handle, "plugin_handle_close"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_delete_data *(void **) (&customFuncts->custom_plugin_delete_data) = dlsym(handle, "plugin_delete_data"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_get_data *(void **) (&customFuncts->custom_plugin_handle_get_data) = dlsym(handle, "plugin_handle_get_data"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); - + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_get_data *(void **) (&customFuncts->custom_plugin_get_data) = dlsym(handle, "plugin_get_data"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_init *(void **) (&customFuncts->custom_plugin_init) = dlsym(handle, "plugin_init"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); - + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_deinit *(void **) (&customFuncts->custom_plugin_deinit) = dlsym(handle, "plugin_deinit"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_open *(void **) (&customFuncts->custom_plugin_handle_open) = dlsym(handle, "plugin_handle_open"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_set_data *(void **) (&customFuncts->custom_plugin_handle_set_data) = dlsym(handle, "plugin_handle_set_data"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_set_data *(void **) (&customFuncts->custom_plugin_set_data) = dlsym(handle, "plugin_set_data"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_get_size_handle *(void **) (&customFuncts->custom_plugin_handle_get_size) = dlsym(handle, "plugin_handle_get_size"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_get_size *(void **) (&customFuncts->custom_plugin_get_size) = dlsym(handle, "plugin_get_size"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // create backup *(void **) (&customFuncts->custom_plugin_create_backup) = dlsym(handle, "plugin_create_backup"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // restore backup *(void **) (&customFuncts->custom_plugin_restore_backup) = dlsym(handle, "plugin_restore_backup"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // restore backup *(void **) (&customFuncts->custom_plugin_get_backup) = dlsym(handle, "plugin_get_backup"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } // custom_plugin_get_status_notification_clbk *(void **) (&customFuncts->custom_plugin_get_status_notification_clbk) = dlsym(handle, "plugin_get_status_notification_clbk"); if ((error = dlerror()) != NULL) { - printf("load_custom_library - error: %s\n", error); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); } } else { - printf("load_custom_library - error: %s\n", dlerror()); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("load_custom_library - error:"), DLT_STRING(error)); rval = EPERS_DLOPENERROR; } } diff --git a/src/persistence_client_library_data_organization.c b/src/persistence_client_library_data_organization.c index be18687..c2dcde1 100644 --- a/src/persistence_client_library_data_organization.c +++ b/src/persistence_client_library_data_organization.c @@ -80,6 +80,8 @@ char gAppId[MaxAppNameLen]; int gMaxKeyValDataSize = defaultMaxKeyValDataSize; +DltContext gDLTContext; + int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct); diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c index 4185a7c..4939cc7 100644 --- a/src/persistence_client_library_db_access.c +++ b/src/persistence_client_library_db_access.c @@ -91,7 +91,8 @@ itzam_btree* pers_db_open(PersistenceInfo_s* info, const char* dbPath) itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_open ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_open ==> itzam_btree_open => Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_open ==> itzam_btree_open => Itzam problem"), DLT_STRING(STATE_MESSAGES[state])); } gBtreeCreated[arrayIdx][info->configKey.policy] = 1; } @@ -100,7 +101,8 @@ itzam_btree* pers_db_open(PersistenceInfo_s* info, const char* dbPath) } else { - printf("btree_get ==> invalid storage type\n"); + printf("pers_db_open ==> invalid storage type\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_open ==> invalid storage type"), DLT_STRING(dbPath)); } return btree; } @@ -117,13 +119,15 @@ void pers_db_close(PersistenceInfo_s* info) state = itzam_btree_close(&gBtree[arrayIdx][info->configKey.policy]); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_close ==> Close Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_close ==> Close Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_close ==> itzam_btree_close => Itzam problem"), DLT_STRING(STATE_MESSAGES[state])); } gBtreeCreated[arrayIdx][info->configKey.policy] = 0; } else { printf("pers_db_close ==> invalid storage type\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_close ==> invalid storage type"), DLT_INT(info->context.ldbid )); } } @@ -142,7 +146,8 @@ void pers_db_close_all() state = itzam_btree_close(&gBtree[i][PersistencePolicy_wc]); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_close_all ==> Close WC: Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_close_all ==> itzam_btree_close => Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_close_all ==> itzam_btree_close => Itzam problem:"), DLT_STRING(STATE_MESSAGES[state]) ); } gBtreeCreated[i][PersistencePolicy_wc] = 0; } @@ -154,7 +159,8 @@ void pers_db_close_all() state = itzam_btree_close(&gBtree[i][PersistencePolicy_wt]); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_close_all ==> Close WT: Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_close_all ==> itzam_btree_close => Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_close_all ==>itzam_btree_close => Itzam problem:"), DLT_STRING(STATE_MESSAGES[state])); } gBtreeCreated[i][PersistencePolicy_wt] = 0; } @@ -193,8 +199,9 @@ int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned } else { + printf("pers_db_read_key ==> no resource config table %s | %s \n", dbPath, key); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==>no resource config table"), DLT_STRING(dbPath), DLT_STRING(key) ); read_size = EPERS_NOPRCTABLE; - fprintf(stderr, "\npersistence_get_data ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); } } else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library @@ -266,7 +273,8 @@ int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned state = itzam_btree_insert(btree,(const void *)&insert); if (state != ITZAM_OKAY) { - fprintf(stderr, "\npersistence_set_data ==> Insert Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_write_key ==> itzam_btree_insert => Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> itzam_btree_insert => Itzam problem"), DLT_STRING(STATE_MESSAGES[state]) ); write_size = EPERS_DB_ERROR_INTERNAL; } @@ -282,20 +290,23 @@ int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned } else { - fprintf(stderr, "\npersistence_set_data ==> set_value_to_table_itzam => data to long » size %d | maxSize: %d\n", dataSize, DbKeySize); + printf("pers_db_write_key ==> data to long » size %d | maxSize: %d\n", dataSize, DbValueSize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> data to long » size:"), DLT_INT(dataSize), DLT_INT(DbValueSize) ); write_size = EPERS_DB_VALUE_SIZE; } } else { - fprintf(stderr, "\nset_value_to_table_itzam => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + printf("pers_db_write_key => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> key to long » size"), DLT_INT(keySize), DLT_INT(DbKeySize) ); write_size = EPERS_DB_KEY_SIZE; } } else { + printf("pers_db_write_key ==> no resource config table: %s | %s\n", dbPath, key); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_write_key ==> no resource config table"), DLT_STRING(dbPath), DLT_STRING(key)); write_size = EPERS_NOPRCTABLE; - fprintf(stderr, "\npersistence_set_data ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); } } else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library @@ -349,14 +360,16 @@ int pers_db_get_key_size(char* dbPath, char* key, PersistenceInfo_s* info) } else { - fprintf(stderr, "persistence_get_data_size => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + printf("pers_db_get_key_size => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_get_key_size ==> key to long"), DLT_INT(keySize), DLT_INT(DbKeySize)); read_size = EPERS_DB_KEY_SIZE; } } else { + printf("pers_db_get_key_size ==> no resource config table: %s | %s\n", dbPath, key); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_get_key_size ==> no config table"), DLT_STRING(dbPath), DLT_STRING(key)); read_size = EPERS_NOPRCTABLE; - fprintf(stderr, "\npersistence_get_data_size ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); } } else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library @@ -406,7 +419,8 @@ int pers_db_delete_key(char* dbPath, char* dbKey, PersistenceInfo_s* info) state = itzam_btree_remove(btree, (const void *)&delete); if (state != ITZAM_OKAY) { - fprintf(stderr, "persistence_delete_data ==> Remove Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_delete_key ==> itzam_btree_remove => Itzam problem: %s \n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_delete_key ==> itzam_btree_remove => Itzam problem"), DLT_STRING(STATE_MESSAGES[state])); ret = EPERS_DB_ERROR_INTERNAL; } itzam_btree_transaction_commit(btree); @@ -420,13 +434,15 @@ int pers_db_delete_key(char* dbPath, char* dbKey, PersistenceInfo_s* info) } else { - fprintf(stderr, "persistence_delete_data => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + printf("pers_db_delete_key => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_delete_key ==> key to long"), DLT_INT(keySize), DLT_INT(DbKeySize)); ret = EPERS_DB_KEY_SIZE; } } else { - fprintf(stderr, "persistence_delete_data => no prct table\n"); + printf("pers_db_delete_key ==> no resource config table: %s | %s\n", dbPath, dbKey); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_delete_key ==> no resource config table"), DLT_STRING(dbPath), DLT_STRING(dbKey)); ret = EPERS_NOPRCTABLE; } } @@ -499,6 +515,8 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte char* createSignal = "PersistenceResCreate"; char* theReason = NULL; + DBusConnection* conn = get_dbus_connection(); + memset(ldbid_array, 0, DbusSubMatchSize); memset(user_array, 0, DbusSubMatchSize); memset(seat_array, 0, DbusSubMatchSize); @@ -542,19 +560,28 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte if(ret == TRUE) { // Send the signal - if(dbus_connection_send(get_dbus_connection(), message, NULL) == TRUE) + if(conn != NULL) { - // Free the signal now we have finished with it - dbus_message_unref(message); + if(dbus_connection_send(conn, message, 0) == TRUE) + { + // Free the signal now we have finished with it + dbus_message_unref(message); + } + else + { + rval = EPERS_NOTIFY_SIG; + } } else { - rval = EPERS_NOTIFY_SIG; + printf("pers_send_Notification_Signal ==> E R R O R C O N E C T I O N NULL!!\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_send_Notification_Signal ==> E R R O R C O N E C T I O N NULL!!")); } } else { - printf("pers_send_Notification_Signal: \n"); + printf("pers_send_Notification_Signal: ERROR \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_send_Notification_Signal ==> ERROR dbus_message_append_args")); rval = EPERS_NOTIFY_SIG; } } @@ -589,8 +616,9 @@ int get_cursor_handle() } else { + printf("get_cursor_handle => Reached maximum of open handles: %d \n", MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_cursor_handle ==> Reached maximum of open handles:"), DLT_INT(MaxPersHandle)); handle = -1; - printf("get_persistence_handle_idx => Reached maximum of open handles: %d \n", MaxPersHandle); } } pthread_mutex_unlock(&gMtx); @@ -626,7 +654,8 @@ int pers_db_cursor_create(char* dbPath) state = itzam_btree_open(&gCursorArray[handle].m_btree, dbPath, itzam_comparator_string, error_handler, 1/*recover*/, 0/*read_only*/); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_open ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_cursor_create ==> itzam_btree_open: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_create ==> itzam_btree_open"), DLT_STRING(STATE_MESSAGES[state])); } else { @@ -670,12 +699,14 @@ int pers_db_cursor_next(unsigned int handlerDB) } else { - printf("persistence_db_cursor_get_key ==> invalid handle: %u \n", handlerDB); + printf("pers_db_cursor_next ==> invalid handle: %u \n", handlerDB); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_next ==> invalid handle: "), DLT_INT(handlerDB)); } } else { - printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, MaxPersHandle); + printf("pers_db_cursor_next ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_next ==> handle bigger than max:"), DLT_INT(MaxPersHandle)); } return rval; } @@ -701,17 +732,20 @@ int pers_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bu } else { - printf("persistence_db_cursor_get_key ==> buffer to small » keySize: %d | bufSize: %d \n", length, bufSize); + printf("pers_db_cursor_get_key ==> buffer to small » keySize: %d | bufSize: %d \n", length, bufSize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_get_key ==> buffer to small » keySize: "), DLT_INT(bufSize)); } } else { printf("persistence_db_cursor_get_key ==> invalid handle: %u \n", handlerDB); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_db_cursor_get_key ==> invalid handle:"), DLT_INT(handlerDB)); } } else { printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_db_cursor_get_key ==> handle bigger than max:"), DLT_INT(MaxPersHandle)); } return rval; } @@ -738,17 +772,20 @@ int pers_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, int bufS } else { - printf("persistence_db_cursor_get_data ==> buffer to small » keySize: %d | bufSize: %d \n", length, bufSize); + printf("pers_db_cursor_get_data ==> buffer to small » keySize: %d | bufSize: %d \n", length, bufSize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_get_data ==> buffer to small » keySize: "), DLT_INT(bufSize)); } } else { printf("persistence_db_cursor_get_data ==> invalid handle: %u \n", handlerDB); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_db_cursor_get_data ==> invalid handle:"), DLT_INT(handlerDB)); } } else { printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_db_cursor_get_data ==> handle bigger than max:"), DLT_INT(MaxPersHandle)); } return rval; } @@ -769,12 +806,14 @@ int pers_db_cursor_get_data_size(unsigned int handlerDB) } else { - printf("persistence_db_cursor_get_data ==> invalid handle: %u \n", handlerDB); + printf("pers_db_cursor_get_data_size ==> invalid handle: %u \n", handlerDB); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_get_data_size ==> invalid handle:"), DLT_INT(handlerDB)); } } else { printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("persistence_db_cursor_get_data ==> handle bigger than max:"), DLT_INT(MaxPersHandle)); } return size; } @@ -793,7 +832,8 @@ int pers_db_cursor_destroy(unsigned int handlerDB) state = itzam_btree_close(&gCursorArray[handlerDB].m_btree); if (state != ITZAM_OKAY) { - fprintf(stderr, "pers_db_cursor_destroy ==> Close: Itzam problem: %s\n", STATE_MESSAGES[state]); + printf("pers_db_cursor_destroy ==> itzam_btree_close: Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_cursor_destroy ==> itzam_btree_close: Itzam problem"), DLT_STRING(STATE_MESSAGES[state])); } close_cursor_handle(handlerDB); diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c index 05804d7..a6485d7 100644 --- a/src/persistence_client_library_dbus_service.c +++ b/src/persistence_client_library_dbus_service.c @@ -101,32 +101,25 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec { DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED; - printf("handleObjectPathMessageFallback Object: '%s' -> Interface: '%s' -> Message: '%s'\n", - dbus_message_get_sender(message), dbus_message_get_interface(message), dbus_message_get_member(message) ); - // org.genivi.persistence.admin S I G N A L if((0==strcmp("org.genivi.persistence.admin", dbus_message_get_interface(message)))) { - printf("checkPersAdminSignalInterface '%s' -> '%s'\n", dbus_message_get_interface(message), dbus_message_get_member(message)); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) { - printf(" checkPersAdminSignal signal\n"); if((0==strcmp("PersistenceModeChanged", dbus_message_get_member(message)))) { - printf(" checkPersAdminSignal message\n"); // to do handle signal result = signal_persModeChange(connection, message); } else { - printf("handleObjectPathMessageFallback -> unknown signal '%s'\n", dbus_message_get_interface(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback -> unknown signal:"), DLT_STRING(dbus_message_get_interface(message)) ); } } } // org.genivi.persistence.admin S I G N A L else if((0==strcmp("org.genivi.persistence.adminconsumer", dbus_message_get_interface(message)))) { - printf("checkPersAdminconsumerSignalInterface '%s' -> '%s'\n", dbus_message_get_interface(message), dbus_message_get_member(message)); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) { pclNotification_s notifyStruct; @@ -167,14 +160,12 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec if (reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback => DBus No memory"), DLT_STRING(dbus_message_get_interface(message)) ); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback => DBus No memory"), DLT_STRING(dbus_message_get_interface(message)) ); } result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;; @@ -218,18 +209,17 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec dbus_message_iter_close_container(&dict, &variant); dbus_message_iter_close_container(&array, &dict); - printf("handleObjectPathMessageFallback ==> value: %d \n", value); // to do handle signal result = DBUS_HANDLER_RESULT_HANDLED; } else { - printf("handleObjectPathMessageFallback -> unknown property '%s'\n", dbus_message_get_interface(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback -> unknown property:"), DLT_STRING(dbus_message_get_interface(message)) ); } } else { - printf("handleObjectPathMessageFallback -> not a signal '%s'\n", dbus_message_get_member(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback -> not a signal:"), DLT_STRING(dbus_message_get_member(message)) ); } } @@ -262,8 +252,6 @@ void* run_mainloop(void* dataPtr) // setup the dbus mainLoop(vtablePersAdmin, vtableLifecycle, vtableFallback, dataPtr); - printf("Exit dbus main loop!!!!\n"); - return NULL; } @@ -281,45 +269,43 @@ int setup_dbus_mainloop(void) dbus_error_init(&err); + // wain until dbus main loop has been setup and running + pthread_mutex_lock(&gDbusInitializedMtx); + // Connect to the bus and check for errors if(pAddress != NULL) { - printf("Use specific dbus address: %s\n !", pAddress); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("setup_dbus_mainloop -> Use specific dbus address:"), DLT_STRING(pAddress) ); + gDbusConn = dbus_connection_open(pAddress, &err); if(gDbusConn != NULL) { if(!dbus_bus_register(gDbusConn, &err)) { - printf("dbus_bus_register() Error %s\n", err.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("dbus_bus_register() Error :"), DLT_STRING(err.message) ); dbus_error_free (&err); return -1; } - else - { - printf("Registered connection successfully !\n"); - } } else { - printf("dbus_connection_open() Error %s\n",err.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("dbus_connection_open() Error :"), DLT_STRING(err.message) ); dbus_error_free(&err); } } else { - printf("Use default dbus bus (DBUS_BUS_SYSTEM) !!!!!!\n"); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("Use default dbus bus (DBUS_BUS_SYSTEM)")); + gDbusConn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); } - // wain until dbus main loop has been setup and running - pthread_mutex_lock(&gDbusInitializedMtx); - // create here the dbus connection and pass to main loop rval = pthread_create(&thread, NULL, run_mainloop, gDbusConn); if(rval) { - fprintf(stderr, "Server: - ERROR! pthread_create( run_mainloop ) returned: %d\n", rval); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pthread_create( DBUS run_mainloop ) returned an error:"), DLT_INT(rval) ); } // wait for condition variable @@ -337,8 +323,6 @@ static dbus_bool_t addWatch(DBusWatch *watch, void *data) { dbus_bool_t result = FALSE; - //fprintf(stderr, "addWatch called @%08x flags: %08x enabled: %c\n", (unsigned int)watch, dbus_watch_get_flags(watch), TRUE==dbus_watch_get_enabled(watch)?'x':'-'); - if (ARRAY_SIZE(gPollInfo.fds)>gPollInfo.nfds) { int flags = dbus_watch_get_flags(watch); @@ -410,18 +394,21 @@ static dbus_bool_t addTimeout(DBusTimeout *timeout, void *data) } else { - fprintf(stderr, "timerfd_settime() failed %d '%s'\n", errno, strerror(errno)); + printf("timerfd_settime() failed %d '%s'\n", errno, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => timerfd_settime() failed"), DLT_STRING(strerror(errno)) ); } } else { - fprintf(stderr, "timerfd_create() failed %d '%s'\n", errno, strerror(errno)); + printf("timerfd_create() failed %d '%s'\n", errno, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => timerfd_create() failed"), DLT_STRING(strerror(errno)) ); } } } else { - fprintf(stderr, "cannot create another fd to be poll()'ed\n"); + printf("cannot create another fd to be poll()'ed\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => cannot create another fd to be poll()'ed")); } return ret; @@ -439,7 +426,8 @@ static void removeTimeout(DBusTimeout *timeout, void *data) { if (-1==close(gPollInfo.fds[i].fd)) { - fprintf(stderr, "close() timerfd #%d failed %d '%s'\n", gPollInfo.fds[i].fd, errno, strerror(errno)); + printf("removeTimeout => close() timerfd #%d failed %d '%s'\n", gPollInfo.fds[i].fd, errno, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("removeTimeout => close() timerfd"), DLT_STRING(strerror(errno)) ); } --gPollInfo.nfds; @@ -469,7 +457,8 @@ static void timeoutToggled(DBusTimeout *timeout, void *data) const struct itimerspec its = { .it_value= {interval/1000, interval%1000} }; if (-1!=timerfd_settime(gPollInfo.fds[i].fd, 0, &its, NULL)) { - fprintf(stderr, "timerfd_settime() %d failed %d '%s'\n", interval, errno, strerror(errno)); + printf("timeoutToggled => timerfd_settime() %d failed %d '%s'\n", interval, errno, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("timeoutToggled => timerfd_settime()"), DLT_STRING(strerror(errno)) ); } } } @@ -492,7 +481,8 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, if (dbus_error_is_set(&err)) { - printf("Connection Error (%s)\n", err.message); + printf("mainLoop => Connection Error (%s)\n", err.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => Connection Error:"), DLT_STRING(err.message) ); dbus_error_free(&err); } else if (NULL != conn) @@ -501,7 +491,8 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, //printf("connected as '%s'\n", dbus_bus_get_unique_name(conn)); if (-1 == (gEfds = eventfd(0, 0))) { - printf("eventfd() failed w/ errno %d\n", errno); + printf("mainLoop => eventfd() failed w/ errno %d\n", errno); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => eventfd() failed w/ errno:"), DLT_INT(errno) ); } else { @@ -523,7 +514,8 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, if( (TRUE!=dbus_connection_set_watch_functions(conn, addWatch, removeWatch, watchToggled, NULL, NULL)) || (TRUE!=dbus_connection_set_timeout_functions(conn, addTimeout, removeTimeout, timeoutToggled, NULL, NULL)) ) { - printf("dbus_connection_set_watch_functions() failed\n"); + printf("mainLoop => dbus_connection_set_watch_functions() failed\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => dbus_connection_set_watch_functions() failed")); } else { @@ -539,7 +531,8 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, if (0>ret) { - fprintf(stderr, "poll() failed w/ errno %d\n", errno); + printf("mainLoop => poll() failed w/ errno %d\n", errno); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => poll() failed w/ errno "), DLT_INT(errno) ); } else if (0==ret) { @@ -562,12 +555,16 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, unsigned long long nExpCount = 0; if ((ssize_t)sizeof(nExpCount)!=read(gPollInfo.fds[i].fd, &nExpCount, sizeof(nExpCount))) { - fprintf(stderr, "read failed!?\n"); + printf("mainLoop => read failed!?\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => read failed")); } - fprintf(stderr, "timeout %x #%d!\n", (int)gPollInfo.objects[i].timeout, (int)nExpCount); + printf("mainLoop => timeout %x #%d!\n", (int)gPollInfo.objects[i].timeout, (int)nExpCount); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => timeout")); + if (FALSE==dbus_timeout_handle(gPollInfo.objects[i].timeout)) { - fprintf(stderr, "dbus_timeout_handle() failed!?\n"); + printf("mainLoop => dbus_timeout_handle() failed!?\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => dbus_timeout_handle() failed!?")); } bContinue = TRUE; } @@ -581,7 +578,8 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, while ((-1==(ret=read(gPollInfo.fds[i].fd, buf, 64)))&&(EINTR==errno)); if (0>ret) { - printf("read() failed w/ errno %d | %s\n", errno, strerror(errno)); + printf("mainLoop => read() failed w/ errno %d | %s\n", errno, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => read() failed"), DLT_STRING(strerror(errno)) ); } else if (ret != -1) { @@ -598,6 +596,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, break; default: printf("command %d not handled!\n", buf[0]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => command not handled"), DLT_INT(buf[0]) ); break; } } diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index fad6265..617e817 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -57,6 +57,8 @@ int pclFileClose(int fd) { int rval = -1; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileClose fd: "), DLT_INT(fd)); + if(fd < MaxPersHandle) { // check if a backup and checksum file needs to bel deleted @@ -66,12 +68,14 @@ int pclFileClose(int fd) if(remove(gFileHandleArray[fd].backupPath ) == -1) { printf("pclFileClose ==> failed to remove backup file\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileClose ==> failed to remove backup file"), DLT_STRING(gFileHandleArray[fd].backupPath)); } // remove checksum file if(remove(gFileHandleArray[fd].csumPath) == -1) { printf("pclFileClose ==> failed to remove checksum file\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileClose ==> failed to remove checksum file"), DLT_STRING(gFileHandleArray[fd].csumPath)); } } __sync_fetch_and_sub(&gOpenFdArray[fd], FileClosed); // set closed flag @@ -90,6 +94,8 @@ int pclFileGetSize(int fd) int ret = 0; ret = fstat(fd, &buf); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileGetSize fd: "), DLT_INT(fd)); + if(ret != -1) { rval = buf.st_size; @@ -103,6 +109,8 @@ void* pclFileMapData(void* addr, long size, long offset, int fd) { void* ptr = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileMapData fd: "), DLT_INT(fd)); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { int mapFlag = PROT_WRITE | PROT_READ; @@ -127,6 +135,8 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n char backupPath[DbKeyMaxLen]; // backup file char csumPath[DbPathMaxLen]; // checksum file + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + memset(dbKey, 0, DbKeyMaxLen); memset(dbPath, 0, DbPathMaxLen); @@ -155,6 +165,7 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1) { printf("pclFileOpen: error => file inconsistent, recovery N O T possible!\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!")); return -1; } } @@ -225,6 +236,7 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n int pclFileReadData(int fd, void * buffer, int buffer_size) { + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileReadData fd: "), DLT_INT(fd)); return read(fd, buffer, buffer_size); } @@ -234,6 +246,8 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user { int rval = 0; + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileReadData "), DLT_INT(ldbid), DLT_STRING(resource_id)); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { int shared_DB = 0; @@ -258,13 +272,15 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user rval = remove(dbPath); if(rval == -1) { - printf("file_remove ERROR: %s \n", strerror(errno) ); + printf("pclFileRemove => remove ERROR: %s \n", strerror(errno) ); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileRemove => remove ERROR"), DLT_STRING(strerror(errno)) ); } } else { rval = shared_DB; printf("pclFileRemove ==> no valid database context or resource not a file\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileRemove ==> no valid database context or resource not a file")); } } else @@ -281,6 +297,8 @@ int pclFileSeek(int fd, long int offset, int whence) { int rval = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileSeek fd:"), DLT_INT(fd)); + if(AccessNoLock == isAccessLocked() ) // check if access to persistent data is locked { rval = lseek(fd, offset, whence); @@ -299,6 +317,8 @@ int pclFileUnmapData(void* address, long size) { int rval = 0; + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileUnmapData")); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { rval = munmap(address, size); @@ -317,6 +337,8 @@ int pclFileWriteData(int fd, const void * buffer, int buffer_size) { int size = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileWriteData fd:"), DLT_INT(fd)); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { if(fd < MaxPersHandle) @@ -412,7 +434,8 @@ int pclCreateFile(const char* path) } else { - printf("pclCreatePathAndFile ==> no valid path to create: %s\n", path); + printf("pclCreateFile ==> no valid path to create: %s\n", path); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateFile ==> no valid path to create: "), DLT_STRING(path) ); } return handle; @@ -437,14 +460,13 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha backupAvail = access(backupPath, F_OK); csumAvail = access(csumPath, F_OK); - //printf("verifyConsistency ==> backup: %d | csum: %d \n", backupAvail, csumAvail); - // ************************************************* // there is a backup file and a checksum // ************************************************* if( (backupAvail == 0) && (csumAvail == 0) ) { - printf("verifyConsistency => there is a backup file AND a checksum\n"); + printf("pclVerifyConsistency => there is a backup file AND a checksum\n"); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is a backup file AND a checksum")); // calculate checksum form backup file fdBackup = open(backupPath, O_RDONLY); if(fdBackup != -1) @@ -484,10 +506,6 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha } } } - else - { - printf("verifyConsistency ==> checksum has invalid size\n"); - } close(fdCsum); } else @@ -507,15 +525,17 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha // ************************************************* else if(csumAvail == 0) { - //printf("verifyConsistency => there is ONLY a checksum file\n"); + printf("verifyConsistency => there is ONLY a checksum file\n"); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is ONLY a checksum file")); fdCsum = open(csumPath, O_RDONLY); if(fdCsum != -1) { readSize = read(fdCsum, csumBuf, ChecksumBufSize); - if(readSize != ChecksumBufSize) + if(readSize <= 0) { printf("verifyConsistency ==> read checksum: invalid readSize\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclVerifyConsistency => read checksum: invalid readSize")); } close(fdCsum); @@ -549,7 +569,9 @@ int pclVerifyConsistency(const char* origPath, const char* backupPath, const cha // ************************************************* else if(backupAvail == 0) { - //printf("verifyConsistency => there is ONLY a backup file\n"); + printf("verifyConsistency => there is ONLY a backup file\n"); + DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclVerifyConsistency => there is ONLY a backup file")); + // calculate checksum form backup file fdBackup = open(backupPath, O_RDONLY); if(fdBackup != -1) @@ -612,7 +634,8 @@ int pclRecoverFromBackup(int backupFd, const char* original) { if(write(handle, buffer, readSize) != readSize) { - printf("pcl_recover_from_backup => couldn't write whole buffer\n"); + printf("pclRecoverFromBackup => couldn't write whole buffer\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclRecoverFromBackup => couldn't write whole buffer")); break; } } @@ -636,13 +659,15 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const int csumSize = strlen(csumBuf); if(write(csfd, csumBuf, csumSize) != csumSize) { - printf("pcl_create_backup: failed to write checksum to file\n"); + printf("pclCreateBackup: failed to write checksum to file\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to write checksum to file")); } close(csfd); } else { - printf("pcl_create_backup => failed to create checksum file: %s | %s\n", csumPath, strerror(errno)); + printf("pclCreateBackup => failed to create checksum file: %s | %s\n", csumPath, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to create checksum file:"), DLT_STRING(strerror(errno)) ); } @@ -660,7 +685,8 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const { if(write(dstFd, buffer, readSize) != readSize) { - printf("pcl_create_backup => couldn't write whole buffer\n"); + printf("pclCreateBackup => couldn't write whole buffer\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => couldn't write whole buffer")); break; } } @@ -676,7 +702,9 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const } else { - printf("pcl_create_backup => failed to open backup file: %s | %s \n", dstPath, strerror(errno)); + printf("pclCreateBackup => failed to open backup file: %s | %s \n", dstPath, strerror(errno)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclCreateBackup => failed to open backup file"), + DLT_STRING(dstPath), DLT_STRING(strerror(errno))); } return readSize; @@ -729,8 +757,6 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]) int pclBackupNeeded(const char* path) { int needBackup = 1; - - return needBackup; } diff --git a/src/persistence_client_library_handle.c b/src/persistence_client_library_handle.c index 7ccb9b3..bad7350 100644 --- a/src/persistence_client_library_handle.c +++ b/src/persistence_client_library_handle.c @@ -73,7 +73,7 @@ int get_persistence_handle_idx() else { handle = -1; - printf("get_persistence_handle_idx => Reached maximum of open handles: %d \n", MaxPersHandle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_persistence_handle_idx => Reached maximum of open handles: "), DLT_INT(MaxPersHandle)); } } pthread_mutex_unlock(&gMtx); diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c index 0256173..43352ec 100644 --- a/src/persistence_client_library_key.c +++ b/src/persistence_client_library_key.c @@ -43,6 +43,8 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u char dbKey[DbKeyMaxLen]; // database key char dbPath[DbPathMaxLen]; // database location + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleOpen: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + memset(dbKey, 0, DbKeyMaxLen); memset(dbPath, 0, DbPathMaxLen); @@ -91,12 +93,14 @@ int pclKeyHandleOpen(unsigned int ldbid, const char* resource_id, unsigned int u else { printf("pclKeyHandleOpen: error - handleId out of bounds [%d]\n", handle); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - handleId out of bounds:"), DLT_INT(handle)); } } } else { printf("pclKeyHandleOpen: error - no database context or resource is not a key \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - no database context or resource is not a key ")); } @@ -109,6 +113,10 @@ int pclKeyHandleClose(int key_handle) { int rval = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleClose: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + + if(key_handle < MaxPersHandle) { if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage ) @@ -148,6 +156,9 @@ int pclKeyHandleGetSize(int key_handle) { int size = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleGetSize: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + if(key_handle < MaxPersHandle) { if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage) @@ -178,6 +189,10 @@ int pclKeyHandleGetSize(int key_handle) int pclKeyHandleReadData(int key_handle, unsigned char* buffer, int buffer_size) { int size = 0; + + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleReadData: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + if(key_handle < MaxPersHandle) { if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage) @@ -209,6 +224,9 @@ int pclKeyHandleRegisterNotifyOnChange(int key_handle, pclChangeNotifyCallback_t { int rval = -1; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleRegisterNotifyOnChange: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + if(key_handle < MaxPersHandle) { rval = pclKeyRegisterNotifyOnChange(gKeyHandleArray[key_handle].info.context.ldbid, @@ -226,6 +244,9 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size { int size = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleWriteData: "), + // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) ); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { if(buffer_size <= gMaxKeyValDataSize) // check data size @@ -259,6 +280,7 @@ int pclKeyHandleWriteData(int key_handle, unsigned char* buffer, int buffer_size else { printf("pclKeyHandleWriteData: error - buffer_size to big, limit is [%d] bytes\n", gMaxKeyValDataSize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize)); } } else @@ -283,6 +305,8 @@ int pclKeyDelete(unsigned int ldbid, const char* resource_id, unsigned int user_ { int rval = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyDelete: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { PersistenceInfo_s dbContext; @@ -339,6 +363,8 @@ int pclKeyGetSize(unsigned int ldbid, const char* resource_id, unsigned int user dbContext.context.seat_no = seat_no; dbContext.context.user_no = user_no; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyGetSize: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + // get database context: database path and database key data_size = get_db_context(&dbContext, resource_id, ResIsNoFile, dbKey, dbPath); if( (data_size >= 0) @@ -370,6 +396,8 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use { int data_size = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyReadData: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { PersistenceInfo_s dbContext; @@ -403,6 +431,7 @@ int pclKeyReadData(unsigned int ldbid, const char* resource_id, unsigned int use else { printf("pclKeyReadData - error - no database context or resource is not a key\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyReadData - error - no database context or resource is not a key")); } } else @@ -420,6 +449,8 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us { int data_size = 0; + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyWriteData: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked { if(buffer_size <= gMaxKeyValDataSize) // check data size @@ -460,12 +491,14 @@ int pclKeyWriteData(unsigned int ldbid, const char* resource_id, unsigned int us else { printf("pclKeyWriteData: error - no database context or resource is not a key\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData - error - no database context or resource is not a key")); } } else { data_size = EPERS_BUFLIMIT; printf("pclKeyWriteData: error - buffer_size to big, limit is [%d] bytes\n", gMaxKeyValDataSize); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize)); } } else @@ -489,6 +522,8 @@ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, un memset(dbKey, 0, DbKeyMaxLen); memset(dbPath, 0, DbPathMaxLen); + //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyRegisterNotifyOnChange: "), DLT_INT(ldbid), DLT_STRING(resource_id) ); + dbContext.context.ldbid = ldbid; dbContext.context.seat_no = seat_no; dbContext.context.user_no = user_no; @@ -505,6 +540,7 @@ int pclKeyRegisterNotifyOnChange(unsigned int ldbid, const char* resource_id, un else { printf("pclKeyRegisterNotifyOnChange: error - resource is not a shared resource or resource is not a key\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyRegisterNotifyOnChange: error - resource is not a shared resource or resource is not a key")); rval = EPERS_RES_NO_KEY; } diff --git a/src/persistence_client_library_lc_interface.c b/src/persistence_client_library_lc_interface.c index 0a6cc50..0febffd 100644 --- a/src/persistence_client_library_lc_interface.c +++ b/src/persistence_client_library_lc_interface.c @@ -51,7 +51,7 @@ int check_lc_request(int request, int requestID) if(-1 == write(gEfds, &cmd, (sizeof(uint64_t)))) { - printf("write failed w/ errno %d\n", errno); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("check_lc_request => failed to write to pipe"), DLT_INT(errno)); rval = NsmErrorStatus_Fail; } else @@ -62,7 +62,7 @@ int check_lc_request(int request, int requestID) } default: { - printf("Unknown lifecycle message!\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("check_lc_request => Unknown lifecycle message"), DLT_INT(request)); break; } } @@ -89,17 +89,15 @@ int msg_lifecycleRequest(DBusConnection *connection, DBusMessage *message) if (reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_lifecycleRequest => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_lifecycleRequest => DBus No memory")); } - dbus_message_unref (reply); + dbus_message_unref(reply); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -110,20 +108,17 @@ int msg_lifecycleRequest(DBusConnection *connection, DBusMessage *message) if (reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_lifecycleRequest => DBus No memory")); } if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &msgReturn, DBUS_TYPE_INVALID)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_lifecycleRequest => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_lifecycleRequest => DBus No memory")); } dbus_connection_flush(connection); @@ -139,7 +134,6 @@ DBusHandlerResult checkLifecycleMsg(DBusConnection * connection, DBusMessage * m { DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - //printf("handleObjectPathMessage '%s' -> '%s'\n", dbus_message_get_interface(message), dbus_message_get_member(message)); if((0==strncmp("org.genivi.NodeStateManager.LifeCycleConsumer", dbus_message_get_interface(message), 20))) { if((0==strncmp("LifecycleRequest", dbus_message_get_member(message), 18))) @@ -148,7 +142,7 @@ DBusHandlerResult checkLifecycleMsg(DBusConnection * connection, DBusMessage * m } else { - printf("checkLifecycleMsg -> unknown message '%s'\n", dbus_message_get_interface(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("checkLifecycleMsg -> unknown message "), DLT_STRING(dbus_message_get_interface(message))); } } return result; @@ -164,48 +158,55 @@ int send_lifecycle_register(const char* method, int shutdownMode, int reg) dbus_error_init (&error); DBusConnection* conn = get_dbus_connection(); - const char* objName = "/org/genivi/NodeStateManager/LifeCycleConsumer"; - const char* busName = dbus_bus_get_unique_name(conn); - - DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager", // destination - "/org/genivi/NodeStateManager/Consumer", // path - "org.genivi.NodeStateManager.Consumer", // interface - method); // method - if(message != NULL) + if(conn != NULL) { - if(reg == 1) // register - { - dbus_message_append_args(message, DBUS_TYPE_STRING, &busName, - DBUS_TYPE_STRING, &objName, - DBUS_TYPE_INT32, &shutdownMode, - DBUS_TYPE_UINT32, &gTimeoutMs, DBUS_TYPE_INVALID); - } - else // unregister + const char* objName = "/org/genivi/NodeStateManager/LifeCycleConsumer"; + const char* busName = dbus_bus_get_unique_name(conn); + + DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager", // destination + "/org/genivi/NodeStateManager/Consumer", // path + "org.genivi.NodeStateManager.Consumer", // interface + method); // method + if(message != NULL) { - dbus_message_append_args(message, DBUS_TYPE_STRING, &busName, - DBUS_TYPE_STRING, &objName, - DBUS_TYPE_INT32, &shutdownMode, DBUS_TYPE_INVALID); + if(reg == 1) // register + { + dbus_message_append_args(message, DBUS_TYPE_STRING, &busName, + DBUS_TYPE_STRING, &objName, + DBUS_TYPE_INT32, &shutdownMode, + DBUS_TYPE_UINT32, &gTimeoutMs, DBUS_TYPE_INVALID); + } + else // unregister + { + dbus_message_append_args(message, DBUS_TYPE_STRING, &busName, + DBUS_TYPE_STRING, &objName, + DBUS_TYPE_INT32, &shutdownMode, DBUS_TYPE_INVALID); - } + } - if(conn != NULL) - { - if(!dbus_connection_send(conn, message, 0)) + if(conn != NULL) { - fprintf(stderr, "send_lifecycle ==> Access denied: %s \n", error.message); - } + if(!dbus_connection_send(conn, message, 0)) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => Access denied"), DLT_STRING(error.message) ); + } - dbus_connection_flush(conn); + dbus_connection_flush(conn); + } + else + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => ERROR: Invalid connection")); + } + dbus_message_unref(message); } else { - fprintf(stderr, "send_lifecycle ==> ERROR: Invalid connection!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => ERROR: Invalid message")); } - dbus_message_unref(message); } else { - fprintf(stderr, "send_lifecycle ==> ERROR: Invalid message!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_register => ERROR: connection isn NULL")); } return rval; @@ -222,34 +223,41 @@ int send_lifecycle_request(const char* method, int requestId, int status) DBusConnection* conn = get_dbus_connection(); - DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager.Consumer", // destination - "/org/genivi/NodeStateManager/Consumer", // path - "org.genivi.NodeStateManager.Consumer", // interface - method); // method - if(message != NULL) + if(conn != NULL) { - dbus_message_append_args(message, DBUS_TYPE_INT32, &requestId, - DBUS_TYPE_INT32, &status, - DBUS_TYPE_INVALID); - - if(conn != NULL) + DBusMessage* message = dbus_message_new_method_call("org.genivi.NodeStateManager.Consumer", // destination + "/org/genivi/NodeStateManager/Consumer", // path + "org.genivi.NodeStateManager.Consumer", // interface + method); // method + if(message != NULL) { - if(!dbus_connection_send(conn, message, 0)) + dbus_message_append_args(message, DBUS_TYPE_INT32, &requestId, + DBUS_TYPE_INT32, &status, + DBUS_TYPE_INVALID); + + if(conn != NULL) { - fprintf(stderr, "send_lifecycle ==> Access denied: %s \n", error.message); - } + if(!dbus_connection_send(conn, message, 0)) + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => Access denied"), DLT_STRING(error.message) ); + } - dbus_connection_flush(conn); + dbus_connection_flush(conn); + } + else + { + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => ERROR: Invalid connection")); + } + dbus_message_unref(message); } else { - fprintf(stderr, "send_lifecycle ==> ERROR: Invalid connection!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => ERROR: Invalid message")); } - dbus_message_unref(message); } else { - fprintf(stderr, "send_lifecycle ==> ERROR: Invalid message!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_lifecycle_request => ERROR: connection isn NULL")); } return rval; @@ -309,7 +317,7 @@ void process_prepare_shutdown(unsigned char requestId, unsigned int status) state = itzam_btree_close(resourceTable); if (state != ITZAM_OKAY) { - fprintf(stderr, "\nOpen Itzam problem: %s\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("process_prepare_shutdown => itzam_btree_close: Itzam problem"), DLT_STRING(STATE_MESSAGES[state])); } } } diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c index 3b50561..31ba221 100644 --- a/src/persistence_client_library_pas_interface.c +++ b/src/persistence_client_library_pas_interface.c @@ -73,7 +73,6 @@ int check_pas_request(unsigned int request, unsigned int requestID) { rval = PasErrorStatus_RespPend; } - printf("======> check_pas_request(requestID: %u | status: %u ) \n", (unsigned int)(cmd>>32&0xFF), (unsigned int)(cmd>>16&0xFF)); break; } case PasMsg_Unblock: @@ -113,14 +112,12 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage * if(reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_persAdminRequest => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_persAdminRequest => DBus No memory")); } dbus_message_unref(reply); @@ -134,20 +131,17 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage * if (reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_persAdminRequest => DBus No memory")); } if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &errorReturn, DBUS_TYPE_INVALID)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_persAdminRequest => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("msg_persAdminRequest => DBus No memory")); } dbus_connection_flush(connection); @@ -173,14 +167,12 @@ int signal_persModeChange(DBusConnection *connection, DBusMessage *message) if(reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("signal_persModeChange => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("signal_persModeChange => DBus No memory")); } dbus_message_unref (reply); @@ -192,20 +184,17 @@ int signal_persModeChange(DBusConnection *connection, DBusMessage *message) if (reply == 0) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("signal_persModeChange => DBus No memory")); } if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &errorCode, DBUS_TYPE_INVALID)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("signal_persModeChange => DBus No memory")); } if (!dbus_connection_send(connection, reply, 0)) { - //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory")); - printf("DBus No memory\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("signal_persModeChange => DBus No memory")); } dbus_connection_flush(connection); @@ -219,7 +208,6 @@ DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * m { DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - //printf("checkPersAdminMsg '%s' -> '%s'\n", dbus_message_get_interface(message), dbus_message_get_member(message)); if((0==strcmp("org.genivi.persistence.adminconsumer", dbus_message_get_interface(message)))) { if((0==strcmp("PersistenceAdminRequest", dbus_message_get_member(message)))) @@ -228,12 +216,12 @@ DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * m } else { - printf("checkPersAdminMsg -> unknown message '%s'\n", dbus_message_get_interface(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("checkPersAdminMsg => unknown message"), DLT_STRING(dbus_message_get_member(message))); } } else { - printf("checkPersAdminMsg ELSE -> unknown message '%s'\n", dbus_message_get_interface(message)); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("checkPersAdminMsg => unknown message"), DLT_STRING(dbus_message_get_interface(message))); } return result; } @@ -264,7 +252,6 @@ int send_pas_register(const char* method, int notificationFlag) DBUS_TYPE_INT32, ¬ificationFlag, DBUS_TYPE_UINT32, &gTimeoutMs, DBUS_TYPE_INVALID); - if(conn != NULL) { replyMsg = dbus_connection_send_with_reply_and_block(conn, message, gTimeoutMs, &error); @@ -273,30 +260,29 @@ int send_pas_register(const char* method, int notificationFlag) { if(dbus_set_error_from_message(&error, replyMsg)) { - fprintf(stderr, "sendDBusMessage ==> Access denied: %s \n", error.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register => Access denied"), DLT_STRING(error.message) ); } else { dbus_message_get_args(replyMsg, &error, DBUS_TYPE_INT32, &rval, DBUS_TYPE_INVALID); - printf("send_pas_register ==> REPLY value: %d \n", rval); } dbus_message_unref(replyMsg); } else { - printf("send_pas_register ==> reply message is NULL!\n ==> error msg: %s \n", error.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register => reply message is NULL!"), DLT_STRING(error.message) ); } } else { - fprintf(stderr, "send_pers_admin_service ==> ERROR: Invalid connection!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register => ERROR: Invalid connection") ); rval = -1; } dbus_message_unref(message); } else { - fprintf(stderr, "send_pers_admin_service ==> ERROR: Invalid message!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_register => ERROR: Invalid message") ); rval = -1; } @@ -318,9 +304,6 @@ int send_pas_request(const char* method, unsigned int requestID, int status) "/org/genivi/persistence/admin", // path "org.genivi.persistence.admin", // interface method); // method - - printf(" =======****> send_pas_request: requestID: %u | status: %d \n", requestID, status); - if(message != NULL) { dbus_message_append_args(message, DBUS_TYPE_UINT32, &requestID, @@ -334,7 +317,7 @@ int send_pas_request(const char* method, unsigned int requestID, int status) { if(dbus_set_error_from_message(&error, replyMsg)) { - fprintf(stderr, "sendDBusMessage ==> Access denied: %s \n", error.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => Access denied"), DLT_STRING(error.message) ); } else { @@ -344,19 +327,19 @@ int send_pas_request(const char* method, unsigned int requestID, int status) } else { - fprintf(stderr, "send_pas_request ==> reply messgae is NULL!\n ==> error msg: %s \n", error.message); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => reply messgae is NULL"), DLT_STRING(error.message) ); } } else { - fprintf(stderr, "send_pers_admin_service ==> ERROR: Invalid connection!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => ERROR: Invalid connection") ); rval = -1; } dbus_message_unref(message); } else { - fprintf(stderr, "send_pers_admin_service ==> ERROR: Invalid message!! \n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("send_pas_request => ERROR: Invalid message") ); rval = -1; } diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c index 96b6f69..1624c29 100644 --- a/src/persistence_client_library_prct_access.c +++ b/src/persistence_client_library_prct_access.c @@ -100,11 +100,10 @@ itzam_btree* get_resource_cfg_table(PersistenceRCT_e rct, int group) break; } - //printf("get_resource_cfg_table => %s \n", filename); state = itzam_btree_open(&gResource_table[arrayIdx], filename, itzam_comparator_string, error_handler, 0 , 0); if(state != ITZAM_OKAY) { - fprintf(stderr, "\n** get_resource_cfg_table => Itzam problem: %s**\n", STATE_MESSAGES[state]); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_resource_cfg_table => itzam_btree_open => Itzam problem"), DLT_STRING(STATE_MESSAGES[state]) ); tree = NULL; } else @@ -170,12 +169,14 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign else { printf("get_db_context - resource_table: no value for key: %s \n", resource_id); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_db_context => itzam_btree_open => resource_table: no value for key"), DLT_STRING(resource_id) ); rval = EPERS_NOKEYDATA; } } // resource table else { printf("get_db_context - error resource table\n"); + DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_db_context =>error resource table")); rval = EPERS_NOPRCTABLE; } diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 56fd931..863be2d 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -26,6 +26,9 @@ #include #include +#include +#include + #include "../include/persistence_client_library_key.h" #include "../include/persistence_client_library_file.h" #include "../include/persistence_client_library_error_def.h" -- cgit v1.2.1