osaf/services/saf/ntfsv/ntfs/Makefile.am | 1 + osaf/services/saf/ntfsv/ntfs/NtfAdmin.cc | 3 ++ osaf/services/saf/ntfsv/ntfs/NtfFilter.cc | 44 ++++++++++++++++-------------- osaf/services/saf/ntfsv/ntfs/NtfLogger.cc | 40 ++++++++++++++++++++++++--- osaf/services/saf/ntfsv/ntfs/ntfs_evt.c | 7 +++- osaf/services/saf/ntfsv/ntfs/ntfs_main.c | 5 +++ 6 files changed, 72 insertions(+), 28 deletions(-)
(1) Retry logging with truncated notificationObject/notifyingObject as no long dn support in LOG Service (2) Fix longdn deallocation followed by memory owner diff --git a/osaf/services/saf/ntfsv/ntfs/Makefile.am b/osaf/services/saf/ntfsv/ntfs/Makefile.am --- a/osaf/services/saf/ntfsv/ntfs/Makefile.am +++ b/osaf/services/saf/ntfsv/ntfs/Makefile.am @@ -39,6 +39,7 @@ osaf_execbindir = $(pkglibdir) osaf_execbin_PROGRAMS = osafntfd osafntfd_CPPFLAGS = \ + -DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/osaf/libs/common/ntfsv/include \ -I$(top_srcdir)/osaf/tools/saflog/include diff --git a/osaf/services/saf/ntfsv/ntfs/NtfAdmin.cc b/osaf/services/saf/ntfsv/ntfs/NtfAdmin.cc --- a/osaf/services/saf/ntfsv/ntfs/NtfAdmin.cc +++ b/osaf/services/saf/ntfsv/ntfs/NtfAdmin.cc @@ -301,6 +301,7 @@ void NtfAdmin::notificationReceivedUpdat // we have got the notification TRACE_2("notification %u received" " again, skipped", (unsigned int)notificationId); + ntfsv_dealloc_notification(sendNotInfo); delete sendNotInfo; } else @@ -344,6 +345,8 @@ void NtfAdmin::notificationReceivedColdS // we have got the notification TRACE_2("notification %u received" " again, skipped", (unsigned int)notificationId); + ntfsv_dealloc_notification(sendNotInfo); + delete sendNotInfo; } else { diff --git a/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc b/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc --- a/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc +++ b/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc @@ -24,9 +24,10 @@ */ #include "NtfFilter.hh" +#include <string> #include "logtrace.h" #include "ntfsv_mem.h" - +#include "osaf_extended_name.h" /** * Constructor. * @@ -115,22 +116,23 @@ bool NtfFilter::checkSourceIndicator(SaU */ bool NtfFilter::cmpSaNameT(SaNameT *n, SaNameT *n2) { - if (n->length != n2->length) { - if (n->length < n2->length) { - char *rv, *p = strndup((char*)n->value, n->length); - char *p2 = strndup((char*)n2->value, n2->length); - rv = strstr(p2,p); - free(p); - free(p2); - if (rv) - return true; - } - return false; - } + bool rc; + SaConstStringT str2, str; + size_t length, length2; - if(memcmp(n->value, n2->value, n2->length) == 0) - return true; - return false; + rc = false; + str = osaf_extended_name_borrow(n); + length = strlen(str); + str2 = osaf_extended_name_borrow(n2); + length2 = strlen(str2); + + if (length != length2) { + if (length < length2) + rc = strstr(str2, str) != NULL; + } else if(memcmp(str, str2, length) == 0) + rc = true; + + return rc; } /** @@ -244,7 +246,7 @@ NtfAlarmFilter::NtfAlarmFilter(SaNtfAlar NtfAlarmFilter::~NtfAlarmFilter() { TRACE_8("destructor p = %p", filter_); - ntfsv_filter_alarm_free(filter_); + ntfsv_filter_alarm_free(filter_, true); free(filter_); } @@ -325,7 +327,7 @@ NtfSecurityAlarmFilter::NtfSecurityAlarm NtfSecurityAlarmFilter::~NtfSecurityAlarmFilter() { TRACE_8("destructor p = %p", filter_); - ntfsv_filter_sec_alarm_free(filter_); + ntfsv_filter_sec_alarm_free(filter_, true); free(filter_); } @@ -442,7 +444,7 @@ NtfFilter(SA_NTF_TYPE_OBJECT_CREATE_DELE NtfObjectCreateDeleteFilter::~NtfObjectCreateDeleteFilter() { TRACE_8("destructor p = %p", filter_); - ntfsv_filter_obj_cr_del_free(filter_); + ntfsv_filter_obj_cr_del_free(filter_, true); free(filter_); } @@ -476,7 +478,7 @@ NtfStateChangeFilter::NtfStateChangeFilt NtfStateChangeFilter::~NtfStateChangeFilter() { TRACE_8("destructor p = %p", filter_); - ntfsv_filter_state_ch_free(filter_); + ntfsv_filter_state_ch_free(filter_, true); free(filter_); } @@ -548,7 +550,7 @@ bool NtfAttributeChangeFilter::checkFilt NtfAttributeChangeFilter::~NtfAttributeChangeFilter() { TRACE_8("destructor p = %p", filter_); - ntfsv_filter_attr_ch_free(filter_); + ntfsv_filter_attr_ch_free(filter_, true); free(filter_); } diff --git a/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc b/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc --- a/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc +++ b/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc @@ -21,12 +21,14 @@ */ #include <sys/poll.h> +#include "saAis.h" #include "saLog.h" #include "NtfAdmin.hh" #include "NtfLogger.hh" #include "ntfs_com.h" #include "logtrace.h" #include "ntfsv_mem.h" +#include "osaf_extended_name.h" /* ======================================================================== * DEFINITIONS @@ -250,13 +252,40 @@ SaAisErrorT NtfLogger::logNotification(N &logRecord); if (SA_AIS_OK != errorCode) { - LOG_ER("Failed to log an alarm or security alarm " - "notification (%d)", - errorCode); + LOG_ER("Failed to log an alarm or security alarm notification (%d)", errorCode); if (errorCode == SA_AIS_ERR_LIBRARY || errorCode == SA_AIS_ERR_BAD_HANDLE) { LOG_ER("Fatal error SA_AIS_ERR_LIBRARY or SA_AIS_ERR_BAD_HANDLE; exiting (%d)...", errorCode); exit(EXIT_FAILURE); - } + } else if (errorCode == SA_AIS_ERR_INVALID_PARAM) { + /* Retry to log truncated notificationObject/notifyingObject because + * LOG Service has not supported long dn in Opensaf 4.5 + */ + char short_dn[SA_MAX_UNEXTENDED_NAME_LENGTH]; + memset(&short_dn, 0, SA_MAX_UNEXTENDED_NAME_LENGTH); + SaNameT shortdn_notificationObject, shortdn_notifyingObject; + if (osaf_is_an_extended_name(ntfHeader->notificationObject)) { + strncpy(short_dn, osaf_extended_name_borrow(ntfHeader->notificationObject) + , SA_MAX_UNEXTENDED_NAME_LENGTH - 1); + osaf_extended_name_lend(short_dn, &shortdn_notificationObject); + logRecord.logHeader.ntfHdr.notificationObject = &shortdn_notificationObject; + } + if (osaf_is_an_extended_name(ntfHeader->notifyingObject)) { + strncpy(short_dn, osaf_extended_name_borrow(ntfHeader->notifyingObject) + , SA_MAX_UNEXTENDED_NAME_LENGTH - 1); + osaf_extended_name_lend(short_dn, &shortdn_notifyingObject); + logRecord.logHeader.ntfHdr.notifyingObject = &shortdn_notifyingObject; + } + if (short_dn[0] != '\0') { + LOG_NO("Retry to log the truncated notificationObject/notifyingObject"); + if ((errorCode = saLogWriteLogAsync(alarmStreamHandle, + notif->getNotificationId(), + SA_LOG_RECORD_WRITE_ACK, + &logRecord)) != SA_AIS_OK) { + LOG_ER("Failed to log the truncated notificationObject/notifyingObject (%d)" + , errorCode); + } + } + } goto end; } } @@ -270,7 +299,8 @@ SaAisErrorT NtfLogger::logNotification(N SaAisErrorT NtfLogger::initLog() { SaAisErrorT result; - SaNameT alarmStreamName = {sizeof(SA_LOG_STREAM_ALARM), SA_LOG_STREAM_ALARM}; + SaNameT alarmStreamName; + osaf_extended_name_lend(SA_LOG_STREAM_ALARM, &alarmStreamName); int first_try = 1; TRACE_ENTER(); diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c --- a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c +++ b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c @@ -20,6 +20,7 @@ #include <limits.h> #include "ntfs.h" #include "ntfsv_enc_dec.h" +#include "osaf_extended_name.h" #include "ntfs_imcnutil.h" @@ -342,10 +343,12 @@ static void print_header(SaNtfNotificati TRACE_1("eventType = %d", (int)*notificationHeader->eventType); /* Notification Object */ - TRACE_1("notificationObject.length = %u\n", notificationHeader->notificationObject->length); + TRACE_1("notificationObject.length = %zu\n", + osaf_extended_name_length(notificationHeader->notificationObject)); /* Notifying Object */ - TRACE_1("notifyingObject->length = %u\n", notificationHeader->notifyingObject->length); + TRACE_1("notifyingObject->length = %zu\n", + osaf_extended_name_length(notificationHeader->notifyingObject)); /* Notification Class ID */ TRACE_1("VendorID = %d\nmajorID = %d\nminorID = %d\n", diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c --- a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c +++ b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c @@ -180,6 +180,11 @@ static uint32_t initialize() uint32_t rc = NCSCC_RC_SUCCESS;; TRACE_ENTER(); + /* Set extended SaNameT environment var*/ + if (setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1) != 0) { + LOG_ER("Failed to set environment variable: SA_ENABLE_EXTENDED_NAMES"); + goto done; + } /* Determine how this process was started, by NID or AMF */ if (getenv("SA_AMF_COMPONENT_NAME") == NULL) ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel