From b510906bf68aef332cb195419ded8f87917fa76f Mon Sep 17 00:00:00 2001 From: Netaji Panigrahi <114923459+NetajiPanigrahi@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:13:59 +0530 Subject: [PATCH] Fix: Modifying Error Codes in rbus_getExt API (#202) * Fix: Modifying Error Codes in RBUS Core Reason for change: When an object not found error originates from rtrouted, rbuscore retrus error code RBUSCORE_ERROR_ENTRY_NOT_FOUND instead of RBUSCORE_ERROR_DESTINATION_UNREACHABLE. Signed-off-by: Netaji Panigrahi * Fix: Modifying Error Codes in RBUS Core Reason for change: When an object not found error originates from rtrouted, rbuscore retrus error code RBUSCORE_ERROR_ENTRY_NOT_FOUND instead of RBUSCORE_ERROR_DESTINATION_UNREACHABLE. Signed-off-by: Netaji Panigrahi * Updated test code * Fixed Method_Invoke failed tests * Fixed SetMulti test * Fix: Modifying Error Codes in rbus_getExt API Reason for change: When Discover component names failed, rbusgetExt function will return the error code RBUSCORE_ERROR_ENTRY_NOT_FOUND. Signed-off-by: Netaji Panigrahi * Fix: Modifying Error Codes --- src/rbus/rbus.c | 16 ++++++++-------- unittests/rbusConsumer.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/rbus/rbus.c b/src/rbus/rbus.c index b8b42a02..a12965e1 100644 --- a/src/rbus/rbus.c +++ b/src/rbus/rbus.c @@ -1368,7 +1368,7 @@ static int _master_event_callback_handler(char const* sender, char const* eventN if(subInternal->dirty) { errorcode = _rbus_event_unsubscribe(handleInfo, subInternal); - if(errorcode != RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if(errorcode != RBUS_ERROR_DESTINATION_NOT_FOUND) { rbusEventSubscriptionInternal_free(subInternal); errorcode = RBUS_ERROR_SUCCESS; @@ -2995,7 +2995,7 @@ rbusError_t rbus_close(rbusHandle_t handle) rbusEventSubscriptionInternal_t* subInternal = NULL; subInternal = (rbusEventSubscriptionInternal_t*)rtVector_At(handleInfo->eventSubs, 0); ret = _rbus_event_unsubscribe(handle, subInternal); - if (ret == RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if (ret == RBUS_ERROR_DESTINATION_NOT_FOUND) { rtVector_RemoveItem(handleInfo->eventSubs, subInternal, rbusEventSubscriptionInternal_free); } @@ -3664,7 +3664,7 @@ rbusError_t rbus_getExt(rbusHandle_t handle, int paramCount, char const** pParam } else { - errorcode = RBUS_ERROR_DESTINATION_NOT_REACHABLE; + errorcode = RBUS_ERROR_DESTINATION_NOT_FOUND; RBUSLOG_ERROR("Discover component names failed with error %d and counts %d/%d", errorcode, paramCount, numComponents); } if(componentNames) @@ -4623,7 +4623,7 @@ static rbusError_t _rbus_event_unsubscribe( subInternal->dirty = true; RBUSLOG_DEBUG ("n%s unsubscription failed because no provider could be found" "and subscriber marked as dirty", subscription->eventName); - errorcode = RBUS_ERROR_DESTINATION_NOT_REACHABLE; + errorcode = RBUS_ERROR_DESTINATION_NOT_FOUND; } else { @@ -4860,7 +4860,7 @@ static void _subscribe_rawdata_handler(rbusHandle_t handle, rbusMessage_t* msg, if (subInternal && subInternal->dirty) { errorcode = _rbus_event_unsubscribe(handle, subInternal); - if(errorcode == RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if(errorcode == RBUS_ERROR_DESTINATION_NOT_FOUND) { RBUSLOG_DEBUG ("%s unsubscription failed because no provider could be found" "and subscriber marked as dirty", subInternal->sub->eventName); @@ -5096,7 +5096,7 @@ rbusError_t rbusEvent_UnsubscribeRawData( if (subInternal) { errorcode = _rbus_event_unsubscribe(handle, subInternal); - if(errorcode != RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if(errorcode != RBUS_ERROR_DESTINATION_NOT_FOUND) { rbusEventSubscriptionInternal_free(subInternal); } @@ -5326,7 +5326,7 @@ rbusError_t rbusEvent_UnsubscribeExRawData( if(subInternal) { errorcode = _rbus_event_unsubscribe(handle, subInternal); - if(errorcode != RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if(errorcode != RBUS_ERROR_DESTINATION_NOT_FOUND) { rbusEventSubscriptionInternal_free(subInternal); } @@ -5412,7 +5412,7 @@ rbusError_t rbusEvent_UnsubscribeEx( } } errorcode = _rbus_event_unsubscribe(handle, subInternal); - if(errorcode != RBUS_ERROR_DESTINATION_NOT_REACHABLE) + if(errorcode != RBUS_ERROR_DESTINATION_NOT_FOUND) { rbusEventSubscriptionInternal_free(subInternal); } diff --git a/unittests/rbusConsumer.cpp b/unittests/rbusConsumer.cpp index 25e3faa4..d01f8a70 100644 --- a/unittests/rbusConsumer.cpp +++ b/unittests/rbusConsumer.cpp @@ -450,7 +450,7 @@ int rbusConsumer(rbusGtest_t test, pid_t pid, int runtime) { const char *param = "Device.rbusProvider.Param2"; isElementPresent(handle, param); - rc = exec_rbus_set_test(handle, RBUS_ERROR_DESTINATION_NOT_REACHABLE, "Device.rbusProvider.Param4", "Gtest set value"); + rc = exec_rbus_set_test(handle, RBUS_ERROR_DESTINATION_NOT_FOUND, "Device.rbusProvider.Param4", "Gtest set value"); } break; case RBUS_GTEST_SET4: @@ -524,7 +524,7 @@ int rbusConsumer(rbusGtest_t test, pid_t pid, int runtime) const char *param1 = "Device.rbusProvider.Param2"; const char *param2 = "Device.rbusProvider.Param4"; isElementPresent(handle, param1); - rc = exec_rbus_multi_test(handle, RBUS_ERROR_DESTINATION_NOT_REACHABLE, 2, param1, param2); + rc = exec_rbus_multi_test(handle, RBUS_ERROR_DESTINATION_NOT_FOUND, 2, param1, param2); } break; case RBUS_GTEST_SET_MULTI4: