Hi Srinivas,

 

Please see my comment [Canh]

 

Regards

Canh

 

-----Original Message-----

From: srinivas [mailto:[email protected]] 

Sent: Wednesday, March 28, 2018 2:11 PM

To: [email protected]; [email protected];
[email protected]

Cc: [email protected]; srinivas
<[email protected]>

Subject: [PATCH 1/1] ntf: fix to avoid core dump of osafntfimcnd processs
[#2806]

 

---

src/ntf/ntfimcnd/ntfimcn_imm.c | 34 +++++++++++-----------------------

1 file changed, 11 insertions(+), 23 deletions(-)

 

diff --git a/src/ntf/ntfimcnd/ntfimcn_imm.c b/src/ntf/ntfimcnd/ntfimcn_imm.c

index 1358d9f..0de0264 100644

--- a/src/ntf/ntfimcnd/ntfimcn_imm.c

+++ b/src/ntf/ntfimcnd/ntfimcn_imm.c

@@ -152,7 +152,6 @@ static SaAisErrorT getClassDescription(const
SaImmClassNameT className,

  *

  * Note:

  * Uses in file global struct s_get_rdn_attr_name

- * Uses global immOmHandle in struct ntfimcn_cb_t

  *

  * @param className[in]

  *

@@ -175,8 +174,8 @@ static char *get_rdn_attr_name(const SaImmClassNameT
className)

               s_get_rdn_attr_name.saved_className =

                   realloc(s_get_rdn_attr_name.saved_className,
strlen(className) + 1);

               if (s_get_rdn_attr_name.saved_className == NULL) {

-                              LOG_ER("Failed to realloc memory");

-                              goto error;

+                             LOG_ER("%s: Failed to realloc
memory",__FUNCTION__);

+                             osaf_abort(0);

               }

               memcpy(s_get_rdn_attr_name.saved_className, className,

                      strlen(className) + 1);

@@ -184,14 +183,14 @@ static char *get_rdn_attr_name(const SaImmClassNameT
className)

 

[Canh] Remove the initializeImmOmHandle() here. There is not needed. There
is variable "ntfimcn_cb.immOmHandle" already. And  getClassDescription() are
using this variable.

               /* Get an IMM OM Handle */

               SaImmHandleT immOmHandle = 0;

               if (initializeImmOmHandle(&immOmHandle) == false) {

-                              LOG_ER("getImmOmHandle() Fail");

+                             LOG_NO("initializeImmOmHandle() Fail");

                               goto error;

               }

                /* Get class description */

               rc = getClassDescription(className, &attrDescr);

[Canh] Because in getClassDescription() are using " ntfimcn_cb.immOmHandle"
to get class description, so the input of
saImmOmClassDescriptionMemoryFree_2() has to be " ntfimcn_cb.immOmHandle",
not local variable " immOmHandle" ??. See the attached diff file in my
previous email.

 

               if (rc != SA_AIS_OK) {

-                              LOG_ER("getClassDescription failed %s",
saf_error(rc));

+                             LOG_NO("getClassDescription failed %s",
saf_error(rc));

                               goto error;

               }

@@ -202,8 +201,8 @@ static char *get_rdn_attr_name(const SaImmClassNameT
className)

 
realloc(s_get_rdn_attr_name.attrName,

 
strlen(attrDescr[i]->attrName) + 1);

                                               if
(s_get_rdn_attr_name.attrName == NULL) {

-
LOG_ER("Failed to realloc memory");

-                                                              goto error;

+                                                             LOG_ER("%s:
Failed to realloc memory",__FUNCTION__);

+                                                             osaf_abort(0);

                                               }

 
memcpy(s_get_rdn_attr_name.attrName,

 
attrDescr[i]->attrName,

@@ -231,20 +230,9 @@ error:

               /* NOTE: Resources are allocated by this function

                *       saImmOmClassDescriptionMemoryFree_2() must be called
before

                *       returning from this function. Not done here because
of

-              *       osafassert()

+             *       imcn_exit()

                */

-              LOG_ER("%s Failed", __FUNCTION__);

-              if ( rc == SA_AIS_ERR_NOT_EXIST ) {

-                              LOG_NO("osafntfimcnd restarting due to error
%s.",

-                                              saf_error(rc));

-                              _exit(EXIT_FAILURE);

-              }

-              else

-              {

-                              // core dump will be generated for all other
errors which will be used

-                              // for further analysis of the error.

-                              osafassert(0);

-              }

+             imcn_exit(EXIT_FAILURE);

               return 0; /* Dummy */

}

@@ -936,7 +924,7 @@ done:

static bool initializeImmOmHandle(SaImmHandleT* immOmHandle) {

               struct timespec timeout_ts;

               struct timespec delay_ts;

-              SaAisErrorT ais_rc;

+             SaAisErrorT ais_rc = SA_AIS_OK;

               bool internal_rc = true;

               SaVersionT imm_version = kImmVersion;

@@ -946,7 +934,7 @@ static bool initializeImmOmHandle(SaImmHandleT*
immOmHandle) {

               while (osaf_is_timeout(&timeout_ts) == false) {

                               ais_rc = saImmOmInitialize(immOmHandle,

                                               &omCallbacks, &imm_version);

-                              if (ais_rc != SA_AIS_ERR_TRY_AGAIN) {

+                             if (ais_rc != SA_AIS_ERR_TRY_AGAIN && ais_rc
!= SA_AIS_ERR_TIMEOUT) {

                                               break;

                               }

                               osaf_nanosleep(&delay_ts);

@@ -978,7 +966,7 @@ static void finalizeImmOmHandle(SaImmHandleT
immOmHandle) {

               }

                if (ais_rc != SA_AIS_OK) {

-                              LOG_NO("%s saImmOmInitialize failed %s",
__FUNCTION__,

+                             LOG_NO("%s saImmOmFinalize failed %s",
__FUNCTION__,

                                      saf_error(ais_rc));

               }

}

-- 

2.7.4

 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to