diff options
author | Ingo Huerner <ingo.huerner@xse.de> | 2014-07-01 16:29:13 +0200 |
---|---|---|
committer | Ingo Huerner <ingo.huerner@xse.de> | 2014-07-01 16:29:13 +0200 |
commit | 6ba53c043395da1c17a51dbea6ff7432731a9944 (patch) | |
tree | 9a032b3a60665f001717547d9e1bc55b7273a79b | |
parent | 42dfdbf362ced48aa8b2761279ba9f9b8a5f8823 (diff) | |
download | persistence-client-library-6ba53c043395da1c17a51dbea6ff7432731a9944.tar.gz |
Fixed a problem with sporadic blocking of pclDeinitLibrary
-rw-r--r-- | src/persistence_client_library.c | 3 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_cmd.c | 2 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_service.c | 16 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_service.h | 4 | ||||
-rw-r--r-- | src/persistence_client_library_lc_interface.c | 2 | ||||
-rw-r--r-- | src/persistence_client_library_pas_interface.c | 2 | ||||
-rw-r--r-- | test/persistence_client_library_benchmark.c | 2 | ||||
-rw-r--r-- | test/persistence_client_library_test.c | 32 | ||||
-rw-r--r-- | test/persistence_test_customlib.c | 14 |
9 files changed, 36 insertions, 41 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 061433c..5bcda0f 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -202,9 +202,6 @@ int pclDeinitLibrary(void) process_prepare_shutdown(Shutdown_Full); // close all db's and fd's and block access - // end dbus library - bContinue = 0; - // send quit command to dbus mainloop deliverToMainloop_NM(&data); diff --git a/src/persistence_client_library_dbus_cmd.c b/src/persistence_client_library_dbus_cmd.c index 4698909..04d5789 100644 --- a/src/persistence_client_library_dbus_cmd.c +++ b/src/persistence_client_library_dbus_cmd.c @@ -369,8 +369,6 @@ void process_send_lifecycle_register(DBusConnection* conn, int regType, int shut { const char* busName = dbus_bus_get_unique_name(conn); - printf("process_send_lifecycle_register => busName: %s\n", busName); - DBusMessage* message = dbus_message_new_method_call(gDbusLcConsDest, // destination gDbusLcCons, // path gDbusLcInterface, // interface diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c index 845cc8f..94a616f 100644 --- a/src/persistence_client_library_dbus_service.c +++ b/src/persistence_client_library_dbus_service.c @@ -446,7 +446,6 @@ static dbus_bool_t addTimeout(DBusTimeout *timeout, void *data) { DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout => cannot create another fd to be poll()'ed")); } - return ret; } @@ -531,7 +530,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, memset(&gPollInfo, 0 , sizeof(gPollInfo)); gPollInfo.nfds = 1; - //gPollInfo.fds[0].fd = gEfds; gPollInfo.fds[0].fd = gPipeFd[0]; gPollInfo.fds[0].events = POLLIN; @@ -557,7 +555,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, { bContinue = 0; /* assume error */ - while (DBUS_DISPATCH_DATA_REMAINS==dbus_connection_dispatch(conn)); + while(DBUS_DISPATCH_DATA_REMAINS==dbus_connection_dispatch(conn)); while ((-1==(ret=poll(gPollInfo.fds, gPollInfo.nfds, -1)))&&(EINTR==errno)); @@ -572,8 +570,9 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, else { int i; + int bQuit = FALSE; - for (i=0; gPollInfo.nfds>i; ++i) + for (i=0; gPollInfo.nfds>i && !bQuit; ++i) { /* anything to do */ if (0!=gPollInfo.fds[i].revents) @@ -582,6 +581,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, { /* time-out occured */ unsigned long long nExpCount = 0; + if ((ssize_t)sizeof(nExpCount)!=read(gPollInfo.fds[i].fd, &nExpCount, sizeof(nExpCount))) { DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => read failed")); @@ -594,9 +594,9 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, } bContinue = TRUE; } - //else if (gPollInfo.fds[i].fd == gEfds) else if (gPollInfo.fds[i].fd == gPipeFd[0]) { + /* internal command */ if (0!=(gPollInfo.fds[i].revents & POLLIN)) { @@ -639,6 +639,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, break; case CMD_QUIT: bContinue = 0; + bQuit = TRUE; break; default: DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("mainLoop => command not handled"), DLT_INT(readData.message.cmd) ); @@ -652,6 +653,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, else { int flags = 0; + if (0!=(gPollInfo.fds[i].revents & POLLIN)) { flags |= DBUS_WATCH_READABLE; @@ -668,7 +670,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, { flags |= DBUS_WATCH_HANGUP; } - bContinue = dbus_watch_handle(gPollInfo.objects[i].watch, flags); } } @@ -683,7 +684,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, dbus_connection_unregister_object_path(conn, gDbusLcConsPath); dbus_connection_unregister_object_path(conn, "/"); } - //close(gEfds); + close(gPipeFd[0]); close(gPipeFd[1]); } @@ -731,7 +732,6 @@ int deliverToMainloop_NM(tMainLoopData* payload) DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("deliverToMainloop => failed to write to pipe"), DLT_INT(errno)); rval = -1; } - return rval; } diff --git a/src/persistence_client_library_dbus_service.h b/src/persistence_client_library_dbus_service.h index 43d4f6a..59666ce 100644 --- a/src/persistence_client_library_dbus_service.h +++ b/src/persistence_client_library_dbus_service.h @@ -34,10 +34,6 @@ extern pthread_mutex_t gDbusPendingRegMtx; extern pthread_mutex_t gMainCondMtx; -// declared in persistence_client_library_dbus_service.c -// used to end dbus library -extern int bContinue; - extern pthread_t gMainLoopThread; diff --git a/src/persistence_client_library_lc_interface.c b/src/persistence_client_library_lc_interface.c index 42b11f9..4e9a71f 100644 --- a/src/persistence_client_library_lc_interface.c +++ b/src/persistence_client_library_lc_interface.c @@ -136,8 +136,6 @@ DBusHandlerResult checkLifecycleMsg(DBusConnection * connection, DBusMessage * m (void)user_data; - printf("checkLifecycleMsg ==> \n Interface: %s \n Message: %s \n", dbus_message_get_interface(message), dbus_message_get_member(message)); - if((0==strncmp(gDbusLcConsterface, dbus_message_get_interface(message), 46))) { if((0==strncmp(gDbusLcConsMsg, dbus_message_get_member(message), 16))) diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c index 792f3e4..4c0d2fc 100644 --- a/src/persistence_client_library_pas_interface.c +++ b/src/persistence_client_library_pas_interface.c @@ -207,8 +207,6 @@ DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * m (void)user_data; - printf("checkPersAdminMsg => \n interface: %s\n Message: %s \n", dbus_message_get_interface(message), dbus_message_get_member(message)); - if((0==strcmp(gDbusPersAdminConsInterface, dbus_message_get_interface(message)))) { if((0==strcmp(gDbusPersAdminConsMsg, dbus_message_get_member(message)))) diff --git a/test/persistence_client_library_benchmark.c b/test/persistence_client_library_benchmark.c index aa2032e..bb97800 100644 --- a/test/persistence_client_library_benchmark.c +++ b/test/persistence_client_library_benchmark.c @@ -487,7 +487,7 @@ int main(int argc, char *argv[]) resolution = ((clockRes.tv_sec * SECONDS2NANO) + clockRes.tv_nsec); printf("Clock resolution => %f ms\n\n", (double)((double)resolution/NANO2MIL)); - init_benchmark(1000); + init_benchmark(numLoops); // init library diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 794c044..12d4761 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -23,6 +23,7 @@ #include <time.h> #include <fcntl.h> #include <sys/mman.h> +#include <sys/stat.h> #include <dlt/dlt.h> #include <dlt/dlt_common.h> @@ -319,14 +320,14 @@ START_TEST(test_SetData) * Logical DB ID: 0xFF with user 3 and seat 2 * ==> local USER value (user 3, seat 2) */ - ret = pclKeyWriteData(0xFF, "status/open_document", 3, 2, "WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf")); + ret = pclKeyWriteData(0xFF, "status/open_document", 3, 2, (unsigned char*)"WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf")); x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Wrong write size"); - ret = pclKeyWriteData(0x84, "links/last_link", 2, 1, "CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens")); + ret = pclKeyWriteData(0x84, "links/last_link", 2, 1, (unsigned char*)"CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens")); x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"), "Wrong write size"); - ret = pclKeyWriteData(0xFF, "posHandle/last_position", 0, 0, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"")); + ret = pclKeyWriteData(0xFF, "posHandle/last_position", 0, 0, (unsigned char*)"WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"")); x_fail_unless(ret == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""), "Wrong write size"); #endif @@ -1178,21 +1179,26 @@ END_TEST START_TEST(test_InitDeinit) { - unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL; + int i = 0; + unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL; - // initialize and deinitialize 1. time - (void)pclInitLibrary(gTheAppId, shutdownReg); - pclDeinitLibrary(); + for(i=1; i<20; i++) + { + // initialize and deinitialize 1. time + (void)pclInitLibrary(gTheAppId, shutdownReg); + pclDeinitLibrary(); - // initialize and deinitialize 2. time - (void)pclInitLibrary(gTheAppId, shutdownReg); - pclDeinitLibrary(); + // initialize and deinitialize 2. time + (void)pclInitLibrary(gTheAppId, shutdownReg); + pclDeinitLibrary(); - // initialize and deinitialize 3. time - (void)pclInitLibrary(gTheAppId, shutdownReg); - pclDeinitLibrary(); + // initialize and deinitialize 3. time + (void)pclInitLibrary(gTheAppId, shutdownReg); + pclDeinitLibrary(); + } + } END_TEST diff --git a/test/persistence_test_customlib.c b/test/persistence_test_customlib.c index 50694d1..581dbe7 100644 --- a/test/persistence_test_customlib.c +++ b/test/persistence_test_customlib.c @@ -84,7 +84,7 @@ int plugin_delete_data(const char* path) // OK int plugin_handle_get_data(int handle, char* buffer, int size) { - int strSize = 99; + //int strSize = 99; //printf("plugin_handle_get_data: %s\n", LIBIDENT); return snprintf(buffer, size, "Custom plugin -> plugin_get_data_handle: %s!", LIBIDENT); @@ -100,7 +100,7 @@ int plugin_handle_get_data(int handle, char* buffer, int size) // OK int plugin_get_data(const char* path, char* buffer, int size) { - int strSize = 99; + //int strSize = 99; //printf("Custom plugin -> plugin_get_data: %s!\n", LIBIDENT); @@ -117,20 +117,20 @@ int plugin_get_data(const char* path, char* buffer, int size) // OK int plugin_init() { - int rval = 99; + //int rval = 99; //printf("* * * * * plugin_init sync => %s!\n", LIBIDENT); - return rval; + return 1; } int plugin_init_async(plugin_callback_async_t pfInitCompletedCB) { - int rval = -1; + //int rval = -1; //printf("* * * * * plugin_init_async => %s!\n", LIBIDENT); - return rval; + return 1; } @@ -290,12 +290,14 @@ int plugin_get_backup(char* backup_id, int size) int plugin_clear_all_data(void) { printf("plugin_clear_all_data\n"); + return 1; } int plugin_sync(void) { printf("plugin_sync\n"); + return 1; } |